UNREACHABLE in X86InstrInfo executed with "atomicrmw max" instruction
| Bugzilla Link | 13458 |
| Resolution | FIXED |
| Resolved on | Sep 20, 2012 01:19 |
| Version | unspecified |
| OS | All |
| Attachments | test case |
| Reporter | LLVM Bugzilla Contributor |
| CC | @darkbuck |
Extended Description
With the attached test case, which is basically just a single "atomicrmw max", I get the following crash with top-of-tree:
% llc bugpoint-reduced-simplified.ll -o /dev/null Cannot emit physreg copy instruction UNREACHABLE executed at X86InstrInfo.cpp:2868! [...] 0. Program arguments: llc bugpoint-reduced-simplified.ll -o /dev/null
- Running pass 'Function Pass Manager' on module 'bugpoint-reduced-simplified.ll'.
- Running pass 'Post-RA pseudo instruction expansion pass' on function '@MergeStats'
fixed in r164281
this issue is addressed in http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120813/148571.html, i.e. adding the missing 64-bit max/min in 32-bit taget
it's so far blocked by review
this issue is addressed in http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120813/148571.html, i.e. adding the missing 64-bit max/min in 32-bit taget
it's so far blocked by review
The bug is in X86TargetLowering::EmitAtomicMinMaxWithCustomInserter. This function lowers the AtomicMin/Max instructions under the assumption that everything is 32-bit, and produces a sequence that uses 32-bit instructions, uses (hardcoded) EAX as a temporary, etc.
The problem is that EmitAtomicMinMaxWithCustomInserter is also used to lower ATOMMAX64 and other 16 and 64-bit atomic min/max pseudo-instructions. When the inputs to atomicmax are 64-bit, the 32-bit lowering results in trying to COPY a GR64 into a GR32 which, in turn, causes the crash. The bitwise atomic operations are handled properly in EmitAtomicBitwiseWithCustomInserter: the function is passed the correct register class, move instructions, etc.
A possible solution is to implement EmitAtomicMinMaxWithCustomInserter using an abstraction that is similar to EmitAtomicBitwiseWithCustomInserter, where the register classes and instructions are provided from the outside.