[PATCH] Bug 20788 - bugpoint does not respect the "Alias must point to a definition"
Nick Johnson
Nicholas.Paul.Johnson at deshawresearch.com
Wed May 6 10:07:12 PDT 2015
LLVM style guidelines
http://reviews.llvm.org/D9529
Files:
tools/bugpoint/ExtractFunction.cpp
Index: tools/bugpoint/ExtractFunction.cpp
===================================================================
--- tools/bugpoint/ExtractFunction.cpp
+++ tools/bugpoint/ExtractFunction.cpp
@@ -184,6 +184,26 @@
// blocks, making it external.
//
void llvm::DeleteFunctionBody(Function *F) {
+ // First, check whether a GlobalAlias references this definition.
+ // GlobalAlias MAY NOT reference declarations.
+ for (;;) {
+ // 1. Find aliases
+ SmallVector<GlobalAlias*,1> aliases;
+ Module *M = F->getParent();
+ for (Module::alias_iterator I=M->alias_begin(), E=M->alias_end(); I!=E; ++I)
+ if (I->getAliasee() == F)
+ aliases.push_back(&*I);
+ if (aliases.empty())
+ break;
+ // 2. Resolve aliases
+ for (unsigned i=0, e=aliases.size(); i<e; ++i) {
+ aliases[i]->replaceAllUsesWith(aliases[i]->getAliasee());
+ aliases[i]->eraseFromParent();
+ }
+ // 3. Repeat until no more aliases found; there might
+ // be an alias to an alias...
+ }
+
// delete the body of the function...
F->deleteBody();
assert(F->isDeclaration() && "This didn't make the function external!");
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9529.25062.patch
Type: text/x-patch
Size: 1140 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150506/e3797b41/attachment.bin>
More information about the llvm-commits
mailing list