diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-11-26 19:22:59 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-11-26 19:22:59 +0000 |
| commit | 8934577171b967cc23186c2ffa0a0c4b54a8d992 (patch) | |
| tree | 71cf3a68625564d956029ae1d8dbd91c62f24077 /llvm/lib/Transforms | |
| parent | ff2f14731a19f36127c1e7302530b322698e3918 (diff) | |
| download | bcm5719-llvm-8934577171b967cc23186c2ffa0a0c4b54a8d992.tar.gz bcm5719-llvm-8934577171b967cc23186c2ffa0a0c4b54a8d992.zip | |
Disallow aliases to available_externally.
They are as much trouble as aliases to declarations. They are requiring
the code generator to define a symbol with the same value as another
symbol, but the second symbol is undefined.
If representing this is important for some optimization, we could add
support for available_externally aliases. They would be *required* to
point to a declaration (or available_externally definition).
llvm-svn: 254170
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/IPO/ElimAvailExtern.cpp | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/llvm/lib/Transforms/IPO/ElimAvailExtern.cpp b/llvm/lib/Transforms/IPO/ElimAvailExtern.cpp index 0e138cbbc7a..af313a6b001 100644 --- a/llvm/lib/Transforms/IPO/ElimAvailExtern.cpp +++ b/llvm/lib/Transforms/IPO/ElimAvailExtern.cpp @@ -49,46 +49,9 @@ ModulePass *llvm::createEliminateAvailableExternallyPass() { return new EliminateAvailableExternally(); } -static void convertAliasToDeclaration(GlobalAlias &GA, Module &M) { - GlobalValue *GVal = GA.getBaseObject(); - GlobalValue *NewGV; - if (auto *GVar = dyn_cast<GlobalVariable>(GVal)) { - GlobalVariable *NewGVar = new GlobalVariable( - M, GVar->getType()->getElementType(), GVar->isConstant(), - GVar->getLinkage(), /*init*/ nullptr, GA.getName(), GVar, - GVar->getThreadLocalMode(), GVar->getType()->getAddressSpace()); - NewGV = NewGVar; - NewGV->copyAttributesFrom(GVar); - } else { - auto *F = dyn_cast<Function>(GVal); - assert(F); - Function *NewF = Function::Create(F->getFunctionType(), F->getLinkage(), - GA.getName(), &M); - NewGV = NewF; - NewGV->copyAttributesFrom(F); - } - GA.replaceAllUsesWith(ConstantExpr::getBitCast(NewGV, GA.getType())); - GA.eraseFromParent(); -} - bool EliminateAvailableExternally::runOnModule(Module &M) { bool Changed = false; - // Convert any aliases that alias with an available externally - // value (which will be turned into declarations later on in this routine) - // into declarations themselves. All aliases must be definitions, and - // must alias with a definition. So this involves creating a declaration - // equivalent to the alias's base object. - for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end(); I != E;) { - // Increment the iterator first since we may delete the current alias. - GlobalAlias &GA = *(I++); - GlobalValue *GVal = GA.getBaseObject(); - if (!GVal->hasAvailableExternallyLinkage()) - continue; - convertAliasToDeclaration(GA, M); - Changed = true; - } - // Drop initializers of available externally global variables. for (GlobalVariable &GV : M.globals()) { if (!GV.hasAvailableExternallyLinkage()) |

