[llvm] b2c7600 - [Attributor] Ignore uses if a value is simplified

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 12 15:39:40 PST 2020


Author: Johannes Doerfert
Date: 2020-02-12T17:36:38-06:00
New Revision: b2c76002caae91689e94d4ddd2bf4c3474e82066

URL: https://github.com/llvm/llvm-project/commit/b2c76002caae91689e94d4ddd2bf4c3474e82066
DIFF: https://github.com/llvm/llvm-project/commit/b2c76002caae91689e94d4ddd2bf4c3474e82066.diff

LOG: [Attributor] Ignore uses if a value is simplified

If we have a replacement for a value, via AAValueSimplify, the original
value will lose all its uses. Thus, as long as a value is simplified we
can skip the uses in checkForAllUses, given that these uses are
transitive uses for the simplified version and will therefore affect the
simplified version as necessary.

Since this allowed us to remove calls without side-effects and a known
return value, we need to make sure not to eliminate `musttail` calls.
Those we keep around, or later remove the entire `musttail` call chain.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/Attributor.cpp
    llvm/test/Transforms/Attributor/ArgumentPromotion/2008-07-02-array-indexing.ll
    llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead.ll
    llvm/test/Transforms/Attributor/IPConstantProp/arg-count-mismatch.ll
    llvm/test/Transforms/Attributor/IPConstantProp/openmp_parallel_for.ll
    llvm/test/Transforms/Attributor/IPConstantProp/remove-call-inst.ll
    llvm/test/Transforms/Attributor/IPConstantProp/return-constant.ll
    llvm/test/Transforms/Attributor/IPConstantProp/solve-after-each-resolving-undefs-for-function.ll
    llvm/test/Transforms/Attributor/callbacks.ll
    llvm/test/Transforms/Attributor/liveness.ll
    llvm/test/Transforms/Attributor/nonnull.ll
    llvm/test/Transforms/Attributor/value-simplify.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 1d0e82c45d88..d53e8e4d7f90 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -2916,6 +2916,12 @@ struct AAIsDeadFloating : public AAIsDeadValueImpl {
     if (V.use_empty())
       return ChangeStatus::UNCHANGED;
 
+    bool UsedAssumedInformation = false;
+    Optional<ConstantInt *> CI =
+        getAssumedConstant(A, V, *this, UsedAssumedInformation);
+    if (CI.hasValue() && CI.getValue())
+      return ChangeStatus::UNCHANGED;
+
     UndefValue &UV = *UndefValue::get(V.getType());
     bool AnyChange = A.changeValueAfterManifest(V, UV);
     return AnyChange ? ChangeStatus::CHANGED : ChangeStatus::UNCHANGED;
@@ -3092,6 +3098,9 @@ struct AAIsDeadReturned : public AAIsDeadValueImpl {
     UndefValue &UV = *UndefValue::get(getAssociatedFunction()->getReturnType());
     auto RetInstPred = [&](Instruction &I) {
       ReturnInst &RI = cast<ReturnInst>(I);
+      if (auto *CI = dyn_cast<CallInst>(RI.getReturnValue()))
+        if (CI->isMustTailCall())
+          return true;
       if (!isa<UndefValue>(RI.getReturnValue()))
         AnyChange |= A.changeUseAfterManifest(RI.getOperandUse(0), UV);
       return true;
@@ -4730,6 +4739,14 @@ struct AAValueSimplifyCallSiteReturned : AAValueSimplifyReturned {
   AAValueSimplifyCallSiteReturned(const IRPosition &IRP)
       : AAValueSimplifyReturned(IRP) {}
 
+  /// See AbstractAttribute::manifest(...).
+  ChangeStatus manifest(Attributor &A) override {
+    if (auto *CI = dyn_cast<CallInst>(&getAssociatedValue()))
+      if (CI->isMustTailCall())
+        return ChangeStatus::UNCHANGED;
+    return AAValueSimplifyReturned::manifest(A);
+  }
+
   void trackStatistics() const override {
     STATS_DECLTRACK_CSRET_ATTR(value_simplify)
   }
@@ -6557,6 +6574,24 @@ bool Attributor::isAssumedDead(const AbstractAttribute &AA,
 bool Attributor::checkForAllUses(
     const function_ref<bool(const Use &, bool &)> &Pred,
     const AbstractAttribute &QueryingAA, const Value &V) {
+
+  // Check the trivial case first as it catches void values.
+  if (V.use_empty())
+    return true;
+
+  // If the value is replaced by another one, for now a constant, we do not have
+  // uses. Note that this requires users of `checkForAllUses` to not recurse but
+  // instead use the `follow` callback argument to look at transitive users,
+  // however, that should be clear from the presence of the argument.
+  bool UsedAssumedInformation = false;
+  Optional<ConstantInt *> CI =
+      getAssumedConstant(*this, V, QueryingAA, UsedAssumedInformation);
+  if (CI.hasValue() && CI.getValue()) {
+    LLVM_DEBUG(dbgs() << "[Attributor] Value is simplified, uses skipped: " << V
+                      << " -> " << *CI.getValue() << "\n");
+    return true;
+  }
+
   const IRPosition &IRP = QueryingAA.getIRPosition();
   SmallVector<const Use *, 16> Worklist;
   SmallPtrSet<const Use *, 16> Visited;
@@ -6567,9 +6602,6 @@ bool Attributor::checkForAllUses(
   LLVM_DEBUG(dbgs() << "[Attributor] Got " << Worklist.size()
                     << " initial uses to check\n");
 
-  if (Worklist.empty())
-    return true;
-
   bool AnyDead = false;
   const Function *ScopeFn = IRP.getAnchorScope();
   const auto *LivenessAA =

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 8742c4fa46a0..982100dfde0e 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
@@ -6,7 +6,7 @@
 ; because there is a load of %A in the entry block
 define internal i32 @callee(i1 %C, i32* %A) {
 ; CHECK-LABEL: define {{[^@]+}}@callee
-; CHECK-SAME: (i1 [[C:%.*]], i32* noalias nocapture nofree nonnull readonly align 536870912 dereferenceable(4) [[A:%.*]])
+; CHECK-SAME: (i32* noalias nocapture nofree nonnull readonly align 536870912 dereferenceable(4) [[A:%.*]])
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[A_0:%.*]] = load i32, i32* null, align 536870912
 ; CHECK-NEXT:    br label [[F:%.*]]
@@ -34,7 +34,7 @@ F:
 
 define i32 @foo() {
 ; CHECK-LABEL: define {{[^@]+}}@foo()
-; CHECK-NEXT:    [[X:%.*]] = call i32 @callee(i1 false, i32* noalias nofree readonly align 536870912 null)
+; CHECK-NEXT:    [[X:%.*]] = call i32 @callee(i32* noalias nofree readonly align 536870912 null)
 ; CHECK-NEXT:    ret i32 [[X]]
 ;
   %X = call i32 @callee(i1 false, i32* null)             ; <i32> [#uses=1]

diff  --git a/llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead.ll b/llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead.ll
index 3396cf3b4ac7..563294148347 100644
--- a/llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead.ll
+++ b/llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead.ll
@@ -20,7 +20,7 @@ define internal i32 @test(i32* %X, i32* %Y) {
 ; OLDPM-NEXT:    br i1 true, label [[LIVE:%.*]], label [[DEAD:%.*]]
 ; OLDPM:       live:
 ; OLDPM-NEXT:    store i32 0, i32* [[X]], align 4
-; OLDPM-NEXT:    ret i32 0
+; OLDPM-NEXT:    ret i32 undef
 ; OLDPM:       dead:
 ; OLDPM-NEXT:    unreachable
 ;
@@ -29,7 +29,7 @@ define internal i32 @test(i32* %X, i32* %Y) {
 ; NEWPM_MODULE-NEXT:    br i1 true, label [[LIVE:%.*]], label [[DEAD:%.*]]
 ; NEWPM_MODULE:       live:
 ; NEWPM_MODULE-NEXT:    store i32 0, i32* [[X]], align 4
-; NEWPM_MODULE-NEXT:    ret i32 0
+; NEWPM_MODULE-NEXT:    ret i32 undef
 ; NEWPM_MODULE:       dead:
 ; NEWPM_MODULE-NEXT:    unreachable
 ;
@@ -38,7 +38,7 @@ define internal i32 @test(i32* %X, i32* %Y) {
 ; NEWPM_CGSCC-NEXT:    br i1 true, label [[LIVE:%.*]], label [[DEAD:%.*]]
 ; NEWPM_CGSCC:       live:
 ; NEWPM_CGSCC-NEXT:    store i32 0, i32* [[X]], align 4
-; NEWPM_CGSCC-NEXT:    ret i32 0
+; NEWPM_CGSCC-NEXT:    ret i32 undef
 ; NEWPM_CGSCC:       dead:
 ; NEWPM_CGSCC-NEXT:    unreachable
 ;
@@ -53,11 +53,29 @@ dead:
 }
 
 define internal i32 @caller(i32* %B) {
-; CHECK-LABEL: define {{[^@]+}}@caller()
-; CHECK-NEXT:    [[A:%.*]] = alloca i32
-; CHECK-NEXT:    store i32 1, i32* [[A]], align 4
-; CHECK-NEXT:    [[C:%.*]] = call i32 @test(i32* noalias nocapture nofree nonnull writeonly align 4 dereferenceable(4) [[A]])
-; CHECK-NEXT:    ret i32 0
+; OLDPM_MODULE-LABEL: define {{[^@]+}}@caller()
+; OLDPM_MODULE-NEXT:    [[A:%.*]] = alloca i32
+; OLDPM_MODULE-NEXT:    store i32 1, i32* [[A]], align 4
+; OLDPM_MODULE-NEXT:    [[C:%.*]] = call i32 @test(i32* noalias nocapture nofree nonnull writeonly align 4 dereferenceable(4) [[A]])
+; OLDPM_MODULE-NEXT:    ret i32 undef
+;
+; OLDPM_CGSCC-LABEL: define {{[^@]+}}@caller()
+; OLDPM_CGSCC-NEXT:    [[A:%.*]] = alloca i32
+; OLDPM_CGSCC-NEXT:    store i32 1, i32* [[A]], align 4
+; OLDPM_CGSCC-NEXT:    [[C:%.*]] = call i32 @test(i32* noalias nocapture nofree nonnull writeonly align 4 dereferenceable(4) [[A]])
+; OLDPM_CGSCC-NEXT:    ret i32 0
+;
+; NEWPM_MODULE-LABEL: define {{[^@]+}}@caller()
+; NEWPM_MODULE-NEXT:    [[A:%.*]] = alloca i32
+; NEWPM_MODULE-NEXT:    store i32 1, i32* [[A]], align 4
+; NEWPM_MODULE-NEXT:    [[C:%.*]] = call i32 @test(i32* noalias nocapture nofree nonnull writeonly align 4 dereferenceable(4) [[A]])
+; NEWPM_MODULE-NEXT:    ret i32 undef
+;
+; NEWPM_CGSCC-LABEL: define {{[^@]+}}@caller()
+; NEWPM_CGSCC-NEXT:    [[A:%.*]] = alloca i32
+; NEWPM_CGSCC-NEXT:    store i32 1, i32* [[A]], align 4
+; NEWPM_CGSCC-NEXT:    [[C:%.*]] = call i32 @test(i32* noalias nocapture nofree nonnull writeonly align 4 dereferenceable(4) [[A]])
+; NEWPM_CGSCC-NEXT:    ret i32 0
 ;
   %A = alloca i32
   store i32 1, i32* %A

diff  --git a/llvm/test/Transforms/Attributor/IPConstantProp/arg-count-mismatch.ll b/llvm/test/Transforms/Attributor/IPConstantProp/arg-count-mismatch.ll
index cd8a9b4baa66..0716960b3854 100644
--- a/llvm/test/Transforms/Attributor/IPConstantProp/arg-count-mismatch.ll
+++ b/llvm/test/Transforms/Attributor/IPConstantProp/arg-count-mismatch.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
-; RUN: opt -S -passes=attributor -aa-pipeline='basic-aa' -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=3 < %s | FileCheck %s
+; RUN: opt -S -passes=attributor -aa-pipeline='basic-aa' -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=1 < %s | FileCheck %s
 
 ; The original C source looked like this:
 ;
@@ -56,9 +56,8 @@ define internal i16 @bar(i16 %p1, i16 %p2) {
 define dso_local i16 @vararg_tests(i16 %a) {
 ; CHECK-LABEL: define {{[^@]+}}@vararg_tests
 ; CHECK-SAME: (i16 [[A:%.*]])
-; CHECK-NEXT:    [[CALL1:%.*]] = call i16 (i16, ...) @vararg_prop(i16 7, i16 8, i16 [[A]])
 ; CHECK-NEXT:    [[CALL2:%.*]] = call i16 bitcast (i16 (i16, i16, ...)* @vararg_no_prop to i16 (i16)*)(i16 7)
-; CHECK-NEXT:    [[ADD:%.*]] = add i16 [[CALL1]], [[CALL2]]
+; CHECK-NEXT:    [[ADD:%.*]] = add i16 7, [[CALL2]]
 ; CHECK-NEXT:    ret i16 [[ADD]]
 ;
   %call1 = call i16 (i16, ...) @vararg_prop(i16 7, i16 8, i16 %a)
@@ -68,10 +67,6 @@ define dso_local i16 @vararg_tests(i16 %a) {
 }
 
 define internal i16 @vararg_prop(i16 %p1, ...) {
-; CHECK-LABEL: define {{[^@]+}}@vararg_prop
-; CHECK-SAME: (i16 returned [[P1:%.*]], ...)
-; CHECK-NEXT:    ret i16 7
-;
   ret i16 %p1
 }
 

diff  --git a/llvm/test/Transforms/Attributor/IPConstantProp/openmp_parallel_for.ll b/llvm/test/Transforms/Attributor/IPConstantProp/openmp_parallel_for.ll
index 8785eff4ba6d..7c51808deb9c 100644
--- a/llvm/test/Transforms/Attributor/IPConstantProp/openmp_parallel_for.ll
+++ b/llvm/test/Transforms/Attributor/IPConstantProp/openmp_parallel_for.ll
@@ -33,7 +33,7 @@ define dso_local void @foo(i32 %N) {
 ; CHECK-NEXT:    store i32 [[N]], i32* [[N_ADDR]], align 4
 ; CHECK-NEXT:    store float 3.000000e+00, float* [[P]], align 4
 ; CHECK-NEXT:    store i32 7, i32* [[N_ADDR]], align 4
-; CHECK-NEXT:    call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull align 8 dereferenceable(24) @1, i32 3, void (i32*, i32*, ...)* nonnull bitcast (void (i32*, i32*, i32*, float*, i64)* @.omp_outlined. to void (i32*, i32*, ...)*), i32* noalias nocapture nonnull readonly align 4 dereferenceable(4) [[N_ADDR]], float* noalias nocapture nonnull readonly align 4 dereferenceable(4) [[P]], i64 4617315517961601024)
+; CHECK-NEXT:    call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull align 8 dereferenceable(24) @1, i32 3, void (i32*, i32*, ...)* nonnull bitcast (void (i32*, i32*, i32*, float*, i64)* @.omp_outlined. to void (i32*, i32*, ...)*), i32* noalias nocapture nonnull readonly align 4 dereferenceable(4) [[N_ADDR]], float* noalias nocapture nonnull readonly align 4 dereferenceable(4) [[P]], i64 undef)
 ; CHECK-NEXT:    ret void
 ;
 entry:

diff  --git a/llvm/test/Transforms/Attributor/IPConstantProp/remove-call-inst.ll b/llvm/test/Transforms/Attributor/IPConstantProp/remove-call-inst.ll
index 339a9fc4b767..9420f53980cb 100644
--- a/llvm/test/Transforms/Attributor/IPConstantProp/remove-call-inst.ll
+++ b/llvm/test/Transforms/Attributor/IPConstantProp/remove-call-inst.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
-; RUN: opt -S -passes=attributor -aa-pipeline='basic-aa' -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=2 < %s | FileCheck %s
+; RUN: opt -S -passes=attributor -aa-pipeline='basic-aa' -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=1 < %s | FileCheck %s
 ; PR5596
 
 ; IPSCCP should propagate the 0 argument, eliminate the switch, and propagate

diff  --git a/llvm/test/Transforms/Attributor/IPConstantProp/return-constant.ll b/llvm/test/Transforms/Attributor/IPConstantProp/return-constant.ll
index cfbef759d41c..1810b07e7549 100644
--- a/llvm/test/Transforms/Attributor/IPConstantProp/return-constant.ll
+++ b/llvm/test/Transforms/Attributor/IPConstantProp/return-constant.ll
@@ -28,9 +28,9 @@ define internal i32 @foo(i1 %C) {
 ; CHECK-SAME: (i1 [[C:%.*]])
 ; CHECK-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
 ; CHECK:       T:
-; CHECK-NEXT:    ret i32 52
+; CHECK-NEXT:    ret i32 undef
 ; CHECK:       F:
-; CHECK-NEXT:    ret i32 52
+; CHECK-NEXT:    ret i32 undef
 ;
   br i1 %C, label %T, label %F
 

diff  --git a/llvm/test/Transforms/Attributor/IPConstantProp/solve-after-each-resolving-undefs-for-function.ll b/llvm/test/Transforms/Attributor/IPConstantProp/solve-after-each-resolving-undefs-for-function.ll
index ba3f9f929cd5..b5663c9c8c13 100644
--- a/llvm/test/Transforms/Attributor/IPConstantProp/solve-after-each-resolving-undefs-for-function.ll
+++ b/llvm/test/Transforms/Attributor/IPConstantProp/solve-after-each-resolving-undefs-for-function.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
-; RUN: opt -S -passes=attributor -aa-pipeline='basic-aa' -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=2 < %s | FileCheck %s
+; RUN: opt -S -passes=attributor -aa-pipeline='basic-aa' -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=1 < %s | FileCheck %s
 
 define internal i32 @testf(i1 %c) {
 entry:

diff  --git a/llvm/test/Transforms/Attributor/callbacks.ll b/llvm/test/Transforms/Attributor/callbacks.ll
index 5e3ac0741b1a..62df702b6800 100644
--- a/llvm/test/Transforms/Attributor/callbacks.ll
+++ b/llvm/test/Transforms/Attributor/callbacks.ll
@@ -24,7 +24,7 @@ define void @t0_caller(i32* %a) {
 ; CHECK-NEXT:    [[TMP0:%.*]] = bitcast i32* [[B]] to i8*
 ; CHECK-NEXT:    store i32 42, i32* [[B]], align 32
 ; CHECK-NEXT:    store i32* [[B]], i32** [[C]], align 64
-; CHECK-NEXT:    call void (i32*, i32*, void (i32*, i32*, ...)*, ...) @t0_callback_broker(i32* noalias align 536870912 null, i32* nonnull align 128 dereferenceable(4) [[PTR]], void (i32*, i32*, ...)* nonnull bitcast (void (i32*, i32*, i32*, i64, i32**)* @t0_callback_callee to void (i32*, i32*, ...)*), i32* align 256 [[A]], i64 99, i32** noalias nocapture nonnull readonly align 64 dereferenceable(8) [[C]])
+; CHECK-NEXT:    call void (i32*, i32*, void (i32*, i32*, ...)*, ...) @t0_callback_broker(i32* noalias align 536870912 null, i32* nonnull align 128 dereferenceable(4) [[PTR]], void (i32*, i32*, ...)* nonnull bitcast (void (i32*, i32*, i32*, i64, i32**)* @t0_callback_callee to void (i32*, i32*, ...)*), i32* align 256 [[A]], i64 undef, i32** noalias nocapture nonnull readonly align 64 dereferenceable(8) [[C]])
 ; CHECK-NEXT:    ret void
 ;
 
@@ -78,7 +78,7 @@ define void @t1_caller(i32* noalias %a) {
 ; CHECK-NEXT:    [[TMP0:%.*]] = bitcast i32* [[B]] to i8*
 ; CHECK-NEXT:    store i32 42, i32* [[B]], align 32
 ; CHECK-NEXT:    store i32* [[B]], i32** [[C]], align 64
-; CHECK-NEXT:    call void (i32*, i32*, void (i32*, i32*, ...)*, ...) @t1_callback_broker(i32* noalias align 536870912 null, i32* noalias nonnull align 128 dereferenceable(4) [[PTR]], void (i32*, i32*, ...)* nonnull bitcast (void (i32*, i32*, i32*, i64, i32**)* @t1_callback_callee to void (i32*, i32*, ...)*), i32* noalias nocapture align 256 [[A]], i64 99, i32** noalias nocapture nonnull readonly align 64 dereferenceable(8) [[C]])
+; CHECK-NEXT:    call void (i32*, i32*, void (i32*, i32*, ...)*, ...) @t1_callback_broker(i32* noalias align 536870912 null, i32* noalias nonnull align 128 dereferenceable(4) [[PTR]], void (i32*, i32*, ...)* nonnull bitcast (void (i32*, i32*, i32*, i64, i32**)* @t1_callback_callee to void (i32*, i32*, ...)*), i32* noalias nocapture align 256 [[A]], i64 undef, i32** noalias nocapture nonnull readonly align 64 dereferenceable(8) [[C]])
 ; CHECK-NEXT:    ret void
 ;
 entry:
@@ -130,7 +130,7 @@ define void @t2_caller(i32* noalias %a) {
 ; CHECK-NEXT:    [[TMP0:%.*]] = bitcast i32* [[B]] to i8*
 ; CHECK-NEXT:    store i32 42, i32* [[B]], align 32
 ; CHECK-NEXT:    store i32* [[B]], i32** [[C]], align 64
-; CHECK-NEXT:    call void (i32*, i32*, void (i32*, i32*, ...)*, ...) @t2_callback_broker(i32* noalias align 536870912 null, i32* noalias nonnull align 128 dereferenceable(4) [[PTR]], void (i32*, i32*, ...)* nonnull bitcast (void (i32*, i32*, i32*, i64, i32**)* @t2_callback_callee to void (i32*, i32*, ...)*), i32* noalias nocapture align 256 [[A]], i64 99, i32** noalias nocapture nonnull readonly align 64 dereferenceable(8) [[C]])
+; CHECK-NEXT:    call void (i32*, i32*, void (i32*, i32*, ...)*, ...) @t2_callback_broker(i32* noalias align 536870912 null, i32* noalias nonnull align 128 dereferenceable(4) [[PTR]], void (i32*, i32*, ...)* nonnull bitcast (void (i32*, i32*, i32*, i64, i32**)* @t2_callback_callee to void (i32*, i32*, ...)*), i32* noalias nocapture align 256 [[A]], i64 undef, i32** noalias nocapture nonnull readonly align 64 dereferenceable(8) [[C]])
 ; CHECK-NEXT:    ret void
 ;
 entry:

diff  --git a/llvm/test/Transforms/Attributor/liveness.ll b/llvm/test/Transforms/Attributor/liveness.ll
index cbd5484e9797..cc9fbf4b499b 100644
--- a/llvm/test/Transforms/Attributor/liveness.ll
+++ b/llvm/test/Transforms/Attributor/liveness.ll
@@ -1094,18 +1094,30 @@ define void @useless_arg_ext_int_ext(i32* %a) {
 ; FIXME: We should fold terminators.
 
 define internal i32 @switch_default(i64 %i) nounwind {
-; CHECK-LABEL: define {{[^@]+}}@switch_default
-; CHECK-SAME: (i64 [[I:%.*]])
-; CHECK-NEXT:  entry:
-; CHECK-NEXT:    switch i64 0, label [[SW_DEFAULT:%.*]] [
-; CHECK-NEXT:    i64 3, label [[RETURN:%.*]]
-; CHECK-NEXT:    i64 10, label [[RETURN]]
-; CHECK-NEXT:    ]
-; CHECK:       sw.default:
-; CHECK-NEXT:    call void @sink()
-; CHECK-NEXT:    ret i32 123
-; CHECK:       return:
-; CHECK-NEXT:    unreachable
+; MODULE-LABEL: define {{[^@]+}}@switch_default()
+; MODULE-NEXT:  entry:
+; MODULE-NEXT:    switch i64 0, label [[SW_DEFAULT:%.*]] [
+; MODULE-NEXT:    i64 3, label [[RETURN:%.*]]
+; MODULE-NEXT:    i64 10, label [[RETURN]]
+; MODULE-NEXT:    ]
+; MODULE:       sw.default:
+; MODULE-NEXT:    call void @sink()
+; MODULE-NEXT:    ret i32 undef
+; MODULE:       return:
+; MODULE-NEXT:    unreachable
+;
+; CGSCC-LABEL: define {{[^@]+}}@switch_default
+; CGSCC-SAME: (i64 [[I:%.*]])
+; CGSCC-NEXT:  entry:
+; CGSCC-NEXT:    switch i64 0, label [[SW_DEFAULT:%.*]] [
+; CGSCC-NEXT:    i64 3, label [[RETURN:%.*]]
+; CGSCC-NEXT:    i64 10, label [[RETURN]]
+; CGSCC-NEXT:    ]
+; CGSCC:       sw.default:
+; CGSCC-NEXT:    call void @sink()
+; CGSCC-NEXT:    ret i32 123
+; CGSCC:       return:
+; CGSCC-NEXT:    unreachable
 ;
 entry:
   switch i64 %i, label %sw.default [
@@ -1122,6 +1134,10 @@ return:
 }
 
 define i32 @switch_default_caller() {
+; MODULE-LABEL: define {{[^@]+}}@switch_default_caller()
+; MODULE-NEXT:    [[CALL2:%.*]] = tail call i32 @switch_default()
+; MODULE-NEXT:    ret i32 123
+;
 ; CGSCC-LABEL: define {{[^@]+}}@switch_default_caller()
 ; CGSCC-NEXT:    [[CALL2:%.*]] = tail call i32 @switch_default(i64 0)
 ; CGSCC-NEXT:    ret i32 123

diff  --git a/llvm/test/Transforms/Attributor/nonnull.ll b/llvm/test/Transforms/Attributor/nonnull.ll
index fbbf0388b323..39bc63a6358e 100644
--- a/llvm/test/Transforms/Attributor/nonnull.ll
+++ b/llvm/test/Transforms/Attributor/nonnull.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=5 -S < %s | FileCheck %s --check-prefixes=ATTRIBUTOR,ATTRIBUTOR_OPM
+; RUN: opt -attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=4 -S < %s | FileCheck %s --check-prefixes=ATTRIBUTOR,ATTRIBUTOR_OPM
 ; RUN: opt -passes=attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=5 -S < %s | FileCheck %s --check-prefixes=ATTRIBUTOR,ATTRIBUTOR_NPM
 ; Copied from Transforms/FunctoinAttrs/nonnull.ll
 

diff  --git a/llvm/test/Transforms/Attributor/value-simplify.ll b/llvm/test/Transforms/Attributor/value-simplify.ll
index dff06e5262a4..464c3b499aad 100644
--- a/llvm/test/Transforms/Attributor/value-simplify.ll
+++ b/llvm/test/Transforms/Attributor/value-simplify.ll
@@ -136,14 +136,6 @@ f:
 }
 
 define internal i1 @ipccp2i(i1 %a) {
-; CHECK-LABEL: define {{[^@]+}}@ipccp2i
-; CHECK-SAME: (i1 returned [[A:%.*]])
-; CHECK-NEXT:    br label %t
-; CHECK:       t:
-; CHECK-NEXT:    ret i1 true
-; CHECK:       f:
-; CHECK-NEXT:    unreachable
-;
   br i1 %a, label %t, label %f
 t:
   ret i1 %a
@@ -153,23 +145,31 @@ f:
 }
 
 define i1 @ipccp2() {
-; CHECK-LABEL: define {{[^@]+}}@ipccp2()
-; CHECK-NEXT:    [[R:%.*]] = call i1 @ipccp2i(i1 true)
-; CHECK-NEXT:    ret i1 [[R]]
+; CHECK-LABEL: define {{[^@]+}}@ipccp2() #1
+; CHECK-NEXT:    ret i1 true
 ;
   %r = call i1 @ipccp2i(i1 true)
   ret i1 %r
 }
 
-define internal i32 @ipccp3i(i32 %a) {
-; CHECK-LABEL: define {{[^@]+}}@ipccp3i
-; CHECK-SAME: (i32 returned [[A:%.*]])
-; CHECK-NEXT:    br label [[T:%.*]]
-; CHECK:       t:
-; CHECK-NEXT:    ret i32 7
-; CHECK:       f:
-; CHECK-NEXT:    unreachable
+define internal i1 @ipccp2ib(i1 %a) {
+  br i1 %a, label %t, label %f
+t:
+  ret i1 true
+f:
+  %r = call i1 @ipccp2ib(i1 false)
+  ret i1 %r
+}
+
+define i1 @ipccp2b() {
+; CHECK-LABEL: define {{[^@]+}}@ipccp2b() #1
+; CHECK-NEXT:    ret i1 true
 ;
+  %r = call i1 @ipccp2ib(i1 true)
+  ret i1 %r
+}
+
+define internal i32 @ipccp3i(i32 %a) {
   %c = icmp eq i32 %a, 7
   br i1 %c, label %t, label %f
 t:
@@ -181,9 +181,7 @@ f:
 
 define i32 @ipccp3() {
 ; CHECK-LABEL: define {{[^@]+}}@ipccp3()
-; CHECK-NEXT:    [[R:%.*]] = call i32 @ipccp3i(i32 7)
-; CHECK-NEXT:    ret i32 [[R]]
-; FIXME: R should be replaced with 7
+; CHECK-NEXT:    ret i32 7
   %r = call i32 @ipccp3i(i32 7)
   ret i32 %r
 }


        


More information about the llvm-commits mailing list