From: Dale Johannesen Date: Fri, 13 Mar 2009 22:59:47 +0000 (+0000) Subject: Fix -strip-debug-declare to work when there are X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=4425240dbcb6e0da24f4a9f72cfb24f529f5b7af;p=oota-llvm.git Fix -strip-debug-declare to work when there are llvm.global.variable's but no llvm.declare's. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66977 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/IPO/StripSymbols.cpp b/lib/Transforms/IPO/StripSymbols.cpp index ee6fbd3cba1..77579d7bfa0 100644 --- a/lib/Transforms/IPO/StripSymbols.cpp +++ b/lib/Transforms/IPO/StripSymbols.cpp @@ -368,29 +368,27 @@ bool StripNonDebugSymbols::runOnModule(Module &M) { bool StripDebugDeclare::runOnModule(Module &M) { Function *Declare = M.getFunction("llvm.dbg.declare"); - - if (!Declare) - return false; - std::vector DeadConstants; - while (!Declare->use_empty()) { - CallInst *CI = cast(Declare->use_back()); - Value *Arg1 = CI->getOperand(1); - Value *Arg2 = CI->getOperand(2); - assert(CI->use_empty() && "llvm.dbg intrinsic should have void result"); - CI->eraseFromParent(); - if (Arg1->use_empty()) { - if (Constant *C = dyn_cast(Arg1)) - DeadConstants.push_back(C); - else - RecursivelyDeleteTriviallyDeadInstructions(Arg1, NULL); + if (Declare) { + while (!Declare->use_empty()) { + CallInst *CI = cast(Declare->use_back()); + Value *Arg1 = CI->getOperand(1); + Value *Arg2 = CI->getOperand(2); + assert(CI->use_empty() && "llvm.dbg intrinsic should have void result"); + CI->eraseFromParent(); + if (Arg1->use_empty()) { + if (Constant *C = dyn_cast(Arg1)) + DeadConstants.push_back(C); + else + RecursivelyDeleteTriviallyDeadInstructions(Arg1, NULL); + } + if (Arg2->use_empty()) + if (Constant *C = dyn_cast(Arg2)) + DeadConstants.push_back(C); } - if (Arg2->use_empty()) - if (Constant *C = dyn_cast(Arg2)) - DeadConstants.push_back(C); + Declare->eraseFromParent(); } - Declare->eraseFromParent(); // Delete all llvm.dbg.global_variables. for (Module::global_iterator I = M.global_begin(), E = M.global_end();