mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-04 05:31:51 +00:00
If an alias is dead and so is its aliasee, then globaldce would
crash because the alias would still be using the aliasee when the aliasee was deleted. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64844 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0d90e5d08b
commit
cdf5ffb7fb
@ -82,7 +82,7 @@ bool GlobalDCE::runOnModule(Module &M) {
|
|||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
Changed |= RemoveUnusedGlobalValue(*I);
|
Changed |= RemoveUnusedGlobalValue(*I);
|
||||||
// Externally visible aliases are needed.
|
// Externally visible aliases are needed.
|
||||||
if (!I->hasInternalLinkage() && !I->hasLinkOnceLinkage())
|
if (!I->hasLocalLinkage() && !I->hasLinkOnceLinkage())
|
||||||
GlobalIsNeeded(I);
|
GlobalIsNeeded(I);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,6 +107,15 @@ bool GlobalDCE::runOnModule(Module &M) {
|
|||||||
I->deleteBody();
|
I->deleteBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The third pass drops targets of aliases which are dead...
|
||||||
|
std::vector<GlobalAlias*> DeadAliases;
|
||||||
|
for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end(); I != E;
|
||||||
|
++I)
|
||||||
|
if (!AliveGlobals.count(I)) {
|
||||||
|
DeadAliases.push_back(I);
|
||||||
|
I->setAliasee(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (!DeadFunctions.empty()) {
|
if (!DeadFunctions.empty()) {
|
||||||
// Now that all interferences have been dropped, delete the actual objects
|
// Now that all interferences have been dropped, delete the actual objects
|
||||||
// themselves.
|
// themselves.
|
||||||
@ -128,14 +137,13 @@ bool GlobalDCE::runOnModule(Module &M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now delete any dead aliases.
|
// Now delete any dead aliases.
|
||||||
for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end(); I != E;) {
|
if (!DeadAliases.empty()) {
|
||||||
Module::alias_iterator J = I++;
|
for (unsigned i = 0, e = DeadAliases.size(); i != e; ++i) {
|
||||||
if (!AliveGlobals.count(J)) {
|
RemoveUnusedGlobalValue(*DeadAliases[i]);
|
||||||
RemoveUnusedGlobalValue(*J);
|
M.getAliasList().erase(DeadAliases[i]);
|
||||||
M.getAliasList().erase(J);
|
|
||||||
++NumAliases;
|
|
||||||
Changed = true;
|
|
||||||
}
|
}
|
||||||
|
NumAliases += DeadAliases.size();
|
||||||
|
Changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that all memory is released
|
// Make sure that all memory is released
|
||||||
|
4
test/Transforms/GlobalDCE/2009-02-17-AliasUsesAliasee.ll
Normal file
4
test/Transforms/GlobalDCE/2009-02-17-AliasUsesAliasee.ll
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
; RUN: llvm-as < %s | opt -globaldce
|
||||||
|
|
||||||
|
@A = alias internal void ()* @F
|
||||||
|
define internal void @F() { ret void }
|
Loading…
x
Reference in New Issue
Block a user