================
@@ -0,0 +1,49 @@
+#include "llvm/Transforms/IPO/DeadRTTIElimination.h"
+#include "llvm/ADT/Statistic.h"
+#include "llvm/IR/ModuleSummaryIndex.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/LibCXXABI.h"
+
+using namespace llvm;
+
+#define DEBUG_TYPE "dre"
+
+STATISTIC(NumDeadTypeInfo, "Number of dead type info global variable");
+
+void DeadRTTIElimIndex::run() {
+  if (!ABI)
+    return;
+
+  if (ExportSummary.typeIdCompatibleVtableMap().empty())
+    return;
+
+  DenseSet<StringRef> TypeIdSlotMayLiveVTables;
+
+  const auto &UsedTypeIds = ExportSummary.getTypeIdAccessed();
+  for (StringRef TypeId : UsedTypeIds) {
+    auto Info = ExportSummary.getTypeIdCompatibleVtableSummary(TypeId);
+
+    if (!Info.has_value())
+      continue;
+
+    for (auto CompatibleVTable : *Info)
+      TypeIdSlotMayLiveVTables.insert(CompatibleVTable.VTableVI.name());
+  }
----------------
mingmingl-llvm wrote:

As I understand it, a vtable's (call it `_ZTV3foo`) RTTI is preserved if any 
class that appears higher up in the inheritance tree relative to `_ZTV3foo` has 
its RTTI used by non vtables (e.g., captured by dynamic_cast 
https://gcc.godbolt.org/z/nq4dT385j).

Would you mind adding some comments here for this case and also a regression 
test?

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

Reply via email to