diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-06 22:44:30 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-06 22:44:30 +0000 |
commit | 26668d093e4668a28f377c521c280454dc1b35ab (patch) | |
tree | 9cdb92f6c54e4648a1e0c8d6682e7791c7d2b5c4 | |
parent | 8abb75bc6173c82a3153fd358735219b3355b539 (diff) | |
download | llvm-26668d093e4668a28f377c521c280454dc1b35ab.tar.gz llvm-26668d093e4668a28f377c521c280454dc1b35ab.tar.bz2 llvm-26668d093e4668a28f377c521c280454dc1b35ab.tar.xz |
Special case aliases in GlobalValue::getSection.
This is similar to the getAlignment patch, but is done just for
completeness. It looks like we never call getSection on an alias. All the
tests still pass if the if is replaced with an assert.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208139 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/IR/GlobalValue.h | 4 | ||||
-rw-r--r-- | lib/IR/Globals.cpp | 6 | ||||
-rw-r--r-- | lib/IR/Verifier.cpp | 1 |
3 files changed, 8 insertions, 3 deletions
diff --git a/include/llvm/IR/GlobalValue.h b/include/llvm/IR/GlobalValue.h index 5d0e3791e8..31cd31d741 100644 --- a/include/llvm/IR/GlobalValue.h +++ b/include/llvm/IR/GlobalValue.h @@ -106,8 +106,8 @@ public: } void setDLLStorageClass(DLLStorageClassTypes C) { DllStorageClass = C; } - bool hasSection() const { return !Section.empty(); } - const std::string &getSection() const { return Section; } + bool hasSection() const { return !getSection().empty(); } + const std::string &getSection() const; void setSection(StringRef S); /// getType - Global values are always pointers. diff --git a/lib/IR/Globals.cpp b/lib/IR/Globals.cpp index 2265e4c2b7..f97602015f 100644 --- a/lib/IR/Globals.cpp +++ b/lib/IR/Globals.cpp @@ -80,6 +80,12 @@ void GlobalValue::setAlignment(unsigned Align) { assert(getAlignment() == Align && "Alignment representation error!"); } +const std::string &GlobalValue::getSection() const { + if (auto *GA = dyn_cast<GlobalAlias>(this)) + return GA->getAliasedGlobal()->getSection(); + return Section; +} + void GlobalValue::setSection(StringRef S) { assert(!isa<GlobalAlias>(this) && "GlobalAlias should not have a section!"); Section = S; diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index bc378aed16..083f7b5255 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -476,7 +476,6 @@ void Verifier::visitGlobalAlias(const GlobalAlias &GA) { Assert1(GA.getType() == GA.getAliasee()->getType(), "Alias and aliasee types should match!", &GA); Assert1(!GA.hasUnnamedAddr(), "Alias cannot have unnamed_addr!", &GA); - Assert1(!GA.hasSection(), "Alias cannot have a section!", &GA); const Constant *Aliasee = GA.getAliasee(); const GlobalValue *GV = dyn_cast<GlobalValue>(Aliasee); |