Commit 34fe8d04 authored by Hideto Ueno's avatar Hideto Ueno
Browse files

[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
parent bb87364f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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.
+2 −4
Original line number Diff line number Diff line
@@ -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;
      }
    }
+1 −1
Original line number Diff line number Diff line
@@ -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:
+1 −1
Original line number Diff line number Diff line
@@ -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:
+2 −2
Original line number Diff line number Diff line
@@ -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
Loading