Skip to content

Commit 02df443

Browse files
author
serge-sans-paille
committed
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
1 parent 5ae6804 commit 02df443

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

llvm/include/llvm/Analysis/LazyCallGraph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ class LazyCallGraph {
419419
/// outer structure. SCCs do not support mutation of the call graph, that
420420
/// must be done through the containing \c RefSCC in order to fully reason
421421
/// about the ordering and connections of the graph.
422-
class SCC {
422+
class LLVM_EXTERNAL_VISIBILITY SCC {
423423
friend class LazyCallGraph;
424424
friend class LazyCallGraph::Node;
425425

llvm/include/llvm/Analysis/LoopInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ extern template class LoopBase<BasicBlock, Loop>;
527527

528528
/// Represents a single loop in the control flow graph. Note that not all SCCs
529529
/// in the CFG are necessarily loops.
530-
class Loop : public LoopBase<BasicBlock, Loop> {
530+
class LLVM_EXTERNAL_VISIBILITY Loop : public LoopBase<BasicBlock, Loop> {
531531
public:
532532
/// A range representing the start and end location of a loop.
533533
class LocRange {

llvm/include/llvm/Analysis/LoopNestAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ using LoopVectorTy = SmallVector<Loop *, 8>;
2525
class LPMUpdater;
2626

2727
/// This class represents a loop nest and can be used to query its properties.
28-
class LoopNest {
28+
class LLVM_EXTERNAL_VISIBILITY LoopNest {
2929
public:
3030
using InstrVectorTy = SmallVector<const Instruction *>;
3131

llvm/include/llvm/CodeGen/MachineFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ struct LandingPadInfo {
227227
: LandingPadBlock(MBB) {}
228228
};
229229

230-
class MachineFunction {
230+
class LLVM_EXTERNAL_VISIBILITY MachineFunction {
231231
Function &F;
232232
const LLVMTargetMachine &Target;
233233
const TargetSubtargetInfo *STI;

llvm/include/llvm/IR/Function.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class User;
5858
class BranchProbabilityInfo;
5959
class BlockFrequencyInfo;
6060

61-
class Function : public GlobalObject, public ilist_node<Function> {
61+
class LLVM_EXTERNAL_VISIBILITY Function : public GlobalObject,
62+
public ilist_node<Function> {
6263
public:
6364
using BasicBlockListType = SymbolTableList<BasicBlock>;
6465

llvm/include/llvm/IR/Module.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ class VersionTuple;
6464
/// constant references to global variables in the module. When a global
6565
/// variable is destroyed, it should have no entries in the GlobalValueRefMap.
6666
/// The main container class for the LLVM Intermediate Representation.
67-
class Module {
68-
/// @name Types And Enumerations
69-
/// @{
67+
class LLVM_EXTERNAL_VISIBILITY Module {
68+
/// @name Types And Enumerations
69+
/// @{
7070
public:
7171
/// The type for the list of global variables.
7272
using GlobalListType = SymbolTableList<GlobalVariable>;

0 commit comments

Comments
 (0)