From 262c679d329b0805dbb055bd62e5abe41824c0ad Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Wed, 28 Apr 2021 17:46:59 +0300 Subject: [PATCH] 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. --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 7 ++++--- llvm/test/Transforms/SimplifyCFG/X86/sink-common-code.ll | 11 ++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 207aacb..16e69c0 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(I0); - if (CB && OI == OE - 1 && !CB->isIndirectCall()) + // Don't create indirect calls! The called value is the final operand. + if (isa(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 24f11b8..917d1ab 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 -- 2.7.4