From 89112b608f50e2944619b320bd04d31bbd57b370 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 2 Nov 2009 03:25:55 +0000 Subject: [PATCH] only IPSCCP incoming arguments if the function is executable, this fixes an assertion on the buildbot. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85784 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/SCCP.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 016d018d73b..5e360d96a59 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -1713,21 +1713,23 @@ bool IPSCCP::runOnModule(Module &M) { SmallVector BlocksToErase; for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) { - for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); - AI != E; ++AI) { - if (AI->use_empty()) continue; - - LatticeVal IV = Solver.getLatticeValueFor(AI); - if (IV.isOverdefined()) continue; - - Constant *CST = IV.isConstant() ? - IV.getConstant() : UndefValue::get(AI->getType()); - DEBUG(errs() << "*** Arg " << *AI << " = " << *CST <<"\n"); - - // Replaces all of the uses of a variable with uses of the - // constant. - AI->replaceAllUsesWith(CST); - ++IPNumArgsElimed; + if (Solver.isBlockExecutable(F->begin())) { + for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); + AI != E; ++AI) { + if (AI->use_empty()) continue; + + LatticeVal IV = Solver.getLatticeValueFor(AI); + if (IV.isOverdefined()) continue; + + Constant *CST = IV.isConstant() ? + IV.getConstant() : UndefValue::get(AI->getType()); + DEBUG(errs() << "*** Arg " << *AI << " = " << *CST <<"\n"); + + // Replaces all of the uses of a variable with uses of the + // constant. + AI->replaceAllUsesWith(CST); + ++IPNumArgsElimed; + } } for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {