================
@@ -338,12 +574,33 @@ PreservedAnalyses GlobalDCEPass::run(Module &M, 
ModuleAnalysisManager &MAM) {
 
   // The second pass drops the bodies of functions which are dead...
   std::vector<Function *> DeadFunctions;
-  for (Function &F : M)
+  std::set<Function *> DeadFunctionsSet;
+  auto funcRemovedInIndex = [&](Function *F) -> bool {
+    if (!ImportSummary)
+      return false;
+    auto &vfuncsRemoved = ImportSummary->funcsToBeRemoved();
+    // If function is internalized, its current GUID will be different
+    // from the GUID in funcsToBeRemoved. Treat it as a global and search
+    // again.
+    if (vfuncsRemoved.count(F->getGUID()))
+      return true;
+    if (vfuncsRemoved.count(GlobalValue::getGUID(F->getName())))
----------------
teresajohnson wrote:

These lookups are a little dangerous as I think there are cases where we might 
rename and it wouldn't find the right function. For internalization we tag the 
function with an attribute before any thinlto renaming, linkage changes, or 
other optimization passes. See 
https://github.com/llvm/llvm-project/blob/0936a718492d248a726b8e8d4529e4aa194bc8e9/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp#L271.

https://github.com/llvm/llvm-project/pull/69735
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to