From: Peter Collingbourne Date: Tue, 28 Mar 2017 22:31:35 +0000 (+0000) Subject: LTO: Replace InputFile::Symbol::getFlags() with predicate accessors. NFC. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aba00eee42201f8027be89ac5191f53f6fb5fef2;p=llvm 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298951 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/LTO/LTO.h b/include/llvm/LTO/LTO.h index f7debe062c5..57b220fe733 100644 --- a/include/llvm/LTO/LTO.h +++ b/include/llvm/LTO/LTO.h @@ -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(); diff --git a/lib/LTO/LTO.cpp b/lib/LTO/LTO.cpp index f5e80041130..de02de9d614 100644 --- a/lib/LTO/LTO.cpp +++ b/lib/LTO/LTO.cpp @@ -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()]; diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 719c5db050a..52d352f4bc7 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -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;