[PATCH] D155659: [WPD][LLD] Add option to validate RTTI is enabled on all native types and prevent devirtualization on types with native RTTI

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 6 20:39:51 PDT 2023


MaskRay added a comment.

In D155659#4640159 <https://reviews.llvm.org/D155659#4640159>, @modimo wrote:

> Gentle ping @MaskRay

Sorry for the delay. (There were Phabricator <https://discourse.llvm.org/t/phabricator-is-very-slow/73132/9?u=maskray> issues <https://discourse.llvm.org/t/reviews-llvm-org-read-only-mode/73289> to handle beside work...)

I will need to re-read https://discourse.llvm.org/t/rfc-safer-whole-program-class-hierarchy-analysis/65144 and an internal discussion in May 2022 when I was thinking about `_ZTI`.

`-frtti` is discouraged by https://google.github.io/styleguide/cppguide.html#Run-Time_Type_Information__RTTI_ , so I think it may not benefit us... but this feature is still useful. I need to read these discussions...



================
Comment at: lld/ELF/Driver.cpp:1030
+    if (name.consume_front("_ZTI")) {
+      typeInfoSymbols.insert(name);
+    } else if (name.consume_front("_ZTV")) {
----------------
omit braces for single-line single-statement body


================
Comment at: lld/ELF/Driver.cpp:1060
+    if (!typeInfoSymbols.count(s)) {
+      vtableSymbolsWithNoRTTI.insert(s);
+    }
----------------
drop the two nested braces


================
Comment at: lld/ELF/Driver.cpp:1064
+
+  // Remove known safe symbols
+  for (auto *arg : args.filtered(OPT_lto_known_safe_vtables)) {
----------------



================
Comment at: lld/ELF/Driver.cpp:1067
+    StringRef knownSafeName = arg->getValue();
+    knownSafeName.consume_front("_ZTV");
+    vtableSymbolsWithNoRTTI.erase(knownSafeName);
----------------
If not starting with `_ZTV`, consider reporting an error?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155659/new/

https://reviews.llvm.org/D155659



More information about the llvm-commits mailing list