llvm.org GIT mirror llvm / ef2833b
[ARM] Skip inline asm memory operands in DAGToDAGISel The current logic for handling inline asm operands in DAGToDAGISel interprets the operands by looking for constants, which should represent the flags describing the kind of operand we're dealing with (immediate, memory, register def etc). The operands representing actual data are skipped only if they are non-const, with the exception of immediate operands which are skipped explicitly when a flag describing an immediate is found. The oversight is that memory operands may be const too (e.g. for device drivers reading a fixed address), so we should explicitly skip the operand following a flag describing a memory operand. If we don't, we risk interpreting that constant as a flag, which is definitely not intended. Fixes PR26038 Differential Revision: https://reviews.llvm.org/D22103 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275776 91177308-0d34-0410-b5e6-96231b3b80d8 Diana Picus 4 years ago
2 changed file(s) with 22 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
42634263 if (Changed && InlineAsm::isUseOperandTiedToDef(Flag, DefIdx))
42644264 IsTiedToChangedOp = OpChanged[DefIdx];
42654265
4266 // Memory operands to inline asm in the SelectionDAG are modeled with two
4267 // operands: a constant of value InlineAsm::Kind_Mem followed by the input
4268 // operand. If we get here and we have a Kind_Mem, skip the next operand (so
4269 // it doesn't get misinterpreted), and continue. We do this here because
4270 // it's important to update the OpChanged array correctly before moving on.
4271 if (Kind == InlineAsm::Kind_Mem) {
4272 SDValue op = N->getOperand(++i);
4273 AsmNodeOperands.push_back(op);
4274 continue;
4275 }
4276
42664277 if (Kind != InlineAsm::Kind_RegUse && Kind != InlineAsm::Kind_RegDef
42674278 && Kind != InlineAsm::Kind_RegDefEarlyClobber)
42684279 continue;
120120 %0 = tail call <4 x i32> asm "vld1.s32 {${0:e}[], ${0:f}[]}, [$1]", "=w,r"(i32* %p) nounwind
121121 ret <4 x i32> %0
122122 }
123
124 ; Bugzilla PR26038
125
126 define i32 @fn1() local_unnamed_addr nounwind {
127 ; CHECK-LABEL: fn1
128 entry:
129 ; CHECK: mov [[addr:r[0-9]+]], #5
130 ; CHECK: ldrh {{.*}}[[addr]]
131 %0 = tail call i32 asm "ldrh $0, $1", "=r,*Q"(i8* inttoptr (i32 5 to i8*)) nounwind
132 ret i32 %0
133 }