mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-04 16:01:46 +00:00
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
This commit is contained in:
parent
fc0b80d974
commit
4425240dbc
@ -368,29 +368,27 @@ bool StripNonDebugSymbols::runOnModule(Module &M) {
|
|||||||
bool StripDebugDeclare::runOnModule(Module &M) {
|
bool StripDebugDeclare::runOnModule(Module &M) {
|
||||||
|
|
||||||
Function *Declare = M.getFunction("llvm.dbg.declare");
|
Function *Declare = M.getFunction("llvm.dbg.declare");
|
||||||
|
|
||||||
if (!Declare)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
std::vector<Constant*> DeadConstants;
|
std::vector<Constant*> DeadConstants;
|
||||||
|
|
||||||
while (!Declare->use_empty()) {
|
if (Declare) {
|
||||||
CallInst *CI = cast<CallInst>(Declare->use_back());
|
while (!Declare->use_empty()) {
|
||||||
Value *Arg1 = CI->getOperand(1);
|
CallInst *CI = cast<CallInst>(Declare->use_back());
|
||||||
Value *Arg2 = CI->getOperand(2);
|
Value *Arg1 = CI->getOperand(1);
|
||||||
assert(CI->use_empty() && "llvm.dbg intrinsic should have void result");
|
Value *Arg2 = CI->getOperand(2);
|
||||||
CI->eraseFromParent();
|
assert(CI->use_empty() && "llvm.dbg intrinsic should have void result");
|
||||||
if (Arg1->use_empty()) {
|
CI->eraseFromParent();
|
||||||
if (Constant *C = dyn_cast<Constant>(Arg1))
|
if (Arg1->use_empty()) {
|
||||||
DeadConstants.push_back(C);
|
if (Constant *C = dyn_cast<Constant>(Arg1))
|
||||||
else
|
DeadConstants.push_back(C);
|
||||||
RecursivelyDeleteTriviallyDeadInstructions(Arg1, NULL);
|
else
|
||||||
|
RecursivelyDeleteTriviallyDeadInstructions(Arg1, NULL);
|
||||||
|
}
|
||||||
|
if (Arg2->use_empty())
|
||||||
|
if (Constant *C = dyn_cast<Constant>(Arg2))
|
||||||
|
DeadConstants.push_back(C);
|
||||||
}
|
}
|
||||||
if (Arg2->use_empty())
|
Declare->eraseFromParent();
|
||||||
if (Constant *C = dyn_cast<Constant>(Arg2))
|
|
||||||
DeadConstants.push_back(C);
|
|
||||||
}
|
}
|
||||||
Declare->eraseFromParent();
|
|
||||||
|
|
||||||
// Delete all llvm.dbg.global_variables.
|
// Delete all llvm.dbg.global_variables.
|
||||||
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
|
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
|
||||||
|
Loading…
Reference in New Issue
Block a user