[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining
Bill Wendling via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 25 23:39:13 PDT 2019
void updated this revision to Diff 206587.
void added a comment.
Modify so that no diagnistics are emitted until we can determine if it's an
immediate or not.
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60943/new/
https://reviews.llvm.org/D60943
Files:
lib/CodeGen/CGStmt.cpp
test/Sema/inline-asm-validate-x86.c
Index: test/Sema/inline-asm-validate-x86.c
===================================================================
--- test/Sema/inline-asm-validate-x86.c
+++ test/Sema/inline-asm-validate-x86.c
@@ -147,9 +147,9 @@
// This offset-from-null pointer can be used as an integer constant expression.
__asm__ __volatile__("\n#define S_B abcd%0\n" : : "n"(&((struct s*)0)->b));
// This pointer cannot be used as an integer constant expression.
- __asm__ __volatile__("\n#define GLOBAL_A abcd%0\n" : : "n"(&s.a)); // expected-error{{constraint 'n' expects an integer constant expression}}
+ __asm__ __volatile__("\n#define GLOBAL_A abcd%0\n" : : "e"(&s.a)); // expected-error{{constraint 'e' expects an integer constant expression}}
// Floating-point is also not okay.
- __asm__ __volatile__("\n#define PI abcd%0\n" : : "n"(3.14f)); // expected-error{{constraint 'n' expects an integer constant expression}}
+ __asm__ __volatile__("\n#define PI abcd%0\n" : : "e"(3.14f)); // expected-error{{constraint 'e' expects an integer constant expression}}
#ifdef AMD64
// This arbitrary pointer is fine.
__asm__ __volatile__("\n#define BEEF abcd%0\n" : : "n"((int*)0xdeadbeeeeeef));
Index: lib/CodeGen/CGStmt.cpp
===================================================================
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -1842,11 +1842,9 @@
InputExpr->EvaluateAsRValue(EVResult, getContext(), true);
llvm::APSInt IntResult;
- if (!EVResult.Val.toIntegralConstant(IntResult, InputExpr->getType(),
- getContext()))
- llvm_unreachable("Invalid immediate constant!");
-
- return llvm::ConstantInt::get(getLLVMContext(), IntResult);
+ if (EVResult.Val.toIntegralConstant(IntResult, InputExpr->getType(),
+ getContext()))
+ return llvm::ConstantInt::get(getLLVMContext(), IntResult);
}
Expr::EvalResult Result;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60943.206587.patch
Type: text/x-patch
Size: 1964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190626/a42412be/attachment.bin>
More information about the cfe-commits
mailing list