[PATCH] D109252: Add extra check for llvm::Any::TypeId visibility

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 3 14:11:03 PDT 2021


MaskRay added a comment.

Use llvm-readelf instead. llvm-nm does not check visibility.
Also, weak objects use `[vV]` instead of `[wW]`.

  % llvm-readelf -sC /tmp/out/custom1/lib/libLLVM-14git.so | grep llvm::Any::TypeId
    1774: 000000000079add6     1 OBJECT  WEAK   DEFAULT    10 llvm::Any::TypeId<llvm::Loop const*>::Id@@LLVM_14
    2602: 000000000076dc84     1 OBJECT  WEAK   DEFAULT    10 llvm::Any::TypeId<llvm::MachineFunction const*>::Id@@LLVM_14
  ...
  % llvm-nm -C /tmp/out/custom1/lib/libLLVM-14git.so | grep llvm::Any::TypeId
  0000000000cbdb60 V llvm::Any::TypeId<llvm::PreservedAnalyses>::Id
  0000000000cbe4f4 V llvm::Any::TypeId<polly::Scop const*>::Id

If you use lit, check (a) `WEAK.*DEFAULT.* llvm::Any::TypeId<` has matches and (b)  `HIDDEN.* llvm::Any::TypeId<` doesn't have matches.
A test without positive pattern can easily go stale and unnoticed.



================
Comment at: llvm/tools/llvm-shlib/CMakeLists.txt:81
+      # This checks that no instanciation of llvm::Any::TypeId ends up with
+      # hidden visibility. This happens if llvm::Any is used with hidden types.
+      add_custom_target(
----------------
The comment should be extended to reference a URL with a very clear problem report.

A reader would be eager to know why 


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

https://reviews.llvm.org/D109252



More information about the llvm-commits mailing list