diff options
| author | Anton Korobeynikov <asl@math.spbu.ru> | 2007-04-28 13:45:00 +0000 |
|---|---|---|
| committer | Anton Korobeynikov <asl@math.spbu.ru> | 2007-04-28 13:45:00 +0000 |
| commit | b18f8f85e9151195a81833d6862063323338854e (patch) | |
| tree | 3bbb4f5593defb3935aa086ffccc1edb0f2c606a /llvm/lib/VMCore | |
| parent | 1deacd61f4a93742e3e12bac91026158bdb1aaf0 (diff) | |
| download | bcm5719-llvm-b18f8f85e9151195a81833d6862063323338854e.tar.gz bcm5719-llvm-b18f8f85e9151195a81833d6862063323338854e.zip | |
Implement review feedback. Aliasees can be either GlobalValue's or
bitcasts of them.
llvm-svn: 36537
Diffstat (limited to 'llvm/lib/VMCore')
| -rw-r--r-- | llvm/lib/VMCore/AsmWriter.cpp | 14 | ||||
| -rw-r--r-- | llvm/lib/VMCore/Globals.cpp | 21 | ||||
| -rw-r--r-- | llvm/lib/VMCore/Module.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/VMCore/Verifier.cpp | 4 |
4 files changed, 30 insertions, 12 deletions
diff --git a/llvm/lib/VMCore/AsmWriter.cpp b/llvm/lib/VMCore/AsmWriter.cpp index 8834e1e2a22..656a7bed74e 100644 --- a/llvm/lib/VMCore/AsmWriter.cpp +++ b/llvm/lib/VMCore/AsmWriter.cpp @@ -926,7 +926,7 @@ void AssemblyWriter::printAlias(const GlobalAlias *GA) { assert(0 && "Invalid alias linkage"); } - const GlobalValue *Aliasee = GA->getAliasee(); + const Constant *Aliasee = dyn_cast_or_null<Constant>(GA->getAliasee()); assert(Aliasee && "Aliasee cannot be null"); if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(Aliasee)) { @@ -940,9 +940,15 @@ void AssemblyWriter::printAlias(const GlobalAlias *GA) { Out << getLLVMName(F->getName(), GlobalPrefix); else Out << "@\"\""; - } else - assert(0 && "Unsupported aliasee"); - + } else { + const ConstantExpr *CE = 0; + if ((CE = dyn_cast<ConstantExpr>(Aliasee)) && + (CE->getOpcode() == Instruction::BitCast)) { + writeOperand(CE, false); + } else + assert(0 && "Unsupported aliasee"); + } + printInfoComment(*GA); Out << "\n"; } diff --git a/llvm/lib/VMCore/Globals.cpp b/llvm/lib/VMCore/Globals.cpp index c64b719095d..88a8c0b2a7a 100644 --- a/llvm/lib/VMCore/Globals.cpp +++ b/llvm/lib/VMCore/Globals.cpp @@ -163,12 +163,15 @@ void GlobalVariable::replaceUsesOfWithOnConstant(Value *From, Value *To, //===----------------------------------------------------------------------===// GlobalAlias::GlobalAlias(const Type *Ty, LinkageTypes Link, - const std::string &Name, const GlobalValue* aliasee, + const std::string &Name, Constant* aliasee, Module *ParentModule) - : GlobalValue(Ty, Value::GlobalAliasVal, 0, 0, - Link, Name), Aliasee(aliasee) { + : GlobalValue(Ty, Value::GlobalAliasVal, &Aliasee, 1, Link, Name) { LeakDetector::addGarbageObject(this); + if (aliasee) + assert(aliasee->getType() == Ty && "Alias and aliasee types should match!"); + Aliasee.init(aliasee, this); + if (ParentModule) ParentModule->getAliasList().push_back(this); } @@ -190,12 +193,16 @@ void GlobalAlias::eraseFromParent() { } bool GlobalAlias::isDeclaration() const { - return (Aliasee && Aliasee->isDeclaration()); + const GlobalValue* AV = dyn_cast_or_null<const GlobalValue>(getAliasee()); + return (AV && AV->isDeclaration()); } -void GlobalAlias::setAliasee(const GlobalValue *GV) +void GlobalAlias::setAliasee(Constant *Aliasee) { - // FIXME: Some checks? - Aliasee = GV; + if (Aliasee) { + assert(Aliasee->getType() == getType() && + "Alias and aliasee types should match!"); + setOperand(0, Aliasee); + } } diff --git a/llvm/lib/VMCore/Module.cpp b/llvm/lib/VMCore/Module.cpp index c66032388ba..e20dab30be9 100644 --- a/llvm/lib/VMCore/Module.cpp +++ b/llvm/lib/VMCore/Module.cpp @@ -298,6 +298,9 @@ void Module::dropAllReferences() { for(Module::global_iterator I = global_begin(), E = global_end(); I != E; ++I) I->dropAllReferences(); + + for(Module::alias_iterator I = alias_begin(), E = alias_end(); I != E; ++I) + I->dropAllReferences(); } void Module::addLibrary(const std::string& Lib) { diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp index 1578c2ddd6d..01eb860f911 100644 --- a/llvm/lib/VMCore/Verifier.cpp +++ b/llvm/lib/VMCore/Verifier.cpp @@ -316,7 +316,9 @@ void Verifier::visitGlobalAlias(GlobalAlias &GA) { Assert1(GA.hasExternalLinkage() || GA.hasInternalLinkage() || GA.hasWeakLinkage(), "Alias should have external or external weak linkage!", &GA); - + Assert1(GA.getType() == GA.getAliasee()->getType(), + "Alias and aliasee types should match!", &GA); + visitGlobalValue(GA); } |

