[PATCH] D60942: Emit diagnostic if inline asm "n" constraint isn't an immediate
Bill Wendling via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 21 03:21:20 PDT 2019
void updated this revision to Diff 195995.
void added a comment.
Herald added a subscriber: eraman.
Fix testcase to get the correct error message.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60942/new/
https://reviews.llvm.org/D60942
Files:
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
test/CodeGen/X86/inline-asm-bad-constraint-n.ll
Index: test/CodeGen/X86/inline-asm-bad-constraint-n.ll
===================================================================
--- test/CodeGen/X86/inline-asm-bad-constraint-n.ll
+++ test/CodeGen/X86/inline-asm-bad-constraint-n.ll
@@ -2,7 +2,7 @@
@x = global i32 0, align 4
-;CHECK: error: invalid operand for inline asm constraint 'n'
+; CHECK: error: constraint 'n' expects an integer constant expression
define void @foo() {
%a = getelementptr i32, i32* @x, i32 1
call void asm sideeffect "foo $0", "n"(i32* %a) nounwind
Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -7865,6 +7865,7 @@
/// visitInlineAsm - Handle a call to an InlineAsm object.
void SelectionDAGBuilder::visitInlineAsm(ImmutableCallSite CS) {
+ LLVMContext &Ctx = *DAG.getContext();
const InlineAsm *IA = cast<InlineAsm>(CS.getCalledValue());
/// ConstraintOperands - Information about all of the constraints.
@@ -7907,7 +7908,7 @@
OpInfo.ConstraintVT =
OpInfo
- .getCallOperandValEVT(*DAG.getContext(), TLI, DAG.getDataLayout())
+ .getCallOperandValEVT(Ctx, TLI, DAG.getDataLayout())
.getSimpleVT();
} else if (OpInfo.Type == InlineAsm::isOutput && !OpInfo.isIndirect) {
// The return value of the call is this value. As such, there is no
@@ -7935,6 +7936,12 @@
// Compute the constraint code and ConstraintType to use.
TLI.ComputeConstraintToUse(T, SDValue());
+ if (T.ConstraintCode == "n" && !isa<ConstantSDNode>(OpInfo.CallOperand))
+ // We've delayed emitting a diagnostic for the "n" constraint because
+ // inlining could cause an integer showing up.
+ return emitInlineAsmError(CS, "constraint 'n' expects an integer "
+ "constant expression");
+
ExtraInfo.update(T);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60942.195995.patch
Type: text/x-patch
Size: 2002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190421/72532fb8/attachment.bin>
More information about the llvm-commits
mailing list