[lld] 7c67592 - [ELF] Merge canInline into scriptDefined
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 5 12:00:39 PST 2022
Author: Fangrui Song
Date: 2022-02-05T12:00:34-08:00
New Revision: 7c675923c739478b33a02af130101f8edea2fb3a
URL: https://github.com/llvm/llvm-project/commit/7c675923c739478b33a02af130101f8edea2fb3a
DIFF: https://github.com/llvm/llvm-project/commit/7c675923c739478b33a02af130101f8edea2fb3a.diff
LOG: [ELF] Merge canInline into scriptDefined
They perform similar tasks and are essentially the same after
d28c26bbdd9e6e55cc0a6156e9879f7e0ca36329.
Added:
Modified:
lld/ELF/Driver.cpp
lld/ELF/LTO.cpp
lld/ELF/SymbolTable.cpp
lld/ELF/Symbols.h
Removed:
################################################################################
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index f32f95200864..090b95944e97 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -2061,8 +2061,8 @@ static std::vector<WrappedSymbol> addWrappedSymbols(opt::InputArgList &args) {
// We want to tell LTO not to inline symbols to be overwritten
// because LTO doesn't know the final symbol contents after renaming.
- real->canInline = false;
- sym->canInline = false;
+ real->scriptDefined = true;
+ sym->scriptDefined = true;
// Tell LTO not to eliminate these symbols.
sym->isUsedInRegularObj = true;
diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp
index e409e86f9c34..f349a5b121bf 100644
--- a/lld/ELF/LTO.cpp
+++ b/lld/ELF/LTO.cpp
@@ -273,7 +273,7 @@ void BitcodeCompiler::add(BitcodeFile &f) {
// We tell LTO to not apply interprocedural optimization for wrapped
// (with --wrap) symbols because otherwise LTO would inline them while
// their values are still not final.
- r.LinkerRedefined = !sym->canInline;
+ r.LinkerRedefined = sym->scriptDefined;
}
checkError(ltoObj->add(std::move(f.obj), resols));
}
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index 90a4ab93868c..36f838a751ab 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -89,7 +89,6 @@ Symbol *SymbolTable::insert(StringRef name) {
sym->isUsedInRegularObj = false;
sym->exportDynamic = false;
sym->inDynamicList = false;
- sym->canInline = true;
sym->referenced = false;
sym->traced = false;
sym->scriptDefined = false;
diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h
index 8333e02bae63..d04454cc8749 100644
--- a/lld/ELF/Symbols.h
+++ b/lld/ELF/Symbols.h
@@ -126,11 +126,6 @@ class Symbol {
// exported into .dynsym.
uint8_t inDynamicList : 1;
- // False if LTO shouldn't inline whatever this symbol points to. If a symbol
- // is overwritten after LTO, LTO shouldn't inline the symbol because it
- // doesn't know the final contents of the symbol.
- uint8_t canInline : 1;
-
// Used to track if there has been at least one undefined reference to the
// symbol. For Undefined and SharedSymbol, the binding may change to STB_WEAK
// if the first undefined reference from a non-shared object is weak.
@@ -246,11 +241,11 @@ class Symbol {
binding(binding), type(type), stOther(stOther), symbolKind(k),
visibility(stOther & 3),
isUsedInRegularObj(!file || file->kind() == InputFile::ObjKind),
- exportDynamic(false), inDynamicList(false), canInline(false),
- referenced(false), traced(false), hasVersionSuffix(false),
- isInIplt(false), gotInIgot(false), isPreemptible(false), used(false),
- folded(false), needsTocRestore(false), scriptDefined(false),
- needsCopy(false), needsGot(false), needsPlt(false), needsTlsDesc(false),
+ exportDynamic(false), inDynamicList(false), referenced(false),
+ traced(false), hasVersionSuffix(false), isInIplt(false),
+ gotInIgot(false), isPreemptible(false), used(false), folded(false),
+ needsTocRestore(false), scriptDefined(false), needsCopy(false),
+ needsGot(false), needsPlt(false), needsTlsDesc(false),
needsTlsGd(false), needsTlsGdToIe(false), needsTlsLd(false),
needsGotDtprel(false), needsTlsIe(false), hasDirectReloc(false) {}
@@ -279,7 +274,10 @@ class Symbol {
// PPC64 toc pointer.
uint8_t needsTocRestore : 1;
- // True if this symbol is defined by a linker script.
+ // True if this symbol is defined by a symbol assignment or wrapped by --wrap.
+ //
+ // LTO shouldn't inline the symbol because it doesn't know the final content
+ // of the symbol.
uint8_t scriptDefined : 1;
// True if this symbol needs a canonical PLT entry, or (during
@@ -588,7 +586,6 @@ void Symbol::replace(const Symbol &newSym) {
isUsedInRegularObj = old.isUsedInRegularObj;
exportDynamic = old.exportDynamic;
inDynamicList = old.inDynamicList;
- canInline = old.canInline;
referenced = old.referenced;
traced = old.traced;
hasVersionSuffix = old.hasVersionSuffix;
More information about the llvm-commits
mailing list