[llvm] r258654 - [SCCP] Remove duplicate code
NAKAMURA Takumi via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 24 06:30:10 PST 2016
It crashes LTO.
http://bb.pgr.jp/builders/clang-3stage-x86_64-linux/builds/9251
A reduced testcase attached. Reproducible with "opt -ipsccp".
On Sun, Jan 24, 2016 at 3:30 PM David Majnemer via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: majnemer
> Date: Sun Jan 24 00:26:47 2016
> New Revision: 258654
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258654&view=rev
> Log:
> [SCCP] Remove duplicate code
>
> SCCP has code identical to changeToUnreachable's behavior, switch it
> over to just call changeToUnreachable.
>
> No functionality change intended.
>
> Modified:
> llvm/trunk/include/llvm/Transforms/Utils/Local.h
> llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
> llvm/trunk/lib/Transforms/Utils/Local.cpp
>
> Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=258654&r1=258653&r2=258654&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original)
> +++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Sun Jan 24 00:26:47
> 2016
> @@ -295,7 +295,7 @@ unsigned removeAllNonTerminatorAndEHPadI
>
> /// \brief Insert an unreachable instruction before the specified
> /// instruction, making it and the rest of the code in the block dead.
> -void changeToUnreachable(Instruction *I, bool UseLLVMTrap);
> +unsigned changeToUnreachable(Instruction *I, bool UseLLVMTrap);
>
> /// Replace 'BB's terminator with one that does not have an unwind
> successor
> /// block. Rewrites `invoke` to `call`, etc. Updates any PHIs in unwind
>
> Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=258654&r1=258653&r2=258654&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Sun Jan 24 00:26:47 2016
> @@ -1564,14 +1564,6 @@ FunctionPass *llvm::createSCCPPass() {
> return new SCCP();
> }
>
> -static void DeleteInstructionInBlock(BasicBlock *BB) {
> - DEBUG(dbgs() << " BasicBlock Dead:" << *BB);
> - ++NumDeadBlocks;
> -
> - unsigned NumRemovedInBB =
> removeAllNonTerminatorAndEHPadInstructions(BB);
> - NumInstRemoved += NumRemovedInBB;
> -}
> -
> // runOnFunction() - Run the Sparse Conditional Constant Propagation
> algorithm,
> // and return true if the function was modified.
> //
> @@ -1608,7 +1600,11 @@ bool SCCP::runOnFunction(Function &F) {
>
> for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
> if (!Solver.isBlockExecutable(&*BB)) {
> - DeleteInstructionInBlock(&*BB);
> + DEBUG(dbgs() << " BasicBlock Dead:" << *BB);
> +
> + ++NumDeadBlocks;
> + NumInstRemoved += removeAllNonTerminatorAndEHPadInstructions(BB);
> +
> MadeChanges = true;
> continue;
> }
> @@ -1806,18 +1802,13 @@ bool IPSCCP::runOnModule(Module &M) {
>
> for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
> {
> if (!Solver.isBlockExecutable(&*BB)) {
> - DeleteInstructionInBlock(&*BB);
> - MadeChanges = true;
> + DEBUG(dbgs() << " BasicBlock Dead:" << *BB);
>
> - TerminatorInst *TI = BB->getTerminator();
> - for (BasicBlock *Succ : TI->successors()) {
> - if (!Succ->empty() && isa<PHINode>(Succ->begin()))
> - Succ->removePredecessor(&*BB);
> - }
> - if (!TI->use_empty())
> - TI->replaceAllUsesWith(UndefValue::get(TI->getType()));
> - TI->eraseFromParent();
> - new UnreachableInst(M.getContext(), &*BB);
> + ++NumDeadBlocks;
> + NumInstRemoved +=
> + changeToUnreachable(&*BB->begin(), /*UseLLVMTrap=*/false);
> +
> + MadeChanges = true;
>
> if (&*BB != &F->front())
> BlocksToErase.push_back(&*BB);
>
> Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=258654&r1=258653&r2=258654&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Sun Jan 24 00:26:47 2016
> @@ -1243,7 +1243,7 @@ unsigned llvm::removeAllNonTerminatorAnd
> return NumDeadInst;
> }
>
> -void llvm::changeToUnreachable(Instruction *I, bool UseLLVMTrap) {
> +unsigned llvm::changeToUnreachable(Instruction *I, bool UseLLVMTrap) {
> BasicBlock *BB = I->getParent();
> // Loop over all of the successors, removing BB's entry from any PHI
> // nodes.
> @@ -1261,12 +1261,15 @@ void llvm::changeToUnreachable(Instructi
> new UnreachableInst(I->getContext(), I);
>
> // All instructions after this are dead.
> + unsigned NumInstrsRemoved = 0;
> BasicBlock::iterator BBI = I->getIterator(), BBE = BB->end();
> while (BBI != BBE) {
> if (!BBI->use_empty())
> BBI->replaceAllUsesWith(UndefValue::get(BBI->getType()));
> BB->getInstList().erase(BBI++);
> + ++NumInstrsRemoved;
> }
> + return NumInstrsRemoved;
> }
>
> /// changeToCall - Convert the specified invoke into a normal call.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160124/3d25e1f6/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bugpoint-reduced-simplified.ll
Type: application/octet-stream
Size: 1520 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160124/3d25e1f6/attachment-0001.obj>
More information about the llvm-commits
mailing list