[PATCH] D145416: [clang] model 'p' inline asm constraint as reading memory
Nick Desaulniers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 6 13:33:17 PST 2023
nickdesaulniers updated this revision to Diff 502781.
nickdesaulniers added a comment.
- add sema test to validate 'p' inputs as per @efriedma
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145416/new/
https://reviews.llvm.org/D145416
Files:
clang/lib/Basic/TargetInfo.cpp
clang/test/CodeGen/inline-asm-p-constraint.c
clang/test/Sema/inline-asm-validate.c
Index: clang/test/Sema/inline-asm-validate.c
===================================================================
--- clang/test/Sema/inline-asm-validate.c
+++ clang/test/Sema/inline-asm-validate.c
@@ -2,7 +2,9 @@
unsigned t, r, *p;
-int foo (void) {
+void foo (void) {
__asm__ __volatile__( "stxr %w[_t], %[_r], [%[_p]]" : [_t] "=&r" (t) : [_p] "p" (p), [_r] "r" (r) : "memory"); // expected-warning{{value size does not match register size specified by the constraint and modifier}} expected-note {{use constraint modifier "w"}}
- return 1;
+ // Ensure we accept pointer and non-pointer arguments to "p" constrained
+ // inputs.
+ asm (""::"p"(t), "p"(p));
}
Index: clang/test/CodeGen/inline-asm-p-constraint.c
===================================================================
--- clang/test/CodeGen/inline-asm-p-constraint.c
+++ clang/test/CodeGen/inline-asm-p-constraint.c
@@ -11,5 +11,4 @@
asm ("":"=r"(x):"p"(¤t_task));
}
// CHECK: %0 = call i64 asm "", "=r,r"(ptr @current_task) #[[ATTR:[0-9]+]]
-// FIXME: should be memory(read)
-// CHECK: attributes #[[ATTR]] = { nounwind memory(none) }
+// CHECK: attributes #[[ATTR]] = { nounwind memory(read) }
Index: clang/lib/Basic/TargetInfo.cpp
===================================================================
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -896,14 +896,13 @@
Info.setAllowsMemory();
break;
case 'g': // general register, memory operand or immediate integer.
+ case 'p': // address operand.
case 'X': // any operand.
Info.setAllowsRegister();
Info.setAllowsMemory();
break;
case 'E': // immediate floating point.
case 'F': // immediate floating point.
- case 'p': // address operand.
- break;
case ',': // multiple alternative constraint. Ignore comma.
break;
case '#': // Ignore as constraint.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145416.502781.patch
Type: text/x-patch
Size: 1901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230306/63c50ecd/attachment.bin>
More information about the cfe-commits
mailing list