[llvm] 262c679 - Revert "[SimplifyCFG] Sinking indirect calls - they're already indirect anyways"

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 28 07:50:12 PDT 2021


Author: Roman Lebedev
Date: 2021-04-28T17:46:59+03:00
New Revision: 262c679d329b0805dbb055bd62e5abe41824c0ad

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

LOG: Revert "[SimplifyCFG] Sinking indirect calls - they're already indirect anyways"

Seems to break indirect call promotion, LTO/Resolution/X86/load-sample-prof-icp.ll fails.

This reverts commit e57cf128b30a88c6dd42e8ef40deeedd0d7f116d.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    llvm/test/Transforms/SimplifyCFG/X86/sink-common-code.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 207aacbad93e..16e69c0b0d0e 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1748,10 +1748,11 @@ static bool canSinkInstructions(
           !canReplaceOperandWithVariable(I0, OI))
         // We can't create a PHI from this GEP.
         return false;
-      // Don't *create* indirect calls! The called value is the final operand.
-      auto *CB = dyn_cast<CallBase>(I0);
-      if (CB && OI == OE - 1 && !CB->isIndirectCall())
+      // Don't create indirect calls! The called value is the final operand.
+      if (isa<CallBase>(I0) && OI == OE - 1) {
+        // FIXME: if the call was *already* indirect, we should do this.
         return false;
+      }
       for (auto *I : Insts)
         PHIOperands[I].push_back(I->getOperand(OI));
     }

diff  --git a/llvm/test/Transforms/SimplifyCFG/X86/sink-common-code.ll b/llvm/test/Transforms/SimplifyCFG/X86/sink-common-code.ll
index 24f11b85bec5..917d1ab89eea 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/sink-common-code.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/sink-common-code.ll
@@ -1383,9 +1383,14 @@ if.end:
 
 define void @indirect_caller(i1 %c, i32 %v, void (i32)* %foo, void (i32)* %bar) {
 ; CHECK-LABEL: @indirect_caller(
-; CHECK-NEXT:  end:
-; CHECK-NEXT:    [[BAR_SINK:%.*]] = select i1 [[C:%.*]], void (i32)* [[FOO:%.*]], void (i32)* [[BAR:%.*]]
-; CHECK-NEXT:    tail call void [[BAR_SINK]](i32 [[V:%.*]])
+; CHECK-NEXT:    br i1 [[C:%.*]], label [[CALL_FOO:%.*]], label [[CALL_BAR:%.*]]
+; CHECK:       call_foo:
+; CHECK-NEXT:    tail call void [[FOO:%.*]](i32 [[V:%.*]])
+; CHECK-NEXT:    br label [[END:%.*]]
+; CHECK:       call_bar:
+; CHECK-NEXT:    tail call void [[BAR:%.*]](i32 [[V]])
+; CHECK-NEXT:    br label [[END]]
+; CHECK:       end:
 ; CHECK-NEXT:    ret void
 ;
   br i1 %c, label %call_foo, label %call_bar


        


More information about the llvm-commits mailing list