llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

UNREACHABLE in X86InstrInfo executed with "atomicrmw max" instruction

Open llvmbot opened this issue 14 years ago • 4 comments

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

  1. Running pass 'Function Pass Manager' on module 'bugpoint-reduced-simplified.ll'.
  2. Running pass 'Post-RA pseudo instruction expansion pass' on function '@MergeStats'

llvmbot avatar Jul 25 '12 17:07 llvmbot

fixed in r164281

darkbuck avatar Sep 20 '12 08:09 darkbuck

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

darkbuck avatar Aug 21 '12 06:08 darkbuck

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

darkbuck avatar Aug 21 '12 06:08 darkbuck

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.

llvmbot avatar Aug 01 '12 15:08 llvmbot