[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:00:21 PST 2023
nickdesaulniers created this revision.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
GCC doesn't CSE inline asm when 'p' is used on inputs, neither should
clang. In order to do so, we must not set memory(none) modref on such
inline asm.
If you're passing the address of a variable into inline asm as an
operand, you're going to be reading memory!
Link: https://lore.kernel.org/lkml/20230306120106.GE1267364@hirez.programming.kicks-ass.net/
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145416
Files:
clang/lib/Basic/TargetInfo.cpp
clang/test/CodeGen/inline-asm-p-constraint.c
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.502765.patch
Type: text/x-patch
Size: 1226 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230306/503e2789/attachment.bin>
More information about the cfe-commits
mailing list