llvm.org GIT mirror llvm / cdf5ffb
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 Duncan Sands 10 years ago
2 changed file(s) with 21 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
8181 I != E; ++I) {
8282 Changed |= RemoveUnusedGlobalValue(*I);
8383 // Externally visible aliases are needed.
84 if (!I->hasInternalLinkage() && !I->hasLinkOnceLinkage())
84 if (!I->hasLocalLinkage() && !I->hasLinkOnceLinkage())
8585 GlobalIsNeeded(I);
8686 }
8787
106106 I->deleteBody();
107107 }
108108
109 // The third pass drops targets of aliases which are dead...
110 std::vector DeadAliases;
111 for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end(); I != E;
112 ++I)
113 if (!AliveGlobals.count(I)) {
114 DeadAliases.push_back(I);
115 I->setAliasee(0);
116 }
117
109118 if (!DeadFunctions.empty()) {
110119 // Now that all interferences have been dropped, delete the actual objects
111120 // themselves.
127136 }
128137
129138 // Now delete any dead aliases.
130 for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end(); I != E;) {
131 Module::alias_iterator J = I++;
132 if (!AliveGlobals.count(J)) {
133 RemoveUnusedGlobalValue(*J);
134 M.getAliasList().erase(J);
135 ++NumAliases;
136 Changed = true;
137 }
139 if (!DeadAliases.empty()) {
140 for (unsigned i = 0, e = DeadAliases.size(); i != e; ++i) {
141 RemoveUnusedGlobalValue(*DeadAliases[i]);
142 M.getAliasList().erase(DeadAliases[i]);
143 }
144 NumAliases += DeadAliases.size();
145 Changed = true;
138146 }
139147
140148 // Make sure that all memory is released
0 ; RUN: llvm-as < %s | opt -globaldce
1
2 @A = alias internal void ()* @F
3 define internal void @F() { ret void }