[clang] [llvm] [ThinLTO] Support dead RTTI data elimination under -fno-split-lto-unit (PR #126336)

Teresa Johnson via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 18 11:04:24 PST 2025


================
@@ -1920,6 +1924,18 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
       ThinLTO.CombinedIndex, WholeProgramVisibilityEnabledInLTO,
       DynamicExportSymbols, VisibleToRegularObjSymbols);
 
+  Triple TT(getTargetTriple());
+  DeadRTTIElimIndex(ThinLTO.CombinedIndex, TT).run();
+
+  if (!ThinLTO.CombinedIndex.withGlobalValueDeadStripping())
+    computeDeadSymbolsWithConstProp(ThinLTO.CombinedIndex, GUIDPreservedSymbols,
+                                    IsPrevailing, Conf.OptLevel > 0);
----------------
teresajohnson wrote:

Ah this is a good point. I compared the 2 lambdas and the info they surface has similar sources but there is a key difference in that the one used by dead symbol elim is a tri-state, and we specifically want to identify cases where we had a symbol but it is not prevailing *in the LTO unit*. The info used for the isPrevailing defined below will give the module with the prevailing def for things that the IsPrevailing you are passing down here would give an answer of Prevailing::Yes to. I think this IsPrevailing should probably be renamed to IsPrevailingInLTOUnit and the isPrevailing below to IsPrevailingInModule, or something like that. Don't worry about that for your patch, I'll try to do that separately.

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


More information about the cfe-commits mailing list