[llvm] 8b9f2b6 - [Metarenamer] Distinguish instructions by opcodes
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 16 02:11:37 PDT 2023
Author: Max Kazantsev
Date: 2023-03-16T16:11:11+07:00
New Revision: 8b9f2b6244d2ae8a3d469cff58bbb3dfa5e04575
URL: https://github.com/llvm/llvm-project/commit/8b9f2b6244d2ae8a3d469cff58bbb3dfa5e04575
DIFF: https://github.com/llvm/llvm-project/commit/8b9f2b6244d2ae8a3d469cff58bbb3dfa5e04575.diff
LOG: [Metarenamer] Distinguish instructions by opcodes
This should improve readability of metarenamed code.
Differential Revision: https://reviews.llvm.org/D145896
Reviewed By: nikic
Added:
llvm/test/Transforms/MetaRenamer/opcodes.ll
Modified:
llvm/lib/Transforms/Utils/MetaRenamer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/MetaRenamer.cpp b/llvm/lib/Transforms/Utils/MetaRenamer.cpp
index 0987fdc33fdd5..0ab750ad43cd1 100644
--- a/llvm/lib/Transforms/Utils/MetaRenamer.cpp
+++ b/llvm/lib/Transforms/Utils/MetaRenamer.cpp
@@ -115,7 +115,7 @@ void MetaRename(Function &F) {
for (auto &I : BB)
if (!I.getType()->isVoidTy())
- I.setName("inst");
+ I.setName(I.getOpcodeName());
}
}
diff --git a/llvm/test/Transforms/MetaRenamer/opcodes.ll b/llvm/test/Transforms/MetaRenamer/opcodes.ll
new file mode 100644
index 0000000000000..8a78677edbff1
--- /dev/null
+++ b/llvm/test/Transforms/MetaRenamer/opcodes.ll
@@ -0,0 +1,45 @@
+; RUN: opt -passes=metarenamer -S < %s | FileCheck %s
+
+define void @opcodes(ptr %p, ptr %arr) {
+; CHECK-LABEL: bb:
+; CHECK: %load = load i32, ptr %arg, align 4
+; CHECK: br label %bb2
+; CHECK-LABEL: bb2: ; preds = %bb5, %bb
+; CHECK: %phi = phi i32 [ %load, %bb ], [ %sub, %bb5 ]
+; CHECK: %icmp = icmp eq i32 %phi, 0
+; CHECK: br i1 %icmp, label %bb8, label %bb3
+; CHECK-LABEL: bb3: ; preds = %bb2
+; CHECK: %sub = sub i32 %phi, 1
+; CHECK: %icmp4 = icmp ult i32 %sub, %load
+; CHECK: br i1 %icmp4, label %bb5, label %bb9
+; CHECK-LABEL: bb5: ; preds = %bb3
+; CHECK: %getelementptr = getelementptr i32, ptr %arg, i32 %phi
+; CHECK: %load6 = load i32, ptr %getelementptr, align 4
+; CHECK: %icmp7 = icmp eq i32 %load6, 0
+; CHECK: br i1 %icmp7, label %bb2, label %bb8
+preheader:
+ %len = load i32, ptr %p
+ br label %loop
+
+loop:
+ %iv = phi i32 [%len, %preheader], [%iv.next, %backedge]
+ %zero_cond = icmp eq i32 %iv, 0
+ br i1 %zero_cond, label %exit, label %range_check_block
+
+range_check_block:
+ %iv.next = sub i32 %iv, 1
+ %range_check = icmp ult i32 %iv.next, %len
+ br i1 %range_check, label %backedge, label %fail
+
+backedge:
+ %el.ptr = getelementptr i32, ptr %p, i32 %iv
+ %el = load i32, ptr %el.ptr
+ %loop.cond = icmp eq i32 %el, 0
+ br i1 %loop.cond, label %loop, label %exit
+
+exit:
+ ret void
+
+fail:
+ unreachable
+}
More information about the llvm-commits
mailing list