Fine grain control over some symbol visibility

Setting -fvisibility=hidden when compiling Target libs has the advantage of
not being intrusive on the codebase, but it also sets the visibility of all
functions within header-only component like ADT. In the end, we end up with
some symbols with hidden visibility within llvm dylib (through the target libs),
and some with external visibility (through other libs). This paves the way for
subtle bugs like https://reviews.llvm.org/D101972

This patch explicitly set the visibility of some classes to `default` so that
`llvm::Any` related symbols keep a `default` visibility. Indeed a template
function with `default` visibility parametrized by a type with `hidden`
visibility is granted `hidden` visibility, and we don't want this for the
uniqueness of `llvm::Any::TypeId`.

Differential Revision: https://reviews.llvm.org/D108943
This commit is contained in:
serge-sans-paille 2021-08-30 22:21:39 +02:00
parent 5ae6804d17
commit 02df443d28
6 changed files with 9 additions and 8 deletions

View file

@ -419,7 +419,7 @@ public:
/// outer structure. SCCs do not support mutation of the call graph, that
/// must be done through the containing \c RefSCC in order to fully reason
/// about the ordering and connections of the graph.
class SCC {
class LLVM_EXTERNAL_VISIBILITY SCC {
friend class LazyCallGraph;
friend class LazyCallGraph::Node;

View file

@ -527,7 +527,7 @@ extern template class LoopBase<BasicBlock, Loop>;
/// Represents a single loop in the control flow graph. Note that not all SCCs
/// in the CFG are necessarily loops.
class Loop : public LoopBase<BasicBlock, Loop> {
class LLVM_EXTERNAL_VISIBILITY Loop : public LoopBase<BasicBlock, Loop> {
public:
/// A range representing the start and end location of a loop.
class LocRange {

View file

@ -25,7 +25,7 @@ using LoopVectorTy = SmallVector<Loop *, 8>;
class LPMUpdater;
/// This class represents a loop nest and can be used to query its properties.
class LoopNest {
class LLVM_EXTERNAL_VISIBILITY LoopNest {
public:
using InstrVectorTy = SmallVector<const Instruction *>;

View file

@ -227,7 +227,7 @@ struct LandingPadInfo {
: LandingPadBlock(MBB) {}
};
class MachineFunction {
class LLVM_EXTERNAL_VISIBILITY MachineFunction {
Function &F;
const LLVMTargetMachine &Target;
const TargetSubtargetInfo *STI;

View file

@ -58,7 +58,8 @@ class User;
class BranchProbabilityInfo;
class BlockFrequencyInfo;
class Function : public GlobalObject, public ilist_node<Function> {
class LLVM_EXTERNAL_VISIBILITY Function : public GlobalObject,
public ilist_node<Function> {
public:
using BasicBlockListType = SymbolTableList<BasicBlock>;

View file

@ -64,9 +64,9 @@ class VersionTuple;
/// constant references to global variables in the module. When a global
/// variable is destroyed, it should have no entries in the GlobalValueRefMap.
/// The main container class for the LLVM Intermediate Representation.
class Module {
/// @name Types And Enumerations
/// @{
class LLVM_EXTERNAL_VISIBILITY Module {
/// @name Types And Enumerations
/// @{
public:
/// The type for the list of global variables.
using GlobalListType = SymbolTableList<GlobalVariable>;