[clang] [llvm] [IPO] Declare LTO command line options in TableGen (PR #245301)
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 24 21:58:40 PST 2026
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/245301
>From 40bd0a8186cdbb31de0044d87d95949e9a69fa08 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Thu, 19 Nov 2026 20:38:11 -0800
Subject: [PATCH 1/2] [IPO] Declare LTO command line options in TableGen
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
```
---
.../distributed-thin-lto/cfi-devirt.ll | 2 +-
.../test/CodeGen/distributed-thin-lto/cfi.ll | 2 +-
clang/test/CodeGen/thinlto-funcattr-prop.ll | 2 +-
llvm/include/llvm/LTO/LTO.h | 3 +-
.../llvm/Transforms/IPO/FunctionAttrs.h | 5 +-
.../llvm/Transforms/IPO/FunctionImport.h | 10 +-
.../llvm/Transforms/IPO/WholeProgramDevirt.h | 13 +-
llvm/lib/LTO/LTO.cpp | 38 +--
llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 60 ++---
llvm/lib/Transforms/IPO/FunctionAttrs.cpp | 9 +-
llvm/lib/Transforms/IPO/FunctionImport.cpp | 235 +++++-------------
llvm/lib/Transforms/IPO/IPOOptions.h | 1 +
llvm/lib/Transforms/IPO/IPOOptions.td | 85 +++++++
.../lib/Transforms/IPO/WholeProgramDevirt.cpp | 106 +++-----
llvm/test/ThinLTO/X86/deadstrip.ll | 2 +-
.../X86/funcattrs-prop-exported-internal.ll | 2 +-
.../ThinLTO/X86/funcattrs-prop-maythrow.ll | 2 +-
.../ThinLTO/X86/funcattrs-prop-undefined.ll | 2 +-
.../ThinLTO/X86/funcattrs-prop-unknown.ll | 2 +-
llvm/test/ThinLTO/X86/funcattrs-prop-weak.ll | 4 +-
llvm/test/ThinLTO/X86/funcattrs-prop.ll | 2 +-
.../ThinLTO/X86/funcimport_alwaysinline.ll | 2 +-
.../ThinLTO/X86/linkonce_resolution_comdat.ll | 2 +-
llvm/tools/opt/optdriver.cpp | 3 +-
24 files changed, 278 insertions(+), 316 deletions(-)
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,
// 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);
@@ -890,7 +890,7 @@ void ThinLTOCodeGenerator::internalize(Module &TheModule,
Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
// 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;
@@ -899,7 +899,7 @@ void ThinLTOCodeGenerator::internalize(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 &ExportList = ExportLists[ModuleIdentifier];
@@ -911,8 +911,8 @@ void ThinLTOCodeGenerator::internalize(Module &TheModule,
// Resolve prevailing symbols
StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>> ResolvedODR;
- resolvePrevailingInIndex(Index, ResolvedODR, GUIDPreservedSymbols,
- PrevailingCopy);
+ resolvePrevailingInIndex(LibraryOptions, Index, ResolvedODR,
+ GUIDPreservedSymbols, PrevailingCopy);
// Promote the exported values in the index, so that they are promoted
// in the module.
@@ -1064,16 +1064,17 @@ void ThinLTOCodeGenerator::run() {
addUsedSymbolToPreservedGUID(*M, GUIDPreservedSymbols);
// Compute "dead" symbols, we don't want to import/export these!
- computeDeadSymbolsInIndex(*Index, GUIDPreservedSymbols);
+ computeDeadSymbolsInIndex(LibraryOptions, *Index, GUIDPreservedSymbols);
// Currently there is no support for enabling whole program visibility via a
// linker option in the old LTO API, but this call allows it to be specified
// via the internal option. Must be done before WPD below.
- if (hasWholeProgramVisibility(/* WholeProgramVisibilityEnabledInLTO */ false))
+ if (hasWholeProgramVisibility(LibraryOptions,
+ /* WholeProgramVisibilityEnabledInLTO */ false))
Index->setWithWholeProgramVisibility();
// FIXME: This needs linker information via a TBD new interface
- updateVCallVisibilityInIndex(*Index,
+ updateVCallVisibilityInIndex(LibraryOptions, *Index,
/*WholeProgramVisibilityEnabledInLTO=*/false,
// FIXME: These need linker information via a
// TBD new interface.
@@ -1085,8 +1086,8 @@ void ThinLTOCodeGenerator::run() {
// performing IR-based WPD in hybrid regular/thin LTO mode).
std::map<ValueInfo, std::vector<VTableSlotSummary>> LocalWPDTargetsMap;
std::set<GlobalValue::GUID> ExportedGUIDs;
- runWholeProgramDevirtOnIndex(*Index, ExportedGUIDs, LocalWPDTargetsMap,
- nullptr, nullptr);
+ runWholeProgramDevirtOnIndex(LibraryOptions, *Index, ExportedGUIDs,
+ LocalWPDTargetsMap, nullptr);
GUIDPreservedSymbols.insert_range(ExportedGUIDs);
// Compute prevailing symbols
@@ -1097,7 +1098,7 @@ void ThinLTOCodeGenerator::run() {
// combined index.
FunctionImporter::ImportListsTy ImportLists(ModuleCount);
DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
- ComputeCrossModuleImport(*Index, ModuleToDefinedGVSummaries,
+ ComputeCrossModuleImport(LibraryOptions, *Index, ModuleToDefinedGVSummaries,
IsPrevailing(PrevailingCopy), ImportLists,
ExportLists);
@@ -1109,8 +1110,8 @@ void ThinLTOCodeGenerator::run() {
// Resolve prevailing symbols, this has to be computed early because it
// impacts the caching.
- resolvePrevailingInIndex(*Index, ResolvedODR, GUIDPreservedSymbols,
- PrevailingCopy);
+ resolvePrevailingInIndex(LibraryOptions, *Index, ResolvedODR,
+ GUIDPreservedSymbols, PrevailingCopy);
// Use global summary-based analysis to identify symbols that can be
// internalized (because they aren't exported or preserved as per callback).
@@ -1122,7 +1123,8 @@ void ThinLTOCodeGenerator::run() {
*Index, IsExported(ExportLists, GUIDPreservedSymbols),
IsPrevailing(PrevailingCopy));
- thinLTOPropagateFunctionAttrs(*Index, IsPrevailing(PrevailingCopy));
+ thinLTOPropagateFunctionAttrs(LibraryOptions, *Index,
+ IsPrevailing(PrevailingCopy));
// Make sure that every module has an entry in the ExportLists, ImportList,
// GVSummary and ResolvedODR maps to enable threaded access to these maps
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index 8f5dac7702899d..780fa3257c136e 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -54,7 +54,6 @@
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
-#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
@@ -97,10 +96,6 @@ STATISTIC(NumThinLinkNoRecurse,
STATISTIC(NumThinLinkNoUnwind,
"Number of functions marked as nounwind during thinlink");
-static cl::opt<bool> DisableThinLTOPropagation(
- "disable-thinlto-funcattrs", cl::init(true), cl::Hidden,
- cl::desc("Don't propagate function-attrs in thinLTO"));
-
static void addCapturesStat(CaptureInfo CI) {
if (capturesNothing(CI))
++NumCapturesNone;
@@ -410,12 +405,12 @@ static FunctionSummary *calculatePrevailingSummary(
}
bool llvm::thinLTOPropagateFunctionAttrs(
- ModuleSummaryIndex &Index,
+ const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
IsPrevailing) {
// TODO: implement addNoAliasAttrs once
// there's more information about the return type in the summary
- if (DisableThinLTOPropagation)
+ if (!LibraryOptions.get<IPOOptions>().thinlto_funcattrs)
return false;
DenseMap<ValueInfo, FunctionSummary *> CachedPrevailingSummary;
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index 329fce285f21be..d8e5d0ae23effa 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -86,125 +86,8 @@ STATISTIC(NumLiveSymbols, "Number of live symbols in index");
namespace llvm {
extern cl::opt<bool> AlwaysRenamePromotedLocals;
-cl::opt<bool>
- ForceImportAll("force-import-all", cl::init(false), cl::Hidden,
- cl::desc("Import functions with noinline attribute"));
-
-/// Limit on instruction count of imported functions.
-static cl::opt<unsigned> ImportInstrLimit(
- "import-instr-limit", cl::init(100), cl::Hidden, cl::value_desc("N"),
- cl::desc("Only import functions with less than N instructions"));
-
-static cl::opt<int> ImportCutoff(
- "import-cutoff", cl::init(-1), cl::Hidden, cl::value_desc("N"),
- cl::desc("Only import first N functions if N>=0 (default -1)"));
-
-static cl::opt<float>
- ImportInstrFactor("import-instr-evolution-factor", cl::init(0.7),
- cl::Hidden, cl::value_desc("x"),
- cl::desc("As we import functions, multiply the "
- "`import-instr-limit` threshold by this factor "
- "before processing newly imported functions"));
-
-static cl::opt<float> ImportHotInstrFactor(
- "import-hot-evolution-factor", cl::init(1.0), cl::Hidden,
- cl::value_desc("x"),
- cl::desc("As we import functions called from hot callsite, multiply the "
- "`import-instr-limit` threshold by this factor "
- "before processing newly imported functions"));
-
-static cl::opt<float> ImportHotMultiplier(
- "import-hot-multiplier", cl::init(10.0), cl::Hidden, cl::value_desc("x"),
- cl::desc("Multiply the `import-instr-limit` threshold for hot callsites"));
-
-static cl::opt<float> ImportCriticalMultiplier(
- "import-critical-multiplier", cl::init(100.0), cl::Hidden,
- cl::value_desc("x"),
- cl::desc(
- "Multiply the `import-instr-limit` threshold for critical callsites"));
-
-// FIXME: This multiplier was not really tuned up.
-static cl::opt<float> ImportColdMultiplier(
- "import-cold-multiplier", cl::init(0), cl::Hidden, cl::value_desc("N"),
- cl::desc("Multiply the `import-instr-limit` threshold for cold callsites"));
-
-static cl::opt<bool> PrintImportFailures(
- "print-import-failures", cl::init(false), cl::Hidden,
- cl::desc("Print information for functions rejected for importing"));
-
-static cl::opt<bool> ComputeDead("compute-dead", cl::init(true), cl::Hidden,
- cl::desc("Compute dead symbols"));
-
-/// This is a test-only option.
-/// If this option is enabled, the ThinLTO indexing step will import each
-/// function declaration as a fallback. In a real build this may increase ram
-/// usage of the indexing step unnecessarily.
-/// TODO: Implement selective import (based on combined summary analysis) to
-/// ensure the imported function has a use case in the postlink pipeline.
-static cl::opt<bool> ImportDeclaration(
- "import-declaration", cl::init(false), cl::Hidden,
- cl::desc("If true, import function declaration as fallback if the function "
- "definition is not imported."));
-
-/// Narrower form of -import-declaration for indirect call promotion: when the
-/// definition of a profiled indirect call target is not imported, import its
-/// declaration and export it from its defining module, so that the backend can
-/// promote the indirect call to it (see -icp-allow-decls).
-static cl::opt<bool> ImportDeclarationForIndirectCalls(
- "import-declaration-for-indirect-calls", cl::init(false), cl::Hidden,
- cl::desc("If true, import a declaration of the target of an indirect call "
- "edge (and export it from its defining module) when its "
- "definition is not imported."));
-
-static cl::opt<CalleeInfo::HotnessType>
- ImportDeclarationForIndirectCallsMinHotness(
- "import-declaration-for-indirect-calls-min-hotness",
- cl::init(CalleeInfo::HotnessType::Hot), cl::Hidden,
- cl::desc("Minimum hotness of an indirect call edge for "
- "-import-declaration-for-indirect-calls to import a "
- "declaration of its target."),
- cl::values(clEnumValN(CalleeInfo::HotnessType::Unknown, "unknown",
- "Any edge, including ones without profile"),
- clEnumValN(CalleeInfo::HotnessType::Cold, "cold",
- "Cold or hotter edges"),
- clEnumValN(CalleeInfo::HotnessType::None, "none",
- "Edges that are not cold"),
- clEnumValN(CalleeInfo::HotnessType::Hot, "hot",
- "Hot or critical edges"),
- clEnumValN(CalleeInfo::HotnessType::Critical, "critical",
- "Critical edges only")));
-
-/// Pass a workload description file - an example of workload would be the
-/// functions executed to satisfy a RPC request. A workload is defined by a root
-/// function and the list of functions that are (frequently) needed to satisfy
-/// it. The module that defines the root will have all those functions imported.
-/// The file contains a JSON dictionary. The keys are root functions, the values
-/// are lists of functions to import in the module defining the root. It is
-/// assumed -funique-internal-linkage-names was used, thus ensuring function
-/// names are unique even for local linkage ones.
-static cl::opt<std::string> WorkloadDefinitions(
- "thinlto-workload-def",
- cl::desc("Pass a workload definition. This is a file containing a JSON "
- "dictionary. The keys are root functions, the values are lists of "
- "functions to import in the module defining the root. It is "
- "assumed -funique-internal-linkage-names was used, to ensure "
- "local linkage functions have unique names. For example: \n"
- "{\n"
- " \"rootFunction_1\": [\"function_to_import_1\", "
- "\"function_to_import_2\"], \n"
- " \"rootFunction_2\": [\"function_to_import_3\", "
- "\"function_to_import_4\"] \n"
- "}"),
- cl::Hidden);
-
extern cl::opt<std::string> UseCtxProfile;
-static cl::opt<bool> CtxprofMoveRootsToOwnModule(
- "thinlto-move-ctxprof-trees",
- cl::desc("Move contextual profiling roots and the graphs under them in "
- "their own module."),
- cl::Hidden, cl::init(false));
-
extern cl::list<GlobalValue::GUID> MoveSymbolGUID;
extern cl::opt<bool> EnableMemProfContextDisambiguation;
@@ -320,7 +203,7 @@ static auto qualifyCalleeCandidates(
/// - One that has PGO data attached.
/// - [insert you fancy metric here]
static const GlobalValueSummary *
-selectCallee(const ModuleSummaryIndex &Index,
+selectCallee(const IPOOptions &Opts, const ModuleSummaryIndex &Index,
ArrayRef<std::unique_ptr<GlobalValueSummary>> CalleeSummaryList,
unsigned Threshold, StringRef CallerModulePath,
const GlobalValueSummary *&TooLargeOrNoInlineSummary,
@@ -340,14 +223,14 @@ selectCallee(const ModuleSummaryIndex &Index,
// Don't bother importing the definition if the chance of inlining it is
// not high enough (except under `--force-import-all`).
if ((Summary->instCount() > Threshold) && !Summary->fflags().AlwaysInline &&
- !ForceImportAll) {
+ !Opts.force_import_all) {
TooLargeOrNoInlineSummary = Summary;
Reason = FunctionImporter::ImportFailureReason::TooLarge;
continue;
}
// Don't bother importing the definition if we can't inline it anyway.
- if (Summary->fflags().NoInline && !ForceImportAll) {
+ if (Summary->fflags().NoInline && !Opts.force_import_all) {
TooLargeOrNoInlineSummary = Summary;
Reason = FunctionImporter::ImportFailureReason::NoInline;
continue;
@@ -413,6 +296,7 @@ FunctionImporter::ImportMapTy::getImportType(StringRef FromModule,
/// Import globals referenced by a function or other globals that are being
/// imported, if importing such global is possible.
class GlobalsImporter final {
+ const IPOOptions &Opts;
const ModuleSummaryIndex &Index;
const GVSummaryMapTy &DefinedGVSummaries;
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
@@ -482,7 +366,7 @@ class GlobalsImporter final {
Summary.modulePath()) ||
!Index.canImportGlobalVar(GVS, /* AnalyzeRefs */ true,
CanImportDecl)) {
- if (ImportDeclaration && CanImportDecl)
+ if (Opts.import_declaration && CanImportDecl)
ImportList.maybeAddDeclaration(RefSummary->modulePath(),
VI.getGUID());
@@ -515,12 +399,13 @@ class GlobalsImporter final {
public:
GlobalsImporter(
- const ModuleSummaryIndex &Index, const GVSummaryMapTy &DefinedGVSummaries,
+ const IPOOptions &Opts, const ModuleSummaryIndex &Index,
+ const GVSummaryMapTy &DefinedGVSummaries,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
IsPrevailing,
FunctionImporter::ImportMapTy &ImportList,
DenseMap<StringRef, FunctionImporter::ExportSetTy> *ExportLists)
- : Index(Index), DefinedGVSummaries(DefinedGVSummaries),
+ : Opts(Opts), Index(Index), DefinedGVSummaries(DefinedGVSummaries),
IsPrevailing(IsPrevailing), ImportList(ImportList),
ExportLists(ExportLists) {}
@@ -544,6 +429,7 @@ class ModuleImportsManager {
FunctionImporter::ImportThresholdsTy &ImportThresholds);
protected:
+ const IPOOptions &Opts;
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
IsPrevailing;
const ModuleSummaryIndex &Index;
@@ -556,11 +442,13 @@ class ModuleImportsManager {
DenseMap<StringRef, FunctionImporter::ExportSetTy> RequiredDeclExports;
ModuleImportsManager(
+ const IPOOptions &Opts,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
IsPrevailing,
const ModuleSummaryIndex &Index,
DenseMap<StringRef, FunctionImporter::ExportSetTy> *ExportLists = nullptr)
- : IsPrevailing(IsPrevailing), Index(Index), ExportLists(ExportLists) {}
+ : Opts(Opts), IsPrevailing(IsPrevailing), Index(Index),
+ ExportLists(ExportLists) {}
virtual bool canImport(ValueInfo VI) { return true; }
/// Import a declaration of the callee \p VI of a call edge requiring a
@@ -603,7 +491,8 @@ class ModuleImportsManager {
FunctionImporter::ImportMapTy &ImportList);
static std::unique_ptr<ModuleImportsManager>
- create(function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
+ create(const IPOOptions &Opts,
+ function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
IsPrevailing,
const ModuleSummaryIndex &Index,
DenseMap<StringRef, FunctionImporter::ExportSetTy> *ExportLists =
@@ -629,7 +518,7 @@ class WorkloadImportsManager : public ModuleImportsManager {
StringRef ModName,
FunctionImporter::ImportMapTy &ImportList) override {
StringRef Filename = ModName;
- if (CtxprofMoveRootsToOwnModule) {
+ if (Opts.thinlto_move_ctxprof_trees) {
Filename = sys::path::filename(ModName);
// Drop the file extension.
Filename = Filename.substr(0, Filename.find_last_of('.'));
@@ -645,8 +534,8 @@ class WorkloadImportsManager : public ModuleImportsManager {
LLVM_DEBUG(dbgs() << "[Workload] " << ModName
<< " contains the root(s) of context(s).\n");
- GlobalsImporter GVI(Index, DefinedGVSummaries, IsPrevailing, ImportList,
- ExportLists);
+ GlobalsImporter GVI(Opts, Index, DefinedGVSummaries, IsPrevailing,
+ ImportList, ExportLists);
auto &ValueInfos = SetIter->second;
for (auto &VI : llvm::make_early_inc_range(ValueInfos)) {
auto It = DefinedGVSummaries.find(VI.getGUID());
@@ -757,7 +646,7 @@ class WorkloadImportsManager : public ModuleImportsManager {
});
};
std::error_code EC;
- auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(WorkloadDefinitions);
+ auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Opts.thinlto_workload_def);
if (std::error_code EC = BufferOrErr.getError()) {
report_fatal_error("Failed to open context file");
return;
@@ -848,7 +737,7 @@ class WorkloadImportsManager : public ModuleImportsManager {
}
std::string RootDefiningModule =
RootVI.getSummaryList().front()->modulePath().str();
- if (CtxprofMoveRootsToOwnModule) {
+ if (Opts.thinlto_move_ctxprof_trees) {
RootDefiningModule = std::to_string(RootGuid);
LLVM_DEBUG(
dbgs() << "[Workload] Moving " << RootGuid
@@ -871,12 +760,13 @@ class WorkloadImportsManager : public ModuleImportsManager {
public:
WorkloadImportsManager(
+ const IPOOptions &Opts,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
IsPrevailing,
const ModuleSummaryIndex &Index,
DenseMap<StringRef, FunctionImporter::ExportSetTy> *ExportLists)
- : ModuleImportsManager(IsPrevailing, Index, ExportLists) {
- if (UseCtxProfile.empty() == WorkloadDefinitions.empty()) {
+ : ModuleImportsManager(Opts, IsPrevailing, Index, ExportLists) {
+ if (UseCtxProfile.empty() == Opts.thinlto_workload_def.empty()) {
report_fatal_error(
"Pass only one of: -thinlto-pgo-ctx-prof or -thinlto-workload-def");
return;
@@ -899,17 +789,18 @@ class WorkloadImportsManager : public ModuleImportsManager {
};
std::unique_ptr<ModuleImportsManager> ModuleImportsManager::create(
+ const IPOOptions &Opts,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
IsPrevailing,
const ModuleSummaryIndex &Index,
DenseMap<StringRef, FunctionImporter::ExportSetTy> *ExportLists) {
- if (WorkloadDefinitions.empty() && UseCtxProfile.empty()) {
+ if (Opts.thinlto_workload_def.empty() && UseCtxProfile.empty()) {
LLVM_DEBUG(dbgs() << "[Workload] Using the regular imports manager.\n");
return std::unique_ptr<ModuleImportsManager>(
- new ModuleImportsManager(IsPrevailing, Index, ExportLists));
+ new ModuleImportsManager(Opts, IsPrevailing, Index, ExportLists));
}
LLVM_DEBUG(dbgs() << "[Workload] Using the contextual imports manager.\n");
- return std::make_unique<WorkloadImportsManager>(IsPrevailing, Index,
+ return std::make_unique<WorkloadImportsManager>(Opts, IsPrevailing, Index,
ExportLists);
}
@@ -969,14 +860,14 @@ void ModuleImportsManager::computeImportForFunction(
const bool RequiresDeclImport =
Edge.second.requiresDeclImport() ||
(Edge.second.hasIndirectCall() &&
- (ImportDeclaration ||
- (ImportDeclarationForIndirectCalls &&
+ (Opts.import_declaration ||
+ (Opts.import_declaration_for_indirect_calls &&
Edge.second.getHotness() >=
- ImportDeclarationForIndirectCallsMinHotness)));
+ Opts.import_declaration_for_indirect_calls_min_hotness)));
- if (ImportCutoff >= 0 && ImportCount >= ImportCutoff) {
- LLVM_DEBUG(dbgs() << "ignored! import-cutoff value of " << ImportCutoff
- << " reached.\n");
+ if (Opts.import_cutoff >= 0 && ImportCount >= Opts.import_cutoff) {
+ LLVM_DEBUG(dbgs() << "ignored! import-cutoff value of "
+ << Opts.import_cutoff << " reached.\n");
// Still import a declaration if one is required, as that doesn't
// affect the import cutoff count.
if (RequiresDeclImport && !DefinedGVSummaries.count(VI.getGUID()))
@@ -1001,13 +892,13 @@ void ModuleImportsManager::computeImportForFunction(
continue;
}
- auto GetBonusMultiplier = [](CalleeInfo::HotnessType Hotness) -> float {
+ auto GetBonusMultiplier = [&](CalleeInfo::HotnessType Hotness) -> float {
if (Hotness == CalleeInfo::HotnessType::Hot)
- return ImportHotMultiplier;
+ return Opts.import_hot_multiplier;
if (Hotness == CalleeInfo::HotnessType::Cold)
- return ImportColdMultiplier;
+ return Opts.import_cold_multiplier;
if (Hotness == CalleeInfo::HotnessType::Critical)
- return ImportCriticalMultiplier;
+ return Opts.import_critical_multiplier;
return 1.0;
};
@@ -1049,7 +940,7 @@ void ModuleImportsManager::computeImportForFunction(
LLVM_DEBUG(
dbgs() << "ignored! Target was already rejected with Threshold "
<< ProcessedThreshold << "\n");
- if (PrintImportFailures) {
+ if (Opts.print_import_failures) {
assert(FailureInfo &&
"Expected FailureInfo for previously rejected candidate");
FailureInfo->Attempts++;
@@ -1067,7 +958,7 @@ void ModuleImportsManager::computeImportForFunction(
// `SummaryForDeclImport` is an summary eligible for declaration import.
const GlobalValueSummary *SummaryForDeclImport = nullptr;
CalleeSummary =
- selectCallee(Index, VI.getSummaryList(), NewThreshold,
+ selectCallee(Opts, Index, VI.getSummaryList(), NewThreshold,
Summary.modulePath(), SummaryForDeclImport, Reason);
if (!CalleeSummary) {
// There isn't a callee for definition import but one for declaration
@@ -1076,7 +967,7 @@ void ModuleImportsManager::computeImportForFunction(
if (RequiresDeclImport)
// This also marks the callee exported.
addRequiredDeclaration(VI, SummaryForDeclImport, ImportList);
- else if (ImportDeclaration)
+ else if (Opts.import_declaration)
// Not exported, see the comments where RequiresDeclImport is set.
ImportList.maybeAddDeclaration(SummaryForDeclImport->modulePath(),
VI.getGUID());
@@ -1086,7 +977,7 @@ void ModuleImportsManager::computeImportForFunction(
// update failure info if requested.
if (PreviouslyVisited) {
ProcessedThreshold = NewThreshold;
- if (PrintImportFailures) {
+ if (Opts.print_import_failures) {
assert(FailureInfo &&
"Expected FailureInfo for previously rejected candidate");
FailureInfo->Reason = Reason;
@@ -1094,13 +985,13 @@ void ModuleImportsManager::computeImportForFunction(
FailureInfo->MaxHotness =
std::max(FailureInfo->MaxHotness, Edge.second.getHotness());
}
- } else if (PrintImportFailures) {
+ } else if (Opts.print_import_failures) {
assert(!FailureInfo &&
"Expected no FailureInfo for newly rejected candidate");
FailureInfo = std::make_unique<FunctionImporter::ImportFailureInfo>(
VI, Edge.second.getHotness(), Reason, 1);
}
- if (ForceImportAll) {
+ if (Opts.force_import_all) {
std::string Msg = std::string("Failed to import function ") +
VI.name().str() + " due to " +
getFailureName(Reason);
@@ -1120,7 +1011,8 @@ void ModuleImportsManager::computeImportForFunction(
CalleeSummary = CalleeSummary->getBaseObject();
ResolvedCalleeSummary = cast<FunctionSummary>(CalleeSummary);
- assert((ResolvedCalleeSummary->fflags().AlwaysInline || ForceImportAll ||
+ assert((ResolvedCalleeSummary->fflags().AlwaysInline ||
+ Opts.force_import_all ||
(ResolvedCalleeSummary->instCount() <= NewThreshold)) &&
"selectCallee() didn't honor the threshold");
@@ -1144,13 +1036,13 @@ void ModuleImportsManager::computeImportForFunction(
(*ExportLists)[ExportModulePath].insert(VI);
}
- auto GetAdjustedThreshold = [](unsigned Threshold, bool IsHotCallsite) {
+ auto GetAdjustedThreshold = [&](unsigned Threshold, bool IsHotCallsite) {
// Adjust the threshold for next level of imported functions.
// The threshold is different for hot callsites because we can then
// inline chains of hot calls.
if (IsHotCallsite)
- return Threshold * ImportHotInstrFactor;
- return Threshold * ImportInstrFactor;
+ return Threshold * Opts.import_hot_evolution_factor;
+ return Threshold * Opts.import_instr_evolution_factor;
};
const auto AdjThreshold = GetAdjustedThreshold(Threshold, IsHotCallsite);
@@ -1168,7 +1060,7 @@ void ModuleImportsManager::computeImportForModule(
// Worklist contains the list of function imported in this module, for which
// we will analyse the callees and may import further down the callgraph.
SmallVector<EdgeInfo, 128> Worklist;
- GlobalsImporter GVI(Index, DefinedGVSummaries, IsPrevailing, ImportList,
+ GlobalsImporter GVI(Opts, Index, DefinedGVSummaries, IsPrevailing, ImportList,
ExportLists);
FunctionImporter::ImportThresholdsTy ImportThresholds;
@@ -1190,8 +1082,9 @@ void ModuleImportsManager::computeImportForModule(
// Skip import for global variables
continue;
LLVM_DEBUG(dbgs() << "Initialize import for " << VI << "\n");
- computeImportForFunction(*FuncSummary, ImportInstrLimit, DefinedGVSummaries,
- Worklist, GVI, ImportList, ImportThresholds);
+ computeImportForFunction(*FuncSummary, Opts.import_instr_limit,
+ DefinedGVSummaries, Worklist, GVI, ImportList,
+ ImportThresholds);
}
// Process the newly imported functions and add callees to the worklist.
@@ -1206,7 +1099,7 @@ void ModuleImportsManager::computeImportForModule(
// Print stats about functions considered but rejected for importing
// when requested.
- if (PrintImportFailures) {
+ if (Opts.print_import_failures) {
dbgs() << "Missed imports into module " << ModName << "\n";
for (auto &I : ImportThresholds) {
auto &ProcessedThreshold = std::get<0>(I.second);
@@ -1361,13 +1254,15 @@ static bool checkVariableImport(
/// Compute all the import and export for every module using the Index.
void llvm::ComputeCrossModuleImport(
+ const cl::LibraryOptionsContext &LibraryOptions,
const ModuleSummaryIndex &Index,
const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
isPrevailing,
FunctionImporter::ImportListsTy &ImportLists,
DenseMap<StringRef, FunctionImporter::ExportSetTy> &ExportLists) {
- auto MIS = ModuleImportsManager::create(isPrevailing, Index, &ExportLists);
+ auto MIS = ModuleImportsManager::create(LibraryOptions.get<IPOOptions>(),
+ isPrevailing, Index, &ExportLists);
// For each module that has function defined, compute the import/export lists.
for (const auto &DefinedGVSummaries : ModuleToDefinedGVSummaries) {
auto &ImportList = ImportLists[DefinedGVSummaries.first];
@@ -1485,7 +1380,7 @@ static void dumpImportListForModule(const ModuleSummaryIndex &Index,
/// \p ImportList will be populated with a map that can be passed to
/// FunctionImporter::importFunctions() above (see description there).
static void ComputeCrossModuleImportForModuleForTest(
- StringRef ModulePath,
+ const IPOOptions &Opts, StringRef ModulePath,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
isPrevailing,
const ModuleSummaryIndex &Index,
@@ -1497,7 +1392,7 @@ static void ComputeCrossModuleImportForModuleForTest(
// Compute the import list for this module.
LLVM_DEBUG(dbgs() << "Computing import for Module '" << ModulePath << "'\n");
- auto MIS = ModuleImportsManager::create(isPrevailing, Index);
+ auto MIS = ModuleImportsManager::create(Opts, isPrevailing, Index);
MIS->computeImportForModule(FunctionSummaryMap, ModulePath, ImportList);
#ifndef NDEBUG
@@ -1599,11 +1494,11 @@ void llvm::updateIndirectCalls(ModuleSummaryIndex &Index) {
}
void llvm::computeDeadSymbolsAndUpdateIndirectCalls(
- ModuleSummaryIndex &Index,
+ const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index,
const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols,
function_ref<PrevailingType(GlobalValue::GUID)> isPrevailing) {
assert(!Index.withGlobalValueDeadStripping());
- if (!ComputeDead ||
+ if (!LibraryOptions.get<IPOOptions>().compute_dead ||
// Don't do anything when nothing is live, this is friendly with tests.
GUIDPreservedSymbols.empty()) {
// Still need to update indirect calls.
@@ -1715,13 +1610,13 @@ void llvm::computeDeadSymbolsAndUpdateIndirectCalls(
// Compute dead symbols and propagate constants in combined index.
void llvm::computeDeadSymbolsWithConstProp(
- ModuleSummaryIndex &Index,
+ const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index,
const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols,
function_ref<PrevailingType(GlobalValue::GUID)> isPrevailing,
bool ImportEnabled) {
llvm::TimeTraceScope timeScope("Drop dead symbols and propagate attributes");
- computeDeadSymbolsAndUpdateIndirectCalls(Index, GUIDPreservedSymbols,
- isPrevailing);
+ computeDeadSymbolsAndUpdateIndirectCalls(LibraryOptions, Index,
+ GUIDPreservedSymbols, isPrevailing);
if (ImportEnabled)
Index.propagateAttributes(GUIDPreservedSymbols);
}
@@ -2109,6 +2004,10 @@ static void protectImplicitRefGlobals(Module &M) {
appendToCompilerUsed(M, ToProtect);
}
+bool FunctionImporter::forceImportAll(const cl::LibraryOptionsContext &C) {
+ return C.get<IPOOptions>().force_import_all;
+}
+
// Automatically import functions in Module \p DestModule based on the summaries
// index.
Expected<bool> FunctionImporter::importFunctions(
@@ -2442,7 +2341,7 @@ static bool doImportingForModuleForTest(
ComputeCrossModuleImportForModuleFromIndexForTest(M.getModuleIdentifier(),
*Index, ImportList);
else
- ComputeCrossModuleImportForModuleForTest(M.getModuleIdentifier(),
+ ComputeCrossModuleImportForModuleForTest(Opts, M.getModuleIdentifier(),
isPrevailing, *Index, ImportList);
// Conservatively mark all internal values as promoted. This interface is
diff --git a/llvm/lib/Transforms/IPO/IPOOptions.h b/llvm/lib/Transforms/IPO/IPOOptions.h
index 47a22f39549f2a..c6385475fd8a72 100644
--- a/llvm/lib/Transforms/IPO/IPOOptions.h
+++ b/llvm/lib/Transforms/IPO/IPOOptions.h
@@ -13,6 +13,7 @@
#include "llvm/IR/Function.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/ModuleSummaryIndex.h"
#include <limits>
#include <optional>
diff --git a/llvm/lib/Transforms/IPO/IPOOptions.td b/llvm/lib/Transforms/IPO/IPOOptions.td
index 3dac9ca3fb701c..1c0f10c1776b0a 100644
--- a/llvm/lib/Transforms/IPO/IPOOptions.td
+++ b/llvm/lib/Transforms/IPO/IPOOptions.td
@@ -112,23 +112,76 @@ defm : BoolField<"nofree-inference", "true",
"Infer nofree attribute during function-attrs pass">;
defm : BoolField<"nounwind-inference", "true",
"Infer nounwind attribute during function-attrs pass">;
+defm : BoolField<"thinlto-funcattrs", "false",
+ "Propagate function-attrs in thinLTO">;
// TODO: Remove the old spellings after 2027-05.
def : AliasOf<"disable-nofree-inference", "nofree-inference=false">;
def : AliasOf<"disable-nounwind-inference", "nounwind-inference=false">;
// FunctionImport.cpp
+defm : BoolField<"compute-dead", "true",
+ "Compute dead symbols">;
defm : BoolField<"enable-import-metadata", "false",
"Enable import metadata like 'thinlto_src_module' and 'thinlto_src_file'">;
+defm : BoolField<"force-import-all", "false",
+ "Import functions with noinline attribute">;
// Used when testing importing from distributed indexes via opt
// -function-import.
defm : BoolField<"import-all-index", "false",
"Import all external functions in index">;
+// FIXME: This multiplier was not really tuned up.
+defm : ValueField<"import-cold-multiplier", "float", "0",
+ "Multiply the `import-instr-limit` threshold for cold callsites">;
+defm : ValueField<"import-critical-multiplier", "float", "100.0",
+ "Multiply the `import-instr-limit` threshold for critical callsites">;
+defm : ValueField<"import-cutoff", "int", "-1",
+ "Only import first N functions if N>=0">;
+// This is a test-only option.
+// If this option is enabled, the ThinLTO indexing step will import each
+// function declaration as a fallback. In a real build this may increase ram
+// usage of the indexing step unnecessarily.
+// TODO: Implement selective import (based on combined summary analysis) to
+// ensure the imported function has a use case in the postlink pipeline.
+defm : BoolField<"import-declaration", "false",
+ "If true, import function declaration as fallback if the function definition is not imported">;
+// Narrower form of -import-declaration for indirect call promotion: when the
+// definition of a profiled indirect call target is not imported, import its
+// declaration and export it from its defining module, so that the backend can
+// promote the indirect call to it (see -icp-allow-decls).
+defm : BoolField<"import-declaration-for-indirect-calls", "false",
+ "If true, import a declaration of the target of an indirect call edge (and export it from its defining module) when its definition is not imported">;
+defm : EnumField<"import-declaration-for-indirect-calls-min-hotness", "CalleeInfo::HotnessType", "CalleeInfo::HotnessType::Hot",
+ "unknown,cold,none,hot,critical",
+ ["CalleeInfo::HotnessType::Unknown", "CalleeInfo::HotnessType::Cold", "CalleeInfo::HotnessType::None", "CalleeInfo::HotnessType::Hot", "CalleeInfo::HotnessType::Critical"],
+ "Minimum hotness of an indirect call edge for -import-declaration-for-indirect-calls to import a declaration of its target">;
+defm : ValueField<"import-hot-evolution-factor", "float", "1.0",
+ "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",
+ "As we import functions, multiply the `import-instr-limit` threshold by this factor before processing newly imported functions">;
+defm : ValueField<"import-instr-limit", "unsigned", "100",
+ "Only import functions with less than N instructions">;
+defm : BoolField<"print-import-failures", "false",
+ "Print information for functions rejected for importing">;
defm : BoolField<"print-imports", "false",
"Print imported functions">;
// Summary file to use for function importing when using -function-import from
// the command line.
defm : ValueField<"summary-file", "StringRef", "",
"The summary file to use for function importing">;
+defm : BoolField<"thinlto-move-ctxprof-trees", "false",
+ "Move contextual profiling roots and the graphs under them in their own module">;
+// Pass a workload description file - an example of workload would be the
+// functions executed to satisfy a RPC request. A workload is defined by a root
+// function and the list of functions that are (frequently) needed to satisfy
+// it. The module that defines the root will have all those functions imported.
+// The file contains a JSON dictionary. The keys are root functions, the values
+// are lists of functions to import in the module defining the root. It is
+// assumed -funique-internal-linkage-names was used, thus ensuring function
+// names are unique even for local linkage ones.
+defm : ValueField<"thinlto-workload-def", "StringRef", "",
+ "Pass a workload definition. This is a file containing a JSON dictionary. The keys are root functions, the values are lists of functions to import in the module defining the root. It is assumed -funique-internal-linkage-names was used, to ensure local linkage functions have unique names. For example: \n{\n \"rootFunction_1\": [\"function_to_import_1\", \"function_to_import_2\"], \n \"rootFunction_2\": [\"function_to_import_3\", \"function_to_import_4\"] \n}">;
// FunctionSpecialization.cpp
defm : BoolField<"funcspec-for-literal-constant", "true",
@@ -486,14 +539,46 @@ defm : BoolField<"strip-global-constants", "false",
// WholeProgramDevirt.cpp
defm : BoolField<"devirtualize-speculatively", "false",
"Enable speculative devirtualization optimization">;
+// Provide a way to force disable whole program for debugging or workarounds,
+// when enabled via the linker.
+defm : BoolField<"disable-whole-program-visibility", "false",
+ "Disable whole program visibility (overrides enabling options)">;
+// Provide a way to force enable whole program visibility in tests. This is
+// needed to support legacy tests that don't contain !vcall_visibility metadata
+// (the mere presense of type tests previously implied hidden visibility).
+defm : BoolField<"whole-program-visibility", "false",
+ "Enable whole program visibility">;
defm : ValueField<"wholeprogramdevirt-branch-funnel-threshold", "unsigned", "10",
"Maximum number of call targets per call site to enable branch funnels">;
defm : EnumField<"wholeprogramdevirt-check", "WPDCheckMode", "",
"none,trap,fallback",
["WPDCheckMode::None", "WPDCheckMode::Trap", "WPDCheckMode::Fallback"],
"Type of checking for incorrect devirtualizations">;
+// With Clang, a pure virtual class's deleting destructor is emitted as a
+// `llvm.trap` intrinsic followed by an unreachable IR instruction. In the
+// context of whole program devirtualization, the deleting destructor of a pure
+// virtual class won't be invoked by the source code so safe to skip as a
+// devirtualize target.
+//
+// However, not all unreachable functions are safe to skip. In some cases, the
+// program intends to run such functions and terminate, for instance, a unit
+// test may run a death test. A non-test program might (or allowed to) invoke
+// such functions to report failures (whether/when it's a good practice or not
+// is a different topic).
+//
+// This option is enabled to keep an unreachable function as a possible
+// devirtualize target to conservatively keep the program behavior.
+//
+// TODO: Make a pure virtual class's deleting destructor precisely identifiable
+// in Clang's codegen for more devirtualization in LLVM.
+defm : BoolField<"wholeprogramdevirt-keep-unreachable-function", "true",
+ "Regard unreachable functions as possible devirtualize targets">;
+defm : BoolField<"wholeprogramdevirt-print-index-based", "false",
+ "Print index-based devirtualization messages">;
defm : ValueField<"wholeprogramdevirt-read-summary", "StringRef", "",
"Read summary from given bitcode or YAML file before running pass">;
+defm : ListField<"wholeprogramdevirt-skip", "StringRef",
+ "Prevent function(s) from being devirtualized">;
defm : EnumField<"wholeprogramdevirt-summary-action", "PassSummaryAction", "",
"none,import,export",
["PassSummaryAction::None", "PassSummaryAction::Import", "PassSummaryAction::Export"],
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index 1b9d0bdf7ce713..688fdaf0bda1a7 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -102,7 +102,6 @@
#include "llvm/IR/ProfDataUtils.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/Casting.h"
-#include "llvm/Support/CommandLine.h"
#include "llvm/Support/DebugCounter.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
@@ -139,56 +138,6 @@ STATISTIC(NumVirtConstProp, "Number of virtual constant propagations");
DEBUG_COUNTER(CallsToDevirt, "calls-to-devirt",
"Controls how many calls should be devirtualized.");
-namespace llvm {
-
-static cl::opt<bool>
- PrintSummaryDevirt("wholeprogramdevirt-print-index-based", cl::Hidden,
- cl::desc("Print index-based devirtualization messages"));
-
-/// Provide a way to force enable whole program visibility in tests.
-/// This is needed to support legacy tests that don't contain
-/// !vcall_visibility metadata (the mere presense of type tests
-/// previously implied hidden visibility).
-static cl::opt<bool>
- WholeProgramVisibility("whole-program-visibility", cl::Hidden,
- cl::desc("Enable whole program visibility"));
-
-/// Provide a way to force disable whole program for debugging or workarounds,
-/// when enabled via the linker.
-static cl::opt<bool> DisableWholeProgramVisibility(
- "disable-whole-program-visibility", cl::Hidden,
- cl::desc("Disable whole program visibility (overrides enabling options)"));
-
-/// Provide way to prevent certain function from being devirtualized
-static cl::list<std::string>
- SkipFunctionNames("wholeprogramdevirt-skip",
- cl::desc("Prevent function(s) from being devirtualized"),
- cl::Hidden, cl::CommaSeparated);
-
-} // end namespace llvm
-
-/// With Clang, a pure virtual class's deleting destructor is emitted as a
-/// `llvm.trap` intrinsic followed by an unreachable IR instruction. In the
-/// context of whole program devirtualization, the deleting destructor of a pure
-/// virtual class won't be invoked by the source code so safe to skip as a
-/// devirtualize target.
-///
-/// However, not all unreachable functions are safe to skip. In some cases, the
-/// program intends to run such functions and terminate, for instance, a unit
-/// test may run a death test. A non-test program might (or allowed to) invoke
-/// such functions to report failures (whether/when it's a good practice or not
-/// is a different topic).
-///
-/// This option is enabled to keep an unreachable function as a possible
-/// devirtualize target to conservatively keep the program behavior.
-///
-/// TODO: Make a pure virtual class's deleting destructor precisely identifiable
-/// in Clang's codegen for more devirtualization in LLVM.
-static cl::opt<bool> WholeProgramDevirtKeepUnreachableFunction(
- "wholeprogramdevirt-keep-unreachable-function",
- cl::desc("Regard unreachable functions as possible devirtualize targets."),
- cl::Hidden, cl::init(true));
-
namespace {
struct PatternList {
std::vector<GlobPattern> Patterns;
@@ -365,9 +314,6 @@ template <> struct llvm::DenseMapInfo<VTableSlotSummary> {
// 2) All function summaries indicate it's unreachable
// 3) There is no non-function with the same GUID (which is rare)
static bool mustBeUnreachableFunction(ValueInfo TheFnVI) {
- if (WholeProgramDevirtKeepUnreachableFunction)
- return false;
-
if ((!TheFnVI) || TheFnVI.getSummaryList().empty()) {
// Returns false if ValueInfo is absent, or the summary list is empty
// (e.g., function declarations).
@@ -588,7 +534,7 @@ struct DevirtModule {
DevirtSpeculatively ||
(ImportSummary && ImportSummary->withSpeculativeDevirt())) {
assert(!(ExportSummary && ImportSummary));
- FunctionsToSkip.init(SkipFunctionNames);
+ FunctionsToSkip.init(Opts.wholeprogramdevirt_skip);
}
bool areRemarksEnabled();
@@ -705,6 +651,7 @@ struct DevirtModule {
};
struct DevirtIndex {
+ const IPOOptions &Opts;
ModuleSummaryIndex &ExportSummary;
// The set in which to record GUIDs exported from their module by
// devirtualization, used by client to ensure they are not internalized.
@@ -728,15 +675,15 @@ struct DevirtIndex {
const bool DevirtSpeculatively;
DevirtIndex(
- ModuleSummaryIndex &ExportSummary,
+ const IPOOptions &Opts, ModuleSummaryIndex &ExportSummary,
std::set<GlobalValue::GUID> &ExportedGUIDs,
std::map<ValueInfo, std::vector<VTableSlotSummary>> &LocalWPDTargetsMap,
DenseSet<StringRef> *ExternallyVisibleSymbolNamesPtr)
- : ExportSummary(ExportSummary), ExportedGUIDs(ExportedGUIDs),
+ : Opts(Opts), ExportSummary(ExportSummary), ExportedGUIDs(ExportedGUIDs),
LocalWPDTargetsMap(LocalWPDTargetsMap),
ExternallyVisibleSymbolNamesPtr(ExternallyVisibleSymbolNamesPtr),
DevirtSpeculatively(ExportSummary.withSpeculativeDevirt()) {
- FunctionsToSkip.init(SkipFunctionNames);
+ FunctionsToSkip.init(Opts.wholeprogramdevirt_skip);
}
bool tryFindVirtualCallTargets(std::vector<ValueInfo> &TargetsForSlot,
@@ -784,9 +731,13 @@ PreservedAnalyses WholeProgramDevirtPass::run(Module &M,
// Enable whole program visibility if enabled by client (e.g. linker) or
// internal option, and not force disabled.
-bool llvm::hasWholeProgramVisibility(bool WholeProgramVisibilityEnabledInLTO) {
- return (WholeProgramVisibilityEnabledInLTO || WholeProgramVisibility) &&
- !DisableWholeProgramVisibility;
+bool llvm::hasWholeProgramVisibility(
+ const cl::LibraryOptionsContext &LibraryOptions,
+ bool WholeProgramVisibilityEnabledInLTO) {
+ const IPOOptions &Opts = LibraryOptions.get<IPOOptions>();
+ return (WholeProgramVisibilityEnabledInLTO ||
+ Opts.whole_program_visibility) &&
+ !Opts.disable_whole_program_visibility;
}
static bool
@@ -835,7 +786,8 @@ void llvm::updateVCallVisibilityInModule(
const DenseSet<GlobalValue::GUID> &DynamicExportSymbols,
bool ValidateAllVtablesHaveTypeInfos,
function_ref<bool(StringRef)> IsVisibleToRegularObj) {
- if (!hasWholeProgramVisibility(WholeProgramVisibilityEnabledInLTO))
+ if (!hasWholeProgramVisibility(M.getContext().getLibraryOptions(),
+ WholeProgramVisibilityEnabledInLTO))
return;
for (GlobalVariable &GV : M.globals()) {
@@ -865,7 +817,8 @@ void llvm::updatePublicTypeTestCalls(Module &M,
Intrinsic::getDeclarationIfExists(&M, Intrinsic::public_type_test);
if (!PublicTypeTestFunc)
return;
- if (hasWholeProgramVisibility(WholeProgramVisibilityEnabledInLTO)) {
+ if (hasWholeProgramVisibility(M.getContext().getLibraryOptions(),
+ WholeProgramVisibilityEnabledInLTO)) {
Function *TypeTestFunc =
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::type_test);
for (Use &U : make_early_inc_range(PublicTypeTestFunc->uses())) {
@@ -908,10 +861,12 @@ void llvm::getVisibleToRegularObjVtableGUIDs(
/// visibility metadata on vtable definition summaries to linkage unit
/// visibility in Module summary index (for ThinLTO).
void llvm::updateVCallVisibilityInIndex(
- ModuleSummaryIndex &Index, bool WholeProgramVisibilityEnabledInLTO,
+ const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index,
+ bool WholeProgramVisibilityEnabledInLTO,
const DenseSet<GlobalValue::GUID> &DynamicExportSymbols,
const DenseSet<GlobalValue::GUID> &VisibleToRegularObjSymbols) {
- if (!hasWholeProgramVisibility(WholeProgramVisibilityEnabledInLTO))
+ if (!hasWholeProgramVisibility(LibraryOptions,
+ WholeProgramVisibilityEnabledInLTO))
return;
for (auto &P : Index) {
// Don't upgrade the visibility for symbols exported to the dynamic
@@ -935,17 +890,18 @@ void llvm::updateVCallVisibilityInIndex(
}
void llvm::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) {
+ const IPOOptions &Opts = LibraryOptions.get<IPOOptions>();
// Record in the combined index whether speculative devirtualization is
// enabled. This is consulted by the index-based WPD below, and by the
// 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)
Summary.setWithSpeculativeDevirt();
- DevirtIndex(Summary, ExportedGUIDs, LocalWPDTargetsMap,
+ DevirtIndex(Opts, Summary, ExportedGUIDs, LocalWPDTargetsMap,
ExternallyVisibleSymbolNamesPtr)
.run();
}
@@ -1124,7 +1080,8 @@ bool DevirtModule::tryFindVirtualCallTargets(
// We can disregard unreachable functions as possible call targets, as
// unreachable functions shouldn't be called.
- if (mustBeUnreachableFunction(Fn, ExportSummary))
+ if (!Opts.wholeprogramdevirt_keep_unreachable_function &&
+ mustBeUnreachableFunction(Fn, ExportSummary))
continue;
// Save the symbol used in the vtable to use as the devirtualization
@@ -1209,7 +1166,8 @@ bool DevirtIndex::tryFindVirtualCallTargets(
if (VTP.VTableOffset != P.AddressPointOffset + ByteOffset)
continue;
- if (mustBeUnreachableFunction(VTP.FuncVI))
+ if (!Opts.wholeprogramdevirt_keep_unreachable_function &&
+ mustBeUnreachableFunction(VTP.FuncVI))
continue;
TargetsForSlot.push_back(VTP.FuncVI);
@@ -1458,7 +1416,7 @@ bool DevirtIndex::trySingleImplDevirt(MutableArrayRef<ValueInfo> TargetsForSlot,
return false;
// Collect functions devirtualized at least for one call site for stats.
- if (PrintSummaryDevirt || AreStatisticsEnabled())
+ if (Opts.wholeprogramdevirt_print_index_based || AreStatisticsEnabled())
DevirtTargets.insert(TheFn);
auto &S = TheFn.getSummaryList()[0];
@@ -2467,8 +2425,6 @@ DevirtModule::lookUpFunctionValueInfo(Function *TheFn,
bool DevirtModule::mustBeUnreachableFunction(
Function *const F, ModuleSummaryIndex *ExportSummary) {
- if (WholeProgramDevirtKeepUnreachableFunction)
- return false;
// First, learn unreachability by analyzing function IR.
if (!F->isDeclaration()) {
// A function must be unreachable if its entry block ends with an
@@ -2786,7 +2742,7 @@ void DevirtIndex::run() {
// Optionally have the thin link print message for each devirtualized
// function.
- if (PrintSummaryDevirt)
+ if (Opts.wholeprogramdevirt_print_index_based)
for (const auto &DT : DevirtTargets)
errs() << "Devirtualized call to " << DT << "\n";
diff --git a/llvm/test/ThinLTO/X86/deadstrip.ll b/llvm/test/ThinLTO/X86/deadstrip.ll
index 4a4ef5d818ab7c..9f0056df28c136 100644
--- a/llvm/test/ThinLTO/X86/deadstrip.ll
+++ b/llvm/test/ThinLTO/X86/deadstrip.ll
@@ -29,7 +29,7 @@
; RUN: -r %t2.bc,_another_dead_func,pl \
; RUN: -r %t2.bc,_linkonceodrfuncwithalias,pl \
; RUN: -thinlto-threads=1 \
-; RUN: -disable-thinlto-funcattrs=0 \
+; RUN: -thinlto-funcattrs \
; RUN: -debug-only=function-import 2>&1 | FileCheck %s --check-prefix=DEBUG --check-prefix=STATS
; RUN: llvm-dis < %t.out.1.3.import.bc | FileCheck %s --check-prefix=LTO2
; RUN: llvm-dis < %t.out.2.3.import.bc | FileCheck %s --check-prefix=LTO2-CHECK2
diff --git a/llvm/test/ThinLTO/X86/funcattrs-prop-exported-internal.ll b/llvm/test/ThinLTO/X86/funcattrs-prop-exported-internal.ll
index 63615c72731204..fe9d542abc6e95 100644
--- a/llvm/test/ThinLTO/X86/funcattrs-prop-exported-internal.ll
+++ b/llvm/test/ThinLTO/X86/funcattrs-prop-exported-internal.ll
@@ -5,7 +5,7 @@
; RUN: split-file %s %t
; RUN: opt -thinlto-bc %t/main.ll -thin-link-bitcode-file=%t1.thinlink.bc -o %t1.bc
; RUN: opt -thinlto-bc %t/callees.ll -thin-link-bitcode-file=%t2.thinlink.bc -o %t2.bc
-; RUN: llvm-lto2 run -disable-thinlto-funcattrs=0 \
+; RUN: llvm-lto2 run -thinlto-funcattrs \
; RUN: %t1.bc %t2.bc -o %t.o \
; RUN: -r %t1.bc,caller,l -r %t1.bc,caller_noattr,l -r %t1.bc,importer,px -r %t1.bc,importer_noattr,px \
; RUN: -r %t2.bc,caller,px -r %t2.bc,caller_noattr,px \
diff --git a/llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll b/llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll
index 5475ca1bf1d44a..692843a24af048 100644
--- a/llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll
+++ b/llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll
@@ -2,7 +2,7 @@
; RUN: split-file %s %t
; RUN: opt -thinlto-bc %t/main.ll -thin-link-bitcode-file=%t1.thinlink.bc -o %t1.bc
; RUN: opt -thinlto-bc %t/callees.ll -thin-link-bitcode-file=%t2.thinlink.bc -o %t2.bc
-; RUN: llvm-lto2 run -disable-thinlto-funcattrs=0 %t1.bc %t2.bc -o %t.o -r %t1.bc,caller,px -r %t1.bc,caller1,px -r %t1.bc,caller2,px -r %t1.bc,caller_nounwind,px \
+; RUN: llvm-lto2 run -thinlto-funcattrs %t1.bc %t2.bc -o %t.o -r %t1.bc,caller,px -r %t1.bc,caller1,px -r %t1.bc,caller2,px -r %t1.bc,caller_nounwind,px \
; RUN: -r %t1.bc,cleanupret,l -r %t1.bc,catchret,l -r %t1.bc,resume,l -r %t1.bc,cleanupret_nounwind,l \
; RUN: -r %t2.bc,cleanupret,px -r %t2.bc,catchret,px -r %t2.bc,resume,px -r %t2.bc,cleanupret_nounwind,px -r %t2.bc,nonThrowing,px -r %t2.bc,__gxx_personality_v0,px -save-temps
; RUN: llvm-dis -o - %t2.bc | FileCheck %s --check-prefix=SUMMARY
diff --git a/llvm/test/ThinLTO/X86/funcattrs-prop-undefined.ll b/llvm/test/ThinLTO/X86/funcattrs-prop-undefined.ll
index 3f33d5e1a24a0e..fd156584b7dce9 100644
--- a/llvm/test/ThinLTO/X86/funcattrs-prop-undefined.ll
+++ b/llvm/test/ThinLTO/X86/funcattrs-prop-undefined.ll
@@ -2,7 +2,7 @@
; RUN: split-file %s %t
; RUN: opt -thinlto-bc %t/main.ll -thin-link-bitcode-file=%t1.thinlink.bc -o %t1.bc
; RUN: opt -thinlto-bc %t/callees.ll -thin-link-bitcode-file=%t2.thinlink.bc -o %t2.bc
-; RUN: llvm-lto2 run -disable-thinlto-funcattrs=0 %t1.bc %t2.bc -o %t.o -r %t1.bc,caller,px -r %t1.bc,callee,l -r %t1.bc,callee1,l -r %t2.bc,callee,px -save-temps
+; RUN: llvm-lto2 run -thinlto-funcattrs %t1.bc %t2.bc -o %t.o -r %t1.bc,caller,px -r %t1.bc,callee,l -r %t1.bc,callee1,l -r %t2.bc,callee,px -save-temps
; RUN: llvm-dis -o - %t.o.1.3.import.bc | FileCheck %s
;--- main.ll
diff --git a/llvm/test/ThinLTO/X86/funcattrs-prop-unknown.ll b/llvm/test/ThinLTO/X86/funcattrs-prop-unknown.ll
index e63f18bc87213f..cdf154677e923c 100644
--- a/llvm/test/ThinLTO/X86/funcattrs-prop-unknown.ll
+++ b/llvm/test/ThinLTO/X86/funcattrs-prop-unknown.ll
@@ -1,6 +1,6 @@
; Unknown (e.g. indirect) calls returns conservative results from function propagation
; RUN: opt -thinlto-bc %s -thin-link-bitcode-file=%t1.thinlink.bc -o %t1.bc
-; RUN: llvm-lto2 run -disable-thinlto-funcattrs=0 %t1.bc -o %t.o -save-temps \
+; RUN: llvm-lto2 run -thinlto-funcattrs %t1.bc -o %t.o -save-temps \
; RUN: -r %t1.bc,indirect,px -r %t1.bc,inlineasm,px -r %t1.bc,selectcallee,px -r %t1.bc,f, -r %t1.bc,g, -r %t1.bc,global,
; RUN: llvm-dis -o - %t.o.1.3.import.bc | FileCheck %s
diff --git a/llvm/test/ThinLTO/X86/funcattrs-prop-weak.ll b/llvm/test/ThinLTO/X86/funcattrs-prop-weak.ll
index 6f5b7787e601d1..551ce2398bc816 100644
--- a/llvm/test/ThinLTO/X86/funcattrs-prop-weak.ll
+++ b/llvm/test/ThinLTO/X86/funcattrs-prop-weak.ll
@@ -4,7 +4,7 @@
; RUN: opt -thinlto-bc %t/c.ll -thin-link-bitcode-file=%t1.thinlink.bc -o %t3.bc
; If the prevailing weak symbol is defined in a native file, the IR copies should be dead and propagation should not occur
-; RUN: llvm-lto2 run -disable-thinlto-funcattrs=0 %t1.bc %t2.bc %t3.bc -o %t.o \
+; RUN: llvm-lto2 run -thinlto-funcattrs %t1.bc %t2.bc %t3.bc -o %t.o \
; RUN: -r %t1.bc,caller,px -r %t1.bc,callee,lx \
; RUN: -r %t2.bc,callee,x \
; RUN: -r %t3.bc,callee,x \
@@ -14,7 +14,7 @@
; If the prevailing weak symbol is in an IR file, it should be the one used in the final binary and thus propagation
; should be based off of that copy
-; RUN: llvm-lto2 run -O3 -disable-thinlto-funcattrs=0 %t1.bc %t2.bc %t3.bc -o %t.2.o \
+; RUN: llvm-lto2 run -O3 -thinlto-funcattrs %t1.bc %t2.bc %t3.bc -o %t.2.o \
; RUN: -r %t1.bc,caller,px -r %t1.bc,callee,lx \
; RUN: -r %t2.bc,callee,px \
; RUN: -r %t3.bc,callee,x \
diff --git a/llvm/test/ThinLTO/X86/funcattrs-prop.ll b/llvm/test/ThinLTO/X86/funcattrs-prop.ll
index ddf15d3ede9409..7a564c25ee9733 100644
--- a/llvm/test/ThinLTO/X86/funcattrs-prop.ll
+++ b/llvm/test/ThinLTO/X86/funcattrs-prop.ll
@@ -5,7 +5,7 @@
;; ThinLTO Function attribute propagation uses the prevailing symbol to propagate attributes to its callers.
;; Interposable (linkonce and weak) linkages are fair game given we know the prevailing copy will be used in the final binary.
-; RUN: llvm-lto2 run -disable-thinlto-funcattrs=0 %t/a.bc %t/b.bc %t/c.bc -o %t1 -save-temps \
+; RUN: llvm-lto2 run -thinlto-funcattrs %t/a.bc %t/b.bc %t/c.bc -o %t1 -save-temps \
; RUN: -r=%t/a.bc,call_extern,plx -r=%t/a.bc,call_linkonceodr,plx -r=%t/a.bc,call_weakodr,plx -r=%t/a.bc,call_linkonce,plx -r=%t/a.bc,call_weak,plx -r=%t/a.bc,call_linkonce_may_unwind,plx -r=%t/a.bc,call_weak_may_unwind,plx \
; RUN: -r=%t/a.bc,extern, -r=%t/a.bc,linkonceodr, -r=%t/a.bc,weakodr, -r=%t/a.bc,linkonce, -r=%t/a.bc,weak, -r=%t/a.bc,linkonce_may_unwind, -r=%t/a.bc,weak_may_unwind, \
; RUN: -r=%t/b.bc,extern,p -r=%t/b.bc,linkonceodr,p -r=%t/b.bc,weakodr,p -r=%t/b.bc,linkonce,p -r=%t/b.bc,weak,p -r=%t/b.bc,linkonce_may_unwind,p -r=%t/b.bc,weak_may_unwind, \
diff --git a/llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll b/llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll
index 431e2a9254887e..42d2cb77a3d176 100644
--- a/llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll
+++ b/llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll
@@ -1,7 +1,7 @@
; RUN: opt -module-summary %s -o %t1.bc
; RUN: opt -module-summary %p/Inputs/funcimport_alwaysinline.ll -o %t2.bc
-; RUN: llvm-lto2 run -disable-thinlto-funcattrs=0 %t1.bc %t2.bc -o %t.o -save-temps \
+; RUN: llvm-lto2 run -thinlto-funcattrs %t1.bc %t2.bc -o %t.o -save-temps \
; RUN: -r=%t1.bc,foo,plx \
; RUN: -r=%t2.bc,main,plx \
; RUN: -r=%t2.bc,foo,l \
diff --git a/llvm/test/ThinLTO/X86/linkonce_resolution_comdat.ll b/llvm/test/ThinLTO/X86/linkonce_resolution_comdat.ll
index 6e6c97538535cc..1851f715a42883 100644
--- a/llvm/test/ThinLTO/X86/linkonce_resolution_comdat.ll
+++ b/llvm/test/ThinLTO/X86/linkonce_resolution_comdat.ll
@@ -4,7 +4,7 @@
; as well since it is in the same comdat of g.
; RUN: opt -module-summary %s -o %t1.bc
; RUN: opt -module-summary %p/Inputs/linkonce_resolution_comdat.ll -o %t2.bc
-; RUN: llvm-lto -thinlto-action=run -disable-thinlto-funcattrs=0 %t1.bc %t2.bc -exported-symbol=f -exported-symbol=g -exported-symbol=h -thinlto-save-temps=%t3.
+; RUN: llvm-lto -thinlto-action=run -thinlto-funcattrs %t1.bc %t2.bc -exported-symbol=f -exported-symbol=g -exported-symbol=h -thinlto-save-temps=%t3.
; RUN: llvm-dis %t3.0.3.imported.bc -o - | FileCheck %s --check-prefix=IMPORT1
; RUN: llvm-dis %t3.1.3.imported.bc -o - | FileCheck %s --check-prefix=IMPORT2
diff --git a/llvm/tools/opt/optdriver.cpp b/llvm/tools/opt/optdriver.cpp
index df2d34be1d9b3d..7bb9a8a72c150a 100644
--- a/llvm/tools/opt/optdriver.cpp
+++ b/llvm/tools/opt/optdriver.cpp
@@ -652,7 +652,8 @@ optMain(int argc, char **argv,
// Manually assign GUIDs -- updateVCallVisibilityInModule accesses GUIDs, and
// there's no way to specify it in the pass pipeline since this runs before
// any pass given on the command line.
- if (hasWholeProgramVisibility(/*WholeProgramVisibilityEnabledInLTO=*/false))
+ if (hasWholeProgramVisibility(Context.getLibraryOptions(),
+ /*WholeProgramVisibilityEnabledInLTO=*/false))
AssignGUIDPass::runOnModule(*M);
// Enable testing of whole program devirtualization on this module by invoking
>From f3fc428f55439ca3ed9b4cbabe8aa124e447d51a Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Tue, 24 Nov 2026 21:58:25 -0800
Subject: [PATCH 2/2] Loat fields get f suffix; New devirt_speculative.ll test
---
llvm/lib/Transforms/IPO/IPOOptions.td | 10 +++++-----
llvm/test/ThinLTO/X86/devirt_speculative.ll | 4 ++++
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/Transforms/IPO/IPOOptions.td b/llvm/lib/Transforms/IPO/IPOOptions.td
index 1c0f10c1776b0a..0e70eeeb6f5ca4 100644
--- a/llvm/lib/Transforms/IPO/IPOOptions.td
+++ b/llvm/lib/Transforms/IPO/IPOOptions.td
@@ -130,9 +130,9 @@ defm : BoolField<"force-import-all", "false",
defm : BoolField<"import-all-index", "false",
"Import all external functions in index">;
// FIXME: This multiplier was not really tuned up.
-defm : ValueField<"import-cold-multiplier", "float", "0",
+defm : ValueField<"import-cold-multiplier", "float", "0.0f",
"Multiply the `import-instr-limit` threshold for cold callsites">;
-defm : ValueField<"import-critical-multiplier", "float", "100.0",
+defm : ValueField<"import-critical-multiplier", "float", "100.0f",
"Multiply the `import-instr-limit` threshold for critical callsites">;
defm : ValueField<"import-cutoff", "int", "-1",
"Only import first N functions if N>=0">;
@@ -154,11 +154,11 @@ defm : EnumField<"import-declaration-for-indirect-calls-min-hotness", "CalleeInf
"unknown,cold,none,hot,critical",
["CalleeInfo::HotnessType::Unknown", "CalleeInfo::HotnessType::Cold", "CalleeInfo::HotnessType::None", "CalleeInfo::HotnessType::Hot", "CalleeInfo::HotnessType::Critical"],
"Minimum hotness of an indirect call edge for -import-declaration-for-indirect-calls to import a declaration of its target">;
-defm : ValueField<"import-hot-evolution-factor", "float", "1.0",
+defm : ValueField<"import-hot-evolution-factor", "float", "1.0f",
"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",
+defm : ValueField<"import-hot-multiplier", "float", "10.0f",
"Multiply the `import-instr-limit` threshold for hot callsites">;
-defm : ValueField<"import-instr-evolution-factor", "float", "0.7",
+defm : ValueField<"import-instr-evolution-factor", "float", "0.7f",
"As we import functions, multiply the `import-instr-limit` threshold by this factor before processing newly imported functions">;
defm : ValueField<"import-instr-limit", "unsigned", "100",
"Only import functions with less than N instructions">;
diff --git a/llvm/test/ThinLTO/X86/devirt_speculative.ll b/llvm/test/ThinLTO/X86/devirt_speculative.ll
index c097488a23e8d7..f2e9daa46eec1f 100644
--- a/llvm/test/ThinLTO/X86/devirt_speculative.ll
+++ b/llvm/test/ThinLTO/X86/devirt_speculative.ll
@@ -46,6 +46,10 @@
; RUN: -wholeprogramdevirt-read-summary=%t6.o.thinlto.bc -S %t6.o -o - \
; RUN: | FileCheck %s --check-prefix=DIST
+; Index based WPD, legacy ThinLTOCodeGenerator
+; RUN: llvm-lto -thinlto-action=run -devirtualize-speculatively %t6.o --thinlto-save-temps=%t8. --pass-remarks=. --exported-symbol=test --exported-symbol=_ZN1A1fEv --exported-symbol=_ZTV1A 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN: llvm-dis %t8.0.4.opt.bc -o - | FileCheck %s
+
; INDEX: wpdRes: (kind: speculative, singleImplName: "_ZN1A1fEv")
; DIST-LABEL: define i32 @test(
More information about the cfe-commits
mailing list