]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - opencl/llvm.git/commitdiff
Special case aliases in GlobalValue::getSection.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 6 May 2014 22:44:30 +0000 (22:44 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 6 May 2014 22:44:30 +0000 (22:44 +0000)
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

include/llvm/IR/GlobalValue.h
lib/IR/Globals.cpp
lib/IR/Verifier.cpp

index 5d0e3791e85f41dc7ceea1943f548f1e7b3ee26c..31cd31d7413ce557d0d83872651064f2fe4d6364 100644 (file)
@@ -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.
index 2265e4c2b72f75669fd98b8cec111367c437215a..f97602015f1437bb20bce85072ba9f286975ecc4 100644 (file)
@@ -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;
index bc378aed16ba77e6055305b4459468232bd76195..083f7b5255e7f79a8ba2eab699a7bdea2adf3ef9 100644 (file)
@@ -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);