[PATCH] PR16490: Fix a crash in ARM inline asm
Joey Gouly
joey.gouly at arm.com
Wed Jul 3 05:17:57 PDT 2013
In the DAG, the way immediates are constructed is with two operands, the first operand is a constant of InlineAsm::Kind_Imm, and the second is the actual immediate. (see SelectionDAGBuilder::visitInlineAsm, ~6249 of lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp).
So in 'ARMDAGToDAGISel::SelectInlineAsm', if we reach a constant with the Kind_Imm value, we need to skip the next constant. Otherwise funny things happen, because it thinks the immediate constant is actually a register use/def. It seems this was working with small, positive constants, however with the constant '-14', it was producing massive unsigned numbers and causing crashes.
Does this make sense?
http://llvm-reviews.chandlerc.com/D1084
Files:
lib/Target/ARM/ARMISelDAGToDAG.cpp
test/CodeGen/ARM/arm-modifier.ll
Index: lib/Target/ARM/ARMISelDAGToDAG.cpp
===================================================================
--- lib/Target/ARM/ARMISelDAGToDAG.cpp
+++ lib/Target/ARM/ARMISelDAGToDAG.cpp
@@ -3491,6 +3491,12 @@
else
continue;
+ if (Kind == InlineAsm::Kind_Imm) {
+ SDValue op = N->getOperand(++i);
+ AsmNodeOperands.push_back(op);
+ continue;
+ }
+
unsigned NumRegs = InlineAsm::getNumOperandRegisters(Flag);
if (NumRegs)
OpChanged.push_back(false);
Index: test/CodeGen/ARM/arm-modifier.ll
===================================================================
--- test/CodeGen/ARM/arm-modifier.ll
+++ test/CodeGen/ARM/arm-modifier.ll
@@ -65,3 +65,8 @@
%0 = tail call i64 asm sideeffect "ldrexd $0, ${0:H}, [$1]", "=&r,r,*Qo"(i64* %val, i64* %val) nounwind
ret i64 %0
}
+
+define void @f5(i64 %__pu_val) {
+ call void asm sideeffect "$1", "r,i"(i64 %__pu_val, i32 -14)
+ ret void
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1084.1.patch
Type: text/x-patch
Size: 941 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130703/1446ac4e/attachment.bin>
More information about the llvm-commits
mailing list