]> granicus.if.org Git - llvm/commitdiff
LTO: Replace InputFile::Symbol::getFlags() with predicate accessors. NFC.
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 28 Mar 2017 22:31:35 +0000 (22:31 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 28 Mar 2017 22:31:35 +0000 (22:31 +0000)
This makes the predicates independent of the flag representation
and makes the code a little easier to read.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298951 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/LTO/LTO.h
lib/LTO/LTO.cpp
tools/gold/gold-plugin.cpp

index f7debe062c511a0caa735b297af0e7f014ad4ebd..57b220fe733c705f18f4d2e24bcba413ff4fd045 100644 (file)
@@ -152,6 +152,15 @@ public:
       skip();
     }
 
+    bool isUndefined() const {
+      return Flags & object::BasicSymbolRef::SF_Undefined;
+    }
+    bool isCommon() const { return Flags & object::BasicSymbolRef::SF_Common; }
+    bool isWeak() const { return Flags & object::BasicSymbolRef::SF_Weak; }
+    bool isIndirect() const {
+      return Flags & object::BasicSymbolRef::SF_Indirect;
+    }
+
     /// For COFF weak externals, returns the name of the symbol that is used
     /// as a fallback if the weak external remains undefined.
     std::string getCOFFWeakExternalFallback() const {
@@ -171,7 +180,6 @@ public:
     /// Returns the mangled name of the global.
     StringRef getName() const { return Name; }
 
-    uint32_t getFlags() const { return Flags; }
     GlobalValue::VisibilityTypes getVisibility() const {
       if (isGV())
         return getGV()->getVisibility();
index f5e80041130521a7eb0ad3afb045964b1ea917b5..de02de9d6145795eb02d74cf5ad62ef45282f3c7 100644 (file)
@@ -575,7 +575,7 @@ Error LTO::addRegularLTO(BitcodeModule BM, const SymbolResolution *&ResI,
     if (Sym.isGV()) {
       GlobalValue *GV = Sym.getGV();
       if (Res.Prevailing) {
-        if (Sym.getFlags() & object::BasicSymbolRef::SF_Undefined)
+        if (Sym.isUndefined())
           continue;
         Keep.push_back(GV);
         switch (GV->getLinkage()) {
@@ -608,7 +608,7 @@ Error LTO::addRegularLTO(BitcodeModule BM, const SymbolResolution *&ResI,
     // Common resolution: collect the maximum size/alignment over all commons.
     // We also record if we see an instance of a common as prevailing, so that
     // if none is prevailing we can ignore it later.
-    if (Sym.getFlags() & object::BasicSymbolRef::SF_Common) {
+    if (Sym.isCommon()) {
       // FIXME: We should figure out what to do about commons defined by asm.
       // For now they aren't reported correctly by ModuleSymbolTable.
       auto &CommonRes = RegularLTO.Commons[Sym.getGV()->getName()];
index 719c5db050acd0a6e87f7a564ff3b8a69f11352a..52d352f4bc766c671688bb2103ab026053ea232d 100644 (file)
@@ -496,8 +496,6 @@ static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
                sys::path::filename(Obj->getSourceFileName()).str();
 
   for (auto &Sym : Obj->symbols()) {
-    uint32_t Symflags = Sym.getFlags();
-
     cf.syms.push_back(ld_plugin_symbol());
     ld_plugin_symbol &sym = cf.syms.back();
     sym.version = nullptr;
@@ -523,13 +521,13 @@ static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
       break;
     }
 
-    if (Symflags & object::BasicSymbolRef::SF_Undefined) {
+    if (Sym.isUndefined()) {
       sym.def = LDPK_UNDEF;
-      if (Symflags & object::BasicSymbolRef::SF_Weak)
+      if (Sym.isWeak())
         sym.def = LDPK_WEAKUNDEF;
-    } else if (Symflags & object::BasicSymbolRef::SF_Common)
+    } else if (Sym.isCommon())
       sym.def = LDPK_COMMON;
-    else if (Symflags & object::BasicSymbolRef::SF_Weak)
+    else if (Sym.isWeak())
       sym.def = LDPK_WEAKDEF;
     else
       sym.def = LDPK_DEF;