[PATCH] D129276: [IR][OpaquePointers] Properly print cmpxchg with pointer operands.
Denis Antrushin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 7 04:31:22 PDT 2022
dantrushin created this revision.
dantrushin added reviewers: nikic, apilipenko.
Herald added a subscriber: hiraditya.
Herald added a project: All.
dantrushin requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
With opaque pointers address of pointer variable and its value have
same type (`ptr`). As a result, cmpxchg is printed without values
types in LLVM assembly and cannot be read back. Add AtomicCmpXchg
to the list of instructions which always have operand types printed.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D129276
Files:
llvm/lib/IR/AsmWriter.cpp
llvm/test/Assembler/opaque-ptr.ll
Index: llvm/test/Assembler/opaque-ptr.ll
===================================================================
--- llvm/test/Assembler/opaque-ptr.ll
+++ llvm/test/Assembler/opaque-ptr.ll
@@ -107,6 +107,14 @@
ret void
}
+; CHECK: define void @cmpxchg_ptr(ptr %p, ptr %a, ptr %b)
+; CHECK: %val_success = cmpxchg ptr %p, ptr %a, ptr %b acq_rel monotonic
+; CHECK: ret void
+define void @cmpxchg_ptr(ptr %p, ptr %a, ptr %b) {
+ %val_success = cmpxchg ptr %p, ptr %a, ptr %b acq_rel monotonic
+ ret void
+}
+
; CHECK: define void @atomicrmw(ptr %a, i32 %i)
; CHECK: %b = atomicrmw add ptr %a, i32 %i acquire
; CHECK: ret void
Index: llvm/lib/IR/AsmWriter.cpp
===================================================================
--- llvm/lib/IR/AsmWriter.cpp
+++ llvm/lib/IR/AsmWriter.cpp
@@ -4295,9 +4295,9 @@
bool PrintAllTypes = false;
Type *TheType = Operand->getType();
- // Select, Store and ShuffleVector always print all types.
- if (isa<SelectInst>(I) || isa<StoreInst>(I) || isa<ShuffleVectorInst>(I)
- || isa<ReturnInst>(I)) {
+ // Select, Store, ShuffleVector and CmpXchg always print all types.
+ if (isa<SelectInst>(I) || isa<StoreInst>(I) || isa<ShuffleVectorInst>(I) ||
+ isa<ReturnInst>(I) || isa<AtomicCmpXchgInst>(I)) {
PrintAllTypes = true;
} else {
for (unsigned i = 1, E = I.getNumOperands(); i != E; ++i) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129276.442863.patch
Type: text/x-patch
Size: 1412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220707/c77774f3/attachment.bin>
More information about the llvm-commits
mailing list