Repository navigation
[IPO] Declare LTO command line options in TableGen - #245301
Conversation
Port the FunctionImport, FunctionAttrs and WholeProgramDevirt options that the ThinLTO thin link reads from the combined index. LTO passes its context's options, ThinLTOCodeGenerator its LibraryOptions. runWholeProgramDevirtOnIndex replaces its nullable LLVMContext parameter, for which ThinLTOCodeGenerator passed null. Renames without an alias, as an inverting alias rejects the `=0` every user passes: ``` -disable-thinlto-funcattrs -> -thinlto-funcattrs ```
|
@llvm/pr-subscribers-lto @llvm/pr-subscribers-llvm-transforms Author: Fangrui Song (MaskRay) ChangesPort the FunctionImport, FunctionAttrs and WholeProgramDevirt options Renames without an alias, as an inverting alias rejects the Patch is 81.66 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/245301.diff 24 Files Affected:
diff --git a/clang/test/CodeGen/distributed-thin-lto/cfi-devirt.ll b/clang/test/CodeGen/distributed-thin-lto/cfi-devirt.ll
index 14938cbaa465bf..9d52c70928e2cf 100644
--- a/clang/test/CodeGen/distributed-thin-lto/cfi-devirt.ll
+++ b/clang/test/CodeGen/distributed-thin-lto/cfi-devirt.ll
@@ -6,7 +6,7 @@
; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t.o %s
-; RUN: llvm-lto2 run -thinlto-distributed-indexes -disable-thinlto-funcattrs=0 %t.o \
+; RUN: llvm-lto2 run -thinlto-distributed-indexes -thinlto-funcattrs %t.o \
; RUN: -whole-program-visibility \
; RUN: -o %t2.index \
; RUN: -r=%t.o,test,px \
diff --git a/clang/test/CodeGen/distributed-thin-lto/cfi.ll b/clang/test/CodeGen/distributed-thin-lto/cfi.ll
index 585602d43c79d7..70680344237b60 100644
--- a/clang/test/CodeGen/distributed-thin-lto/cfi.ll
+++ b/clang/test/CodeGen/distributed-thin-lto/cfi.ll
@@ -4,7 +4,7 @@
; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t.o %s
-; RUN: llvm-lto2 run -thinlto-distributed-indexes -disable-thinlto-funcattrs=0 %t.o \
+; RUN: llvm-lto2 run -thinlto-distributed-indexes -thinlto-funcattrs %t.o \
; RUN: -o %t2.index \
; RUN: -r=%t.o,test,px \
; RUN: -r=%t.o,_ZTV1B, \
diff --git a/clang/test/CodeGen/thinlto-funcattr-prop.ll b/clang/test/CodeGen/thinlto-funcattr-prop.ll
index e5f39ddd58a4fe..2c71e18f569575 100644
--- a/clang/test/CodeGen/thinlto-funcattr-prop.ll
+++ b/clang/test/CodeGen/thinlto-funcattr-prop.ll
@@ -6,7 +6,7 @@
; RUN: opt -module-summary %t/a.ll -o %t/a.bc
; RUN: opt -module-summary %t/b.ll -o %t/b.bc
-; RUN: llvm-lto2 run -disable-thinlto-funcattrs=0 %t/a.bc %t/b.bc -o %t1.o -save-temps \
+; RUN: llvm-lto2 run -thinlto-funcattrs %t/a.bc %t/b.bc -o %t1.o -save-temps \
; RUN: -r=%t/a.bc,call_extern,plx \
; RUN: -r=%t/a.bc,extern, \
; RUN: -r=%t/b.bc,extern,p
diff --git a/llvm/include/llvm/LTO/LTO.h b/llvm/include/llvm/LTO/LTO.h
index 29c13e0fdbdcc1..3719242ca33431 100644
--- a/llvm/include/llvm/LTO/LTO.h
+++ b/llvm/include/llvm/LTO/LTO.h
@@ -52,7 +52,8 @@ class ToolOutputFile;
/// This is done for correctness (if value exported, ensure we always
/// emit a copy), and compile-time optimization (allow drop of duplicates).
LLVM_ABI void thinLTOResolvePrevailingInIndex(
- const lto::Config &C, ModuleSummaryIndex &Index,
+ const cl::LibraryOptionsContext &LibraryOptions, const lto::Config &C,
+ ModuleSummaryIndex &Index,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
isPrevailing,
function_ref<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)>
diff --git a/llvm/include/llvm/Transforms/IPO/FunctionAttrs.h b/llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
index f01e890e0f6fba..8af5fb24d5462f 100644
--- a/llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
+++ b/llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
@@ -27,6 +27,9 @@ class GlobalValueSummary;
class ModuleSummaryIndex;
class Function;
class Module;
+namespace cl {
+class LibraryOptionsContext;
+}
/// Returns the memory access properties of this copy of the function.
LLVM_ABI MemoryEffects computeFunctionBodyMemoryAccess(Function &F,
@@ -35,7 +38,7 @@ LLVM_ABI MemoryEffects computeFunctionBodyMemoryAccess(Function &F,
/// Propagate function attributes for function summaries along the index's
/// callgraph during thinlink
LLVM_ABI bool thinLTOPropagateFunctionAttrs(
- ModuleSummaryIndex &Index,
+ const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
isPrevailing);
diff --git a/llvm/include/llvm/Transforms/IPO/FunctionImport.h b/llvm/include/llvm/Transforms/IPO/FunctionImport.h
index f3d0360944eeef..4d7310c9cdad3d 100644
--- a/llvm/include/llvm/Transforms/IPO/FunctionImport.h
+++ b/llvm/include/llvm/Transforms/IPO/FunctionImport.h
@@ -25,6 +25,9 @@
namespace llvm {
class Module;
+namespace cl {
+class LibraryOptionsContext;
+}
/// The function importer is automatically importing function from other modules
/// based on the provided summary informations.
@@ -318,6 +321,8 @@ class FunctionImporter {
LLVM_ABI Expected<bool> importFunctions(Module &M,
const ImportMapTy &ImportList);
+ LLVM_ABI static bool forceImportAll(const cl::LibraryOptionsContext &C);
+
private:
/// The summaries index used to trigger importing.
const ModuleSummaryIndex &Index;
@@ -358,6 +363,7 @@ class FunctionImportPass : public OptionalPassInfoMixin<FunctionImportPass> {
/// are made from (the module path for each summary is owned by the index's
/// module path string table).
LLVM_ABI void ComputeCrossModuleImport(
+ const cl::LibraryOptionsContext &LibraryOptions,
const ModuleSummaryIndex &Index,
const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
@@ -384,14 +390,14 @@ LLVM_ABI void updateIndirectCalls(ModuleSummaryIndex &Index);
/// Also update call edges for indirect calls to local functions added from
/// SamplePGO when needed.
LLVM_ABI void computeDeadSymbolsAndUpdateIndirectCalls(
- ModuleSummaryIndex &Index,
+ const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index,
const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols,
function_ref<PrevailingType(GlobalValue::GUID)> isPrevailing);
/// Compute dead symbols and run constant propagation in combined index
/// after that.
LLVM_ABI void computeDeadSymbolsWithConstProp(
- ModuleSummaryIndex &Index,
+ const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index,
const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols,
function_ref<PrevailingType(GlobalValue::GUID)> isPrevailing,
bool ImportEnabled);
diff --git a/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h b/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
index 67c5d783a187ba..fece0f101b145b 100644
--- a/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
+++ b/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
@@ -33,6 +33,9 @@ template <typename T> class MutableArrayRef;
class GlobalVariable;
class ModuleSummaryIndex;
struct ValueInfo;
+namespace cl {
+class LibraryOptionsContext;
+}
namespace wholeprogramdevirt {
@@ -245,7 +248,8 @@ struct VTableSlotSummary {
uint64_t ByteOffset;
};
LLVM_ABI bool
-hasWholeProgramVisibility(bool WholeProgramVisibilityEnabledInLTO);
+hasWholeProgramVisibility(const cl::LibraryOptionsContext &LibraryOptions,
+ bool WholeProgramVisibilityEnabledInLTO);
/// Convert llvm.public.type.test calls to llvm.type.test when whole program
/// visibility is available, or otherwise drop them unless speculative
/// devirtualization is enabled, in which case WPD still needs them to identify
@@ -263,7 +267,8 @@ LLVM_ABI void updateVCallVisibilityInModule(
bool ValidateAllVtablesHaveTypeInfos,
function_ref<bool(StringRef)> IsVisibleToRegularObj);
LLVM_ABI void updateVCallVisibilityInIndex(
- ModuleSummaryIndex &Index, bool WholeProgramVisibilityEnabledInLTO,
+ const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index,
+ bool WholeProgramVisibilityEnabledInLTO,
const DenseSet<GlobalValue::GUID> &DynamicExportSymbols,
const DenseSet<GlobalValue::GUID> &VisibleToRegularObjSymbols);
@@ -280,10 +285,10 @@ LLVM_ABI void getVisibleToRegularObjVtableGUIDs(
/// in case it is exported by cross module importing (in which case the
/// devirtualized target name will need adjustment).
LLVM_ABI void runWholeProgramDevirtOnIndex(
+ const cl::LibraryOptionsContext &LibraryOptions,
ModuleSummaryIndex &Summary, std::set<GlobalValue::GUID> &ExportedGUIDs,
std::map<ValueInfo, std::vector<VTableSlotSummary>> &LocalWPDTargetsMap,
- DenseSet<StringRef> *ExternallyVisibleSymbolNamesPtr,
- const LLVMContext *Ctx);
+ DenseSet<StringRef> *ExternallyVisibleSymbolNamesPtr);
/// Call after cross-module importing to update the recorded single impl
/// devirt target names for any locals that were exported.
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index c340da78cf891d..596e3d6c40e561 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -109,7 +109,6 @@ static cl::opt<bool>
DumpThinCGSCCs("dump-thin-cg-sccs", cl::init(false), cl::Hidden,
cl::desc("Dump the SCCs in the ThinLTO index's callgraph"));
namespace llvm {
-extern cl::opt<bool> ForceImportAll;
extern cl::opt<bool> AlwaysRenamePromotedLocals;
} // end namespace llvm
@@ -404,7 +403,7 @@ std::string llvm::recomputeLTOCacheKey(const std::string &Key,
}
static void thinLTOResolvePrevailingGUID(
- const Config &C, ValueInfo VI,
+ const Config &C, bool ForceImportAll, ValueInfo VI,
DenseSet<GlobalValueSummary *> &GlobalInvolvedWithAlias,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
isPrevailing,
@@ -490,7 +489,8 @@ static void thinLTOResolvePrevailingGUID(
// referencing them because of the import. We make sure we always emit at least
// one copy.
void llvm::thinLTOResolvePrevailingInIndex(
- const Config &C, ModuleSummaryIndex &Index,
+ const cl::LibraryOptionsContext &LibraryOptions, const Config &C,
+ ModuleSummaryIndex &Index,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
isPrevailing,
function_ref<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)>
@@ -505,8 +505,9 @@ void llvm::thinLTOResolvePrevailingInIndex(
if (auto AS = dyn_cast<AliasSummary>(S.get()))
GlobalInvolvedWithAlias.insert(&AS->getAliasee());
+ bool ForceImportAll = FunctionImporter::forceImportAll(LibraryOptions);
for (auto &I : Index)
- thinLTOResolvePrevailingGUID(C, Index.getValueInfo(I),
+ thinLTOResolvePrevailingGUID(C, ForceImportAll, Index.getValueInfo(I),
GlobalInvolvedWithAlias, isPrevailing,
recordNewLinkage, GUIDPreservedSymbols);
}
@@ -1379,7 +1380,8 @@ Error LTO::run(AddStreamFn AddStream, FileCache Cache) {
return PrevailingType::Unknown;
return It->second;
};
- computeDeadSymbolsWithConstProp(ThinLTO.CombinedIndex, GUIDPreservedSymbols,
+ computeDeadSymbolsWithConstProp(RegularLTO.Ctx.getLibraryOptions(),
+ ThinLTO.CombinedIndex, GUIDPreservedSymbols,
isPrevailing, Conf.OptLevel > 0);
// Setup output file to emit statistics.
@@ -2139,6 +2141,8 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
if (DumpThinCGSCCs)
ThinLTO.CombinedIndex.dumpSCCs(outs());
+ const cl::LibraryOptionsContext &LibraryOptions =
+ RegularLTO.Ctx.getLibraryOptions();
std::set<GlobalValue::GUID> ExportedGUIDs;
bool WholeProgramVisibilityEnabledInLTO =
@@ -2146,7 +2150,8 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
// If validation is enabled, upgrade visibility only when all vtables
// have typeinfos.
(!Conf.ValidateAllVtablesHaveTypeInfos || Conf.AllVtablesHaveTypeInfos);
- if (hasWholeProgramVisibility(WholeProgramVisibilityEnabledInLTO))
+ if (hasWholeProgramVisibility(LibraryOptions,
+ WholeProgramVisibilityEnabledInLTO))
ThinLTO.CombinedIndex.setWithWholeProgramVisibility();
// If we're validating, get the vtable symbols that should not be
@@ -2171,7 +2176,7 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
// If allowed, upgrade public vcall visibility to linkage unit visibility in
// the summaries before whole program devirtualization below.
updateVCallVisibilityInIndex(
- ThinLTO.CombinedIndex, WholeProgramVisibilityEnabledInLTO,
+ LibraryOptions, ThinLTO.CombinedIndex, WholeProgramVisibilityEnabledInLTO,
DynamicExportSymbols, VisibleToRegularObjSymbols);
// Perform index-based WPD. This will return immediately if there are
@@ -2188,9 +2193,9 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
(WholeProgramVisibilityEnabledInLTO && !AlwaysRenamePromotedLocals)
? &ExternallyVisibleSymbolNames
: nullptr;
- runWholeProgramDevirtOnIndex(
- ThinLTO.CombinedIndex, ExportedGUIDs, LocalWPDTargetsMap,
- ExternallyVisibleSymbolNamesPtr, &RegularLTO.Ctx);
+ runWholeProgramDevirtOnIndex(LibraryOptions, ThinLTO.CombinedIndex,
+ ExportedGUIDs, LocalWPDTargetsMap,
+ ExternallyVisibleSymbolNamesPtr);
auto isPrevailing = [&](GlobalValue::GUID GUID, const GlobalValueSummary *S) {
return ThinLTO.isPrevailingModuleForGUID(GUID, S->modulePath());
@@ -2230,8 +2235,9 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
releaseGlobalResolutionsMemory();
if (Conf.OptLevel > 0)
- ComputeCrossModuleImport(ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries,
- isPrevailing, ImportLists, ExportLists);
+ ComputeCrossModuleImport(LibraryOptions, ThinLTO.CombinedIndex,
+ ModuleToDefinedGVSummaries, isPrevailing,
+ ImportLists, ExportLists);
// Any functions referenced by the jump table in the regular LTO object must
// be exported.
@@ -2277,10 +2283,12 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
GlobalValue::LinkageTypes NewLinkage) {
ResolvedODR[ModuleIdentifier][GUID] = NewLinkage;
};
- thinLTOResolvePrevailingInIndex(Conf, ThinLTO.CombinedIndex, isPrevailing,
- recordNewLinkage, GUIDPreservedSymbols);
+ thinLTOResolvePrevailingInIndex(LibraryOptions, Conf, ThinLTO.CombinedIndex,
+ isPrevailing, recordNewLinkage,
+ GUIDPreservedSymbols);
- thinLTOPropagateFunctionAttrs(ThinLTO.CombinedIndex, isPrevailing);
+ thinLTOPropagateFunctionAttrs(LibraryOptions, ThinLTO.CombinedIndex,
+ isPrevailing);
generateParamAccessSummary(Conf.LibraryOptions, ThinLTO.CombinedIndex);
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index 14a76f8806d08f..34e5ec682a1b8a 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -527,7 +527,7 @@ ProcessThinLTOModule(Module &TheModule, ModuleSummaryIndex &Index,
/// at least one copy kept) and a compile-time optimization (to drop duplicate
/// copies when possible).
static void resolvePrevailingInIndex(
- ModuleSummaryIndex &Index,
+ const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index,
StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>>
&ResolvedODR,
const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols,
@@ -550,8 +550,8 @@ static void resolvePrevailingInIndex(
// TODO Conf.VisibilityScheme can be lto::Config::ELF for ELF.
lto::Config Conf;
- thinLTOResolvePrevailingInIndex(Conf, Index, isPrevailing, recordNewLinkage,
- GUIDPreservedSymbols);
+ thinLTOResolvePrevailingInIndex(LibraryOptions, Conf, Index, isPrevailing,
+ recordNewLinkage, GUIDPreservedSymbols);
}
// Initialize the TargetMachine builder for a given Triple
@@ -677,7 +677,7 @@ struct IsPrevailing {
} // namespace
static void computeDeadSymbolsInIndex(
- ModuleSummaryIndex &Index,
+ const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index,
const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) {
// We have no symbols resolution available. And can't do any better now in the
// case where the prevailing symbol is in a native object. It can be refined
@@ -685,8 +685,8 @@ static void computeDeadSymbolsInIndex(
auto isPrevailing = [&](GlobalValue::GUID G) {
return PrevailingType::Unknown;
};
- computeDeadSymbolsWithConstProp(Index, GUIDPreservedSymbols, isPrevailing,
- /* ImportEnabled = */ true);
+ computeDeadSymbolsWithConstProp(LibraryOptions, Index, GUIDPreservedSymbols,
+ isPrevailing, /* ImportEnabled = */ true);
}
/**
@@ -710,7 +710,7 @@ void ThinLTOCodeGenerator::promote(Module &TheModule, ModuleSummaryIndex &Index,
addUsedSymbolToPreservedGUID(File, GUIDPreservedSymbols);
// Compute "dead" symbols, we don't want to import/export these!
- computeDeadSymbolsInIndex(Index, GUIDPreservedSymbols);
+ computeDeadSymbolsInIndex(LibraryOptions, Index, GUIDPreservedSymbols);
// Compute prevailing symbols
DenseMap<GlobalValue::GUID, const GlobalValueSummary *> PrevailingCopy;
@@ -719,14 +719,14 @@ void ThinLTOCodeGenerator::promote(Module &TheModule, ModuleSummaryIndex &Index,
// Generate import/export list
FunctionImporter::ImportListsTy ImportLists(ModuleCount);
DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
- ComputeCrossModuleImport(Index, ModuleToDefinedGVSummaries,
+ ComputeCrossModuleImport(LibraryOptions, Index, ModuleToDefinedGVSummaries,
IsPrevailing(PrevailingCopy), ImportLists,
ExportLists);
// Resolve prevailing symbols
StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>> ResolvedODR;
- resolvePrevailingInIndex(Index, ResolvedODR, GUIDPreservedSymbols,
- PrevailingCopy);
+ resolvePrevailingInIndex(LibraryOptions, Index, ResolvedODR,
+ GUIDPreservedSymbols, PrevailingCopy);
thinLTOFinalizeInModule(TheModule,
ModuleToDefinedGVSummaries[ModuleIdentifier],
@@ -762,7 +762,7 @@ void ThinLTOCodeGenerator::crossModuleImport(Module &TheModule,
addUsedSymbolToPreservedGUID(File, GUIDPreservedSymbols);
// Compute "dead" symbols, we don't want to import/export these!
- computeDeadSymbolsInIndex(Index, GUIDPreservedSymbols);
+ computeDeadSymbolsInIndex(LibraryOptions, Index, GUIDPreservedSymbols);
// Compute prevailing symbols
DenseMap<GlobalValue::GUID, const GlobalValueSummary *> PrevailingCopy;
@@ -771,7 +771,7 @@ void ThinLTOCodeGenerator::crossModuleImport(Module &TheModule,
// Generate import/export list
FunctionImporter::ImportListsTy ImportLists(ModuleCount);
DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
- ComputeCrossModuleImport(Index, ModuleToDefinedGVSummaries,
+ ComputeCrossModuleImport(LibraryOptions, Index, ModuleToDefinedGVSummaries,
IsPrevailing(PrevailingCopy), ImportLists,
ExportLists);
auto &ImportList = ImportLists[TheModule.getModuleIdentifier()];
@@ -802,7 +802,7 @@ void ThinLTOCodeGenerator::gatherImportedSummariesForModule(
addUsedSymbolToPreservedGUID(File, GUIDPreservedSymbols);
// Compute "dead" symbols, we don't want to import/export these!
- computeDeadSymbolsInIndex(Index, GUIDPreservedSymbols);
+ computeDeadSymbolsInIndex(LibraryOptions, Index, GUIDPreservedSymbols);
// Compute prevailing symbols
DenseMap<GlobalValue::GUID, const GlobalValueSummary *> PrevailingCopy;
@@ -811,7 +811,7 @@ void ThinLTOCodeGenerator::gatherImportedSummariesForModule(
// Generate import/export list
FunctionImporter::ImportListsTy ImportLists(ModuleCount);
DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
- ComputeCrossModuleImport(Index, ModuleToDefinedGVSummaries,
+ ComputeCrossModuleImport(LibraryOptions, Index, ModuleToDefinedGVSummaries,
IsPrevailing(PrevailingCopy), ImportLists,
ExportLists);
@@ -840,7 +840,7 @@ void ThinLTOCodeGenerator::emitImports(Module &TheModule, StringRef OutputName,
addUsedSymbolToPreservedGUID(File, GUIDPreservedSymbols);
// Compute "dead" symbols, we don't want to import/export these!
- computeDeadSymbolsInIndex(Index, GUIDPreservedSymbols);
+ computeDeadSymbolsInIndex(LibraryOptions, Index, GUIDPreservedSymbols);
// Compute prevailing symbols
DenseMap<GlobalValue::GUID, const GlobalValueSummary *> PrevailingCopy;
@@ -849,7 +849,7 @@ void ThinLTOCodeGenerator::emitImports(Module &TheModule, StringRef OutputName,
...
[truncated]
|
| "As we import functions called from hot callsite, multiply the `import-instr-limit` threshold by this factor before processing newly imported functions">; | ||
| defm : ValueField<"import-hot-multiplier", "float", "10.0", | ||
| "Multiply the `import-instr-limit` threshold for hot callsites">; | ||
| defm : ValueField<"import-instr-evolution-factor", "float", "0.7", |
There was a problem hiding this comment.
"0.7" initializes a float member with a double literal. This is the pattern #240502 fixed for cold-branch-ratio / min-region-size-ratio ("0.1" -> "0.1f") because MSVC warns about the truncation. Suggest "0.7f", and for consistency with AnalysisOptions.td/CodeGenOptions.td, "0.0f", "100.0f", "1.0f", "10.0f" for the other four float fields.
There was a problem hiding this comment.
Thanks for catching this! Fixed
| "Number of functions marked as nounwind during thinlink"); | ||
|
|
||
| static cl::opt<bool> DisableThinLTOPropagation( | ||
| "disable-thinlto-funcattrs", cl::init(true), cl::Hidden, |
There was a problem hiding this comment.
After this patch -disable-thinlto-funcattrs=0 is a hard error. Should we document it in release notes that it is renamed now?
llvm-lto2: Unknown command line argument '-disable-thinlto-funcattrs=0'.
llvm-lto2: Did you mean '--disable-strictnode-mutation=0'?
There was a problem hiding this comment.
No, cl::opt options are internal developer knobs and provide no stability guarantees, so we shouldn't document their addition. Since this option seems to have no OSS usage, I'd remove it directly without adding an alias.
(Note: I do leave aliases for some options -- you can grep // TODO: Remove the old spellings after YYYY-MM for examples.)
| // backends (in particular distributed ThinLTO backends, which do not see the | ||
| // option) so that they apply the speculative resolutions. | ||
| if (Ctx && getIPOOptions(*Ctx).devirtualize_speculatively) | ||
| if (Opts.devirtualize_speculatively) |
There was a problem hiding this comment.
runWholeProgramDevirtOnIndex used to receive Ctx == nullptr from ThinLTOCodeGenerator, so -devirtualize-speculatively was ignored for llvm-lto / libLTO. It is now honored. The description mentions the signature change but not the behavior change. Also, should we add a run line of llvm-lto -thinlto-action=run -devirtualize-speculatively for test coverage?
There was a problem hiding this comment.
Yes, the null context made llvm-lto/libLTO ignore the option. I mentioned the fix in the description and added an llvm-lto -thinlto-action=run -devirtualize-speculatively RUN line to devirt_speculative.ll. It fails without this patch.
…stProp etc. This adapts to llvm/llvm-project#245301
…Prop, r=nikic llvm-wrapper: Pass LibraryOptionsContext to computeDeadSymbolsWithConstProp etc. This adapts to llvm/llvm-project#245301
…Prop, r=nikic llvm-wrapper: Pass LibraryOptionsContext to computeDeadSymbolsWithConstProp etc. This adapts to llvm/llvm-project#245301
When NDEBUG is defined, the entry label may get discarded making it hard to reuse the CHECK prefix that is already available. Add a new one specifically for the new test. Fixes: 7c41857 ([IPO] Declare LTO command line options in TableGen (llvm#245301), 2026-11-25)
…Prop, r=nikic llvm-wrapper: Pass LibraryOptionsContext to computeDeadSymbolsWithConstProp etc. This adapts to llvm/llvm-project#245301
…Prop, r=nikic llvm-wrapper: Pass LibraryOptionsContext to computeDeadSymbolsWithConstProp etc. This adapts to llvm/llvm-project#245301
Rollup merge of #166606 - zmodem:computeDeadSymbolsWithConstProp, r=nikic llvm-wrapper: Pass LibraryOptionsContext to computeDeadSymbolsWithConstProp etc. This adapts to llvm/llvm-project#245301
Port the FunctionImport, FunctionAttrs and WholeProgramDevirt options
that the ThinLTO thin link reads from the combined index.
LTO passes its context's options, ThinLTOCodeGenerator its
LibraryOptions.
runWholeProgramDevirtOnIndex replaces its nullable LLVMContext
parameter, for which ThinLTOCodeGenerator passed null, so llvm-lto and
libLTO now honor -devirtualize-speculatively.
Renames without an alias, as an inverting alias rejects the
=0everyuser passes:
LLM-aided