LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 882 - Inline asm crash in linux kernel
Summary: Inline asm crash in linux kernel
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Backend: X86 (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Chris Lattner
URL:
Keywords: compile-fail
Depends on:
Blocks: 862
  Show dependency tree
 
Reported: 2006-08-17 11:04 PDT by Andrew Lenharth
Modified: 2010-02-22 12:51 PST (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Lenharth 2006-08-17 11:04:02 PDT
The following test case crashes the X86 backend.

target endian = little
target pointersize = 32
target triple = "i686-pc-linux-gnu"
%str = external global [12 x sbyte]             ; <[12 x sbyte]*> [#uses=1]

implementation   ; Functions:

void %unknown_bootoption() {
entry:
        call void asm sideeffect "ud2\0A\09.word ${0:c}\0A\09.long ${1:c}\0A",
"i,i,~{dirflag},~{fpsr},~{flags}"( int 235, sbyte* getelementptr ([12 x sbyte]*
%str, int 0, uint 0) )
        ret void
}
Comment 1 Chris Lattner 2006-08-17 13:26:26 PDT
Evan, this is a bug in the bottom-up selection code.

The problem is that X86GenDAGISel.inc calls SelectInlineAsmMemoryOperands on line 23765.
This method (in SelectionDAGISel.cpp) calls SelectInlineAsmMemoryOperand on memops.  However, these 
operands are not getting added to the selection queue, so the X86ISD::Wrapper object never gets selected.

If you won't get to this before you leave, please reassign it back to me.

-Chris
Comment 2 Evan Cheng 2006-10-31 02:22:48 PST
Looks like there is another bug:

Operand 4 of the inline asm node is an immediate 11. That means operand 5 is
expected to be an immediate as well. But it is a X86ISD::Wrapper of
TargetGlobalAddress <[12 x sbyte]* %str> which would select to a X86::MOVri.
This would still fail.
Comment 3 Chris Lattner 2006-10-31 14:12:05 PST
Implemented.  Testcase here:  CodeGen/X86/asm-global-imm.ll

There are several patches, so not listing here.

-Chris