[llvm] r298951 - LTO: Replace InputFile::Symbol::getFlags() with predicate accessors. NFC.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 28 15:31:36 PDT 2017


Author: pcc
Date: Tue Mar 28 17:31:35 2017
New Revision: 298951

URL: http://llvm.org/viewvc/llvm-project?rev=298951&view=rev
Log:
LTO: Replace InputFile::Symbol::getFlags() with predicate accessors. NFC.

This makes the predicates independent of the flag representation
and makes the code a little easier to read.

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

Modified: llvm/trunk/include/llvm/LTO/LTO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LTO/LTO.h?rev=298951&r1=298950&r2=298951&view=diff
==============================================================================
--- llvm/trunk/include/llvm/LTO/LTO.h (original)
+++ llvm/trunk/include/llvm/LTO/LTO.h Tue Mar 28 17:31:35 2017
@@ -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();

Modified: llvm/trunk/lib/LTO/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTO.cpp?rev=298951&r1=298950&r2=298951&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTO.cpp (original)
+++ llvm/trunk/lib/LTO/LTO.cpp Tue Mar 28 17:31:35 2017
@@ -575,7 +575,7 @@ Error LTO::addRegularLTO(BitcodeModule B
     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 B
     // 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()];

Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=298951&r1=298950&r2=298951&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Tue Mar 28 17:31:35 2017
@@ -496,8 +496,6 @@ static ld_plugin_status claim_file_hook(
                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(
       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;




More information about the llvm-commits mailing list