[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 22:00:10 PST 2026


================
@@ -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)
----------------
MaskRay wrote:

 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.

https://github.com/llvm/llvm-project/pull/245301


More information about the cfe-commits mailing list