[llvm] 34fe8d0 - [Attributor] Use `changeUseAfterManifest` in AAValueSimplify manifest
Hideto Ueno via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 30 00:11:28 PST 2019
Author: Hideto Ueno
Date: 2019-12-30T17:08:48+09:00
New Revision: 34fe8d0451174829529bb8da8ad0c631825e16e0
URL: https://github.com/llvm/llvm-project/commit/34fe8d0451174829529bb8da8ad0c631825e16e0
DIFF: https://github.com/llvm/llvm-project/commit/34fe8d0451174829529bb8da8ad0c631825e16e0.diff
LOG: [Attributor] Use `changeUseAfterManifest` in AAValueSimplify manifest
Summary: This patch makes `AAValueSimplify` use `changeUsesAfterManifest` in `manifest`. This will invoke simple folding after the manifest.
Reviewers: jdoerfert, sstefan1
Reviewed By: jdoerfert
Subscribers: hiraditya, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71972
Added:
Modified:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/test/Transforms/Attributor/ArgumentPromotion/2008-07-02-array-indexing.ll
llvm/test/Transforms/Attributor/ArgumentPromotion/control-flow.ll
llvm/test/Transforms/Attributor/ArgumentPromotion/control-flow2.ll
llvm/test/Transforms/Attributor/ArgumentPromotion/reserve-tbaa.ll
llvm/test/Transforms/Attributor/value-simplify.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 689bb32390b5..9ac4a4666eb7 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -823,6 +823,16 @@ struct Attributor {
return true;
}
+ /// Helper function to replace all uses of \p V with \p NV. Return true if
+ /// there is any change.
+ bool changeValueAfterManifest(Value &V, Value &NV) {
+ bool Changed = false;
+ for (auto &U : V.uses())
+ Changed |= changeUseAfterManifest(U, NV);
+
+ return Changed;
+ }
+
/// Get pointer operand of memory accessing instruction. If \p I is
/// not a memory accessing instruction, return nullptr. If \p AllowVolatile,
/// is set to false and the instruction is volatile, return nullptr.
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index d909f3856319..0fe2cdc00a48 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -2574,9 +2574,7 @@ struct AAIsDeadFloating : public AAIsDeadValueImpl {
return ChangeStatus::UNCHANGED;
UndefValue &UV = *UndefValue::get(V.getType());
- bool AnyChange = false;
- for (Use &U : V.uses())
- AnyChange |= A.changeUseAfterManifest(U, UV);
+ bool AnyChange = A.changeValueAfterManifest(V, UV);
return AnyChange ? ChangeStatus::CHANGED : ChangeStatus::UNCHANGED;
}
@@ -4149,7 +4147,7 @@ struct AAValueSimplifyImpl : AAValueSimplify {
if (!V.user_empty() && &V != C && V.getType() == C->getType()) {
LLVM_DEBUG(dbgs() << "[Attributor][ValueSimplify] " << V << " -> " << *C
<< "\n");
- replaceAllInstructionUsesWith(V, *C);
+ A.changeValueAfterManifest(V, *C);
Changed = ChangeStatus::CHANGED;
}
}
diff --git a/llvm/test/Transforms/Attributor/ArgumentPromotion/2008-07-02-array-indexing.ll b/llvm/test/Transforms/Attributor/ArgumentPromotion/2008-07-02-array-indexing.ll
index 0fa282be4442..ea35e4b0cb05 100644
--- a/llvm/test/Transforms/Attributor/ArgumentPromotion/2008-07-02-array-indexing.ll
+++ b/llvm/test/Transforms/Attributor/ArgumentPromotion/2008-07-02-array-indexing.ll
@@ -9,7 +9,7 @@ define internal i32 @callee(i1 %C, i32* %A) {
; CHECK-SAME: (i1 [[C:%.*]], i32* noalias nocapture nofree nonnull readonly dereferenceable(4) [[A:%.*]])
; CHECK-NEXT: entry:
; CHECK-NEXT: [[A_0:%.*]] = load i32, i32* null
-; CHECK-NEXT: br i1 false, label [[T:%.*]], label [[F:%.*]]
+; CHECK-NEXT: br label [[F:%.*]]
; CHECK: T:
; CHECK-NEXT: unreachable
; CHECK: F:
diff --git a/llvm/test/Transforms/Attributor/ArgumentPromotion/control-flow.ll b/llvm/test/Transforms/Attributor/ArgumentPromotion/control-flow.ll
index cc6868fd4d2e..ba69c588f246 100644
--- a/llvm/test/Transforms/Attributor/ArgumentPromotion/control-flow.ll
+++ b/llvm/test/Transforms/Attributor/ArgumentPromotion/control-flow.ll
@@ -6,7 +6,7 @@ define internal i32 @callee(i1 %C, i32* %P) {
; CHECK-LABEL: define {{[^@]+}}@callee
; CHECK-SAME: (i1 [[C:%.*]], i32* noalias nocapture nofree readnone [[P:%.*]])
; CHECK-NEXT: entry:
-; CHECK-NEXT: br i1 true, label [[T:%.*]], label [[F:%.*]]
+; CHECK-NEXT: br label [[T:%.*]]
; CHECK: T:
; CHECK-NEXT: ret i32 17
; CHECK: F:
diff --git a/llvm/test/Transforms/Attributor/ArgumentPromotion/control-flow2.ll b/llvm/test/Transforms/Attributor/ArgumentPromotion/control-flow2.ll
index 4924e2c1518d..03c337fbfc59 100644
--- a/llvm/test/Transforms/Attributor/ArgumentPromotion/control-flow2.ll
+++ b/llvm/test/Transforms/Attributor/ArgumentPromotion/control-flow2.ll
@@ -6,11 +6,11 @@ target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:1
define internal i32 @callee(i1 %C, i32* %P) {
; CHECK-LABEL: define {{[^@]+}}@callee
; CHECK-SAME: (i1 [[C:%.*]], i32* noalias nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P:%.*]])
-; CHECK-NEXT: br i1 false, label [[T:%.*]], label [[F:%.*]]
+; CHECK-NEXT: br label [[F:%.*]]
; CHECK: T:
; CHECK-NEXT: unreachable
; CHECK: F:
-; CHECK-NEXT: [[X:%.*]] = load i32, i32* [[P]], align 4
+; CHECK-NEXT: [[X:%.*]] = load i32, i32* [[P:%.*]], align 4
; CHECK-NEXT: ret i32 [[X]]
;
br i1 %C, label %T, label %F
diff --git a/llvm/test/Transforms/Attributor/ArgumentPromotion/reserve-tbaa.ll b/llvm/test/Transforms/Attributor/ArgumentPromotion/reserve-tbaa.ll
index 093dcb4932fc..2f57f102f87d 100644
--- a/llvm/test/Transforms/Attributor/ArgumentPromotion/reserve-tbaa.ll
+++ b/llvm/test/Transforms/Attributor/ArgumentPromotion/reserve-tbaa.ll
@@ -17,7 +17,7 @@ define internal fastcc void @fn(i32* nocapture readonly %p1, i64* nocapture read
; CHECK-LABEL: define {{[^@]+}}@fn
; CHECK-SAME: (i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P1:%.*]], i64* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[P2:%.*]])
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[TMP0:%.*]] = load i64, i64* @c, align 8, !tbaa !0
+; CHECK-NEXT: [[TMP0:%.*]] = load i64, i64* undef, align 8, !tbaa !0
; CHECK-NEXT: [[CONV:%.*]] = trunc i64 [[TMP0]] to i32
; CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* @g, align 4, !tbaa !4
; CHECK-NEXT: [[CONV1:%.*]] = trunc i32 [[TMP1]] to i8
diff --git a/llvm/test/Transforms/Attributor/value-simplify.ll b/llvm/test/Transforms/Attributor/value-simplify.ll
index 4e765cc233f1..6eee245a4341 100644
--- a/llvm/test/Transforms/Attributor/value-simplify.ll
+++ b/llvm/test/Transforms/Attributor/value-simplify.ll
@@ -145,7 +145,7 @@ f:
define internal i1 @ipccp2i(i1 %a) {
; CHECK-LABEL: define {{[^@]+}}@ipccp2i
; CHECK-SAME: (i1 returned [[A:%.*]]) #0
-; CHECK-NEXT: br i1 true, label [[T:%.*]], label [[F:%.*]]
+; CHECK-NEXT: br label %t
; CHECK: t:
; CHECK-NEXT: ret i1 true
; CHECK: f:
More information about the llvm-commits
mailing list