[PATCH] D109114: [GlobalDCE] Add a mode to VFE that replaces unused vtable slots with a trap function instead of a NULL pointer

Kuba (Brecka) Mracek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 2 11:30:26 PDT 2021


kubamracek added a comment.

> Maybe you can set the relative offset to 0 in this case? That way, the crashing PC will point to the vtable, which should make it easier to track down the source of any problems. This would also require no runtime support (so doesn't need to be behind a flag) and also saves a PLT slot if the trap function would be in another DSO.

Yes, that's certainly a feasible option, too. Although, may I ask what is it you don't like about the trap function approach? The patch as it is emits the trap function into the current translation unit, so I think it'll never be in another DSO, and if yes then wouldn't that be an invalid relocation again (and defeat the purpose of this change)?

I am asking because I think the implementation of the "set offset to 0" would be more complicated and more invasive -- the `F->replaceNonMetadataUsesWith()` step would then need to "walk up" the expression somehow and replace the outer "i32 trunc" with an "i32 0", which does not necessarily need to be the top-level entry in the array (the vtable structure for Swift classes is more complex than just a array of pointers).


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

https://reviews.llvm.org/D109114



More information about the llvm-commits mailing list