[llvm] [llvm-diff] Also diff alloca's allocated type and alignment (PR #84781)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 11 09:33:58 PDT 2024
https://github.com/YanWQ-monad updated https://github.com/llvm/llvm-project/pull/84781
>From 431bdd42855c957eb0efefc4a03ac4adacd4c5c8 Mon Sep 17 00:00:00 2001
From: YanWQ-monad <YanWQmonad at gmail.com>
Date: Mon, 11 Mar 2024 23:59:47 +0800
Subject: [PATCH 1/3] Diff alloca allocated type and alignment
---
llvm/tools/llvm-diff/lib/DifferenceEngine.cpp | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp b/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp
index 64b5051af14892..b34fd2acaa5368 100644
--- a/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp
+++ b/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp
@@ -527,6 +527,20 @@ class FunctionDifferenceEngine {
Difference = true;
}
return Difference;
+ } else if (isa<AllocaInst>(L)) {
+ const AllocaInst *LI = cast<AllocaInst>(L);
+ const AllocaInst *RI = cast<AllocaInst>(R);
+
+ if (LI->getAllocatedType() != RI->getAllocatedType()) {
+ if (Complain)
+ Engine.log("alloca allocated type differ");
+ return true;
+ }
+ if (LI->getAlign() != RI->getAlign()) {
+ if (Complain)
+ Engine.log("alloca alignment differ");
+ return true;
+ }
} else if (isa<UnreachableInst>(L)) {
return false;
}
>From d2fcbccfa11f90f19e536352d7bd8427bb2b6b29 Mon Sep 17 00:00:00 2001
From: YanWQ-monad <YanWQmonad at gmail.com>
Date: Tue, 12 Mar 2024 00:31:31 +0800
Subject: [PATCH 2/3] Use `hasSameSpecialState` instead
---
llvm/tools/llvm-diff/lib/DifferenceEngine.cpp | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp b/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp
index b34fd2acaa5368..d8622159151230 100644
--- a/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp
+++ b/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp
@@ -377,6 +377,9 @@ class FunctionDifferenceEngine {
return true;
}
+ if (!L->hasSameSpecialState(R))
+ return true;
+
if (isa<CmpInst>(L)) {
if (cast<CmpInst>(L)->getPredicate()
!= cast<CmpInst>(R)->getPredicate()) {
@@ -527,20 +530,6 @@ class FunctionDifferenceEngine {
Difference = true;
}
return Difference;
- } else if (isa<AllocaInst>(L)) {
- const AllocaInst *LI = cast<AllocaInst>(L);
- const AllocaInst *RI = cast<AllocaInst>(R);
-
- if (LI->getAllocatedType() != RI->getAllocatedType()) {
- if (Complain)
- Engine.log("alloca allocated type differ");
- return true;
- }
- if (LI->getAlign() != RI->getAlign()) {
- if (Complain)
- Engine.log("alloca alignment differ");
- return true;
- }
} else if (isa<UnreachableInst>(L)) {
return false;
}
>From 34e6fdb39bef6cd5cf04967e588a6bd37306b8a5 Mon Sep 17 00:00:00 2001
From: YanWQ-monad <YanWQmonad at gmail.com>
Date: Tue, 12 Mar 2024 00:33:45 +0800
Subject: [PATCH 3/3] Add complain log
---
llvm/tools/llvm-diff/lib/DifferenceEngine.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp b/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp
index d8622159151230..5b91e317a85b60 100644
--- a/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp
+++ b/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp
@@ -377,8 +377,11 @@ class FunctionDifferenceEngine {
return true;
}
- if (!L->hasSameSpecialState(R))
+ if (!L->hasSameSpecialState(R)) {
+ if (Complain)
+ Engine.log("special states differ");
return true;
+ }
if (isa<CmpInst>(L)) {
if (cast<CmpInst>(L)->getPredicate()
More information about the llvm-commits
mailing list