clang 23.0.0git
CIRGenModule.h
Go to the documentation of this file.
1//===--- CIRGenModule.h - Per-Module state for CIR gen ----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This is the internal per-translation-unit state used for CIR translation.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENMODULE_H
14#define LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENMODULE_H
15
16#include "CIRGenBuilder.h"
17#include "CIRGenCall.h"
18#include "CIRGenTypeCache.h"
19#include "CIRGenTypes.h"
20#include "CIRGenVTables.h"
21#include "CIRGenValue.h"
22
23#include "clang/AST/CharUnits.h"
26
27#include "TargetInfo.h"
28#include "mlir/IR/Builders.h"
29#include "mlir/IR/BuiltinOps.h"
30#include "mlir/IR/MLIRContext.h"
31#include "clang/AST/Decl.h"
35#include "llvm/ADT/StringRef.h"
36#include "llvm/TargetParser/Triple.h"
37
38namespace clang {
39class ASTContext;
40class CodeGenOptions;
41class Decl;
42class GlobalDecl;
43class LangOptions;
44class TargetInfo;
45class VarDecl;
46
47namespace CIRGen {
48
49class CIRGenFunction;
50class CIRGenCXXABI;
51
52enum ForDefinition_t : bool { NotForDefinition = false, ForDefinition = true };
53
54/// This class organizes the cross-function state that is used while generating
55/// CIR code.
56class CIRGenModule : public CIRGenTypeCache {
57 CIRGenModule(CIRGenModule &) = delete;
58 CIRGenModule &operator=(CIRGenModule &) = delete;
59
60public:
61 CIRGenModule(mlir::MLIRContext &mlirContext, clang::ASTContext &astContext,
62 const clang::CodeGenOptions &cgo,
64
66
67private:
68 mutable std::unique_ptr<TargetCIRGenInfo> theTargetCIRGenInfo;
69
70 CIRGenBuilderTy builder;
71
72 /// Hold Clang AST information.
73 clang::ASTContext &astContext;
74
75 const clang::LangOptions &langOpts;
76
77 const clang::CodeGenOptions &codeGenOpts;
78
79 /// A "module" matches a c/cpp source file: containing a list of functions.
80 mlir::ModuleOp theModule;
81
83
84 const clang::TargetInfo &target;
85
86 std::unique_ptr<CIRGenCXXABI> abi;
87
88 CIRGenTypes genTypes;
89
90 /// Holds information about C++ vtables.
91 CIRGenVTables vtables;
92
93 /// Per-function codegen information. Updated everytime emitCIR is called
94 /// for FunctionDecls's.
95 CIRGenFunction *curCGF = nullptr;
96
98
99public:
100 mlir::ModuleOp getModule() const { return theModule; }
101 CIRGenBuilderTy &getBuilder() { return builder; }
102 clang::ASTContext &getASTContext() const { return astContext; }
103 const clang::TargetInfo &getTarget() const { return target; }
104 const clang::CodeGenOptions &getCodeGenOpts() const { return codeGenOpts; }
105 clang::DiagnosticsEngine &getDiags() const { return diags; }
106 CIRGenTypes &getTypes() { return genTypes; }
107 const clang::LangOptions &getLangOpts() const { return langOpts; }
108
109 CIRGenCXXABI &getCXXABI() const { return *abi; }
110 mlir::MLIRContext &getMLIRContext() { return *builder.getContext(); }
111
113 // FIXME(cir): instead of creating a CIRDataLayout every time, set it as an
114 // attribute for the CIRModule class.
115 return cir::CIRDataLayout(theModule);
116 }
117
118 /// -------
119 /// Handling globals
120 /// -------
121
122 mlir::Operation *lastGlobalOp = nullptr;
123
124 /// Keep a map between lambda fields and names, this needs to be per module
125 /// since lambdas might get generated later as part of defered work, and since
126 /// the pointers are supposed to be uniqued, should be fine. Revisit this if
127 /// it ends up taking too much memory.
128 llvm::DenseMap<const clang::FieldDecl *, llvm::StringRef> lambdaFieldToName;
129 /// Map BlockAddrInfoAttr (function name, label name) to the corresponding CIR
130 /// LabelOp. This provides the main lookup table used to resolve block
131 /// addresses into their label operations.
132 llvm::DenseMap<cir::BlockAddrInfoAttr, cir::LabelOp> blockAddressInfoToLabel;
133 /// Map CIR BlockAddressOps directly to their resolved LabelOps.
134 /// Used once a block address has been successfully lowered to a label.
135 llvm::MapVector<cir::BlockAddressOp, cir::LabelOp> blockAddressToLabel;
136 /// Track CIR BlockAddressOps that cannot be resolved immediately
137 /// because their LabelOp has not yet been emitted. These entries
138 /// are solved later once the corresponding label is available.
139 llvm::DenseSet<cir::BlockAddressOp> unresolvedBlockAddressToLabel;
140 cir::LabelOp lookupBlockAddressInfo(cir::BlockAddrInfoAttr blockInfo);
141 void mapBlockAddress(cir::BlockAddrInfoAttr blockInfo, cir::LabelOp label);
142 void mapUnresolvedBlockAddress(cir::BlockAddressOp op);
143 void mapResolvedBlockAddress(cir::BlockAddressOp op, cir::LabelOp);
144 void updateResolvedBlockAddress(cir::BlockAddressOp op,
145 cir::LabelOp newLabel);
146 /// Tell the consumer that this variable has been instantiated.
148
149 llvm::DenseMap<const Decl *, cir::GlobalOp> staticLocalDeclMap;
150 llvm::DenseMap<const VarDecl *, cir::GlobalOp> initializerConstants;
151
152 mlir::Operation *getGlobalValue(llvm::StringRef ref);
153
154 cir::GlobalOp getStaticLocalDeclAddress(const VarDecl *d) {
155 return staticLocalDeclMap[d];
156 }
157
158 void setStaticLocalDeclAddress(const VarDecl *d, cir::GlobalOp c) {
160 }
161
162 cir::GlobalOp getOrCreateStaticVarDecl(const VarDecl &d,
163 cir::GlobalLinkageKind linkage);
164
165 Address createUnnamedGlobalFrom(const VarDecl &d, mlir::Attribute constAttr,
166 CharUnits align);
167
168 /// If the specified mangled name is not in the module, create and return an
169 /// mlir::GlobalOp value
170 cir::GlobalOp getOrCreateCIRGlobal(llvm::StringRef mangledName, mlir::Type ty,
171 LangAS langAS, const VarDecl *d,
172 ForDefinition_t isForDefinition);
173
174 cir::GlobalOp getOrCreateCIRGlobal(const VarDecl *d, mlir::Type ty,
175 ForDefinition_t isForDefinition);
176
177 static cir::GlobalOp createGlobalOp(CIRGenModule &cgm, mlir::Location loc,
178 llvm::StringRef name, mlir::Type t,
179 bool isConstant = false,
180 mlir::Operation *insertPoint = nullptr);
181
182 /// Add a global constructor or destructor to the module.
183 /// The priority is optional, if not specified, the default priority is used.
184 void addGlobalCtor(cir::FuncOp ctor,
185 std::optional<int> priority = std::nullopt);
186 void addGlobalDtor(cir::FuncOp dtor,
187 std::optional<int> priority = std::nullopt);
188
190 // In C23 (N3096) $6.7.10:
191 // """
192 // If any object is initialized with an empty initializer, then it is
193 // subject to default initialization:
194 // - if it is an aggregate, every member is initialized (recursively)
195 // according to these rules, and any padding is initialized to zero bits;
196 // - if it is a union, the first named member is initialized (recursively)
197 // according to these rules, and any padding is initialized to zero bits.
198 //
199 // If the aggregate or union contains elements or members that are
200 // aggregates or unions, these rules apply recursively to the subaggregates
201 // or contained unions.
202 //
203 // If there are fewer initializers in a brace-enclosed list than there are
204 // elements or members of an aggregate, or fewer characters in a string
205 // literal used to initialize an array of known size than there are elements
206 // in the array, the remainder of the aggregate is subject to default
207 // initialization.
208 // """
209 //
210 // The standard seems ambiguous in the following two areas:
211 // 1. For a union type with empty initializer, if the first named member is
212 // not the largest member, then the bytes comes after the first named member
213 // but before padding are left unspecified. An example is:
214 // union U { int a; long long b;};
215 // union U u = {}; // The first 4 bytes are 0, but 4-8 bytes are left
216 // unspecified.
217 //
218 // 2. It only mentions padding for empty initializer, but doesn't mention
219 // padding for a non empty initialization list. And if the aggregation or
220 // union contains elements or members that are aggregates or unions, and
221 // some are non empty initializers, while others are empty initializers,
222 // the padding initialization is unclear. An example is:
223 // struct S1 { int a; long long b; };
224 // struct S2 { char c; struct S1 s1; };
225 // // The values for paddings between s2.c and s2.s1.a, between s2.s1.a
226 // and s2.s1.b are unclear.
227 // struct S2 s2 = { 'c' };
228 //
229 // Here we choose to zero initiailize left bytes of a union type because
230 // projects like the Linux kernel are relying on this behavior. If we don't
231 // explicitly zero initialize them, the undef values can be optimized to
232 // return garbage data. We also choose to zero initialize paddings for
233 // aggregates and unions, no matter they are initialized by empty
234 // initializers or non empty initializers. This can provide a consistent
235 // behavior. So projects like the Linux kernel can rely on it.
236 return !getLangOpts().CPlusPlus;
237 }
238
239 llvm::StringMap<unsigned> cgGlobalNames;
240 std::string getUniqueGlobalName(const std::string &baseName);
241
242 /// Return the mlir::Value for the address of the given global variable.
243 /// If Ty is non-null and if the global doesn't exist, then it will be created
244 /// with the specified type instead of whatever the normal requested type
245 /// would be. If IsForDefinition is true, it is guaranteed that an actual
246 /// global with type Ty will be returned, not conversion of a variable with
247 /// the same mangled name but some other type.
248 mlir::Value
249 getAddrOfGlobalVar(const VarDecl *d, mlir::Type ty = {},
250 ForDefinition_t isForDefinition = NotForDefinition);
251
252 /// Return the mlir::GlobalViewAttr for the address of the given global.
253 cir::GlobalViewAttr getAddrOfGlobalVarAttr(const VarDecl *d);
254
256 const CXXRecordDecl *derivedClass,
257 llvm::iterator_range<CastExpr::path_const_iterator> path);
258
259 /// Get the CIR attributes and calling convention to use for a particular
260 /// function type.
261 ///
262 /// \param name - The function name.
263 /// \param info - The function type information.
264 /// \param calleeInfo - The callee information these attributes are being
265 /// constructed for. If valid, the attributes applied to this decl may
266 /// contribute to the function attributes and calling convention.
267 /// \param attrs [out] - On return, the attribute list to use.
268 /// \param callingConv [out] - On return, the calling convention to use.
269 /// \param sideEffect [out] - On return, the side effect type of the
270 /// attributes.
271 /// \param attrOnCallSite - Whether or not the attributes are on a call site.
272 /// \param isThunk - Whether the function is a thunk.
273 void constructAttributeList(llvm::StringRef name,
274 const CIRGenFunctionInfo &info,
275 CIRGenCalleeInfo calleeInfo,
276 mlir::NamedAttrList &attrs,
277 cir::CallingConv &callingConv,
278 cir::SideEffect &sideEffect, bool attrOnCallSite,
279 bool isThunk);
280
281 /// Will return a global variable of the given type. If a variable with a
282 /// different type already exists then a new variable with the right type
283 /// will be created and all uses of the old variable will be replaced with a
284 /// bitcast to the new variable.
286 mlir::Location loc, llvm::StringRef name, mlir::Type ty,
287 cir::GlobalLinkageKind linkage, clang::CharUnits alignment);
288
289 void emitVTable(const CXXRecordDecl *rd);
290
291 /// Return the appropriate linkage for the vtable, VTT, and type information
292 /// of the given class.
293 cir::GlobalLinkageKind getVTableLinkage(const CXXRecordDecl *rd);
294
295 /// Get the address of the RTTI descriptor for the given type.
296 mlir::Attribute getAddrOfRTTIDescriptor(mlir::Location loc, QualType ty,
297 bool forEH = false);
298
299 static mlir::SymbolTable::Visibility getMLIRVisibility(Visibility v) {
300 switch (v) {
302 return mlir::SymbolTable::Visibility::Public;
303 case HiddenVisibility:
304 return mlir::SymbolTable::Visibility::Private;
306 // The distinction between ProtectedVisibility and DefaultVisibility is
307 // that symbols with ProtectedVisibility, while visible to the dynamic
308 // linker like DefaultVisibility, are guaranteed to always dynamically
309 // resolve to a symbol in the current shared object. There is currently no
310 // equivalent MLIR visibility, so we fall back on the fact that the symbol
311 // is visible.
312 return mlir::SymbolTable::Visibility::Public;
313 }
314 llvm_unreachable("unknown visibility!");
315 }
316
317 llvm::DenseMap<mlir::Attribute, cir::GlobalOp> constantStringMap;
318
319 /// Return a constant array for the given string.
320 mlir::Attribute getConstantArrayFromStringLiteral(const StringLiteral *e);
321
322 /// Return a global symbol reference to a constant array for the given string
323 /// literal.
324 cir::GlobalOp getGlobalForStringLiteral(const StringLiteral *s,
325 llvm::StringRef name = ".str");
326
327 /// Return a global symbol reference to a constant array for the given string
328 /// literal.
329 cir::GlobalViewAttr
331 llvm::StringRef name = ".str");
332
333 /// Returns the address space for temporary allocations in the language. This
334 /// ensures that the allocated variable's address space matches the
335 /// expectations of the AST, rather than using the target's allocation address
336 /// space, which may lead to type mismatches in other parts of the IR.
338
339 /// Set attributes which are common to any form of a global definition (alias,
340 /// Objective-C method, function, global variable).
341 ///
342 /// NOTE: This should only be called for definitions.
343 void setCommonAttributes(GlobalDecl gd, mlir::Operation *op);
344
346
347 /// Helpers to convert the presumed location of Clang's SourceLocation to an
348 /// MLIR Location.
349 mlir::Location getLoc(clang::SourceLocation cLoc);
350 mlir::Location getLoc(clang::SourceRange cRange);
351
352 /// Return the best known alignment for an unknown pointer to a
353 /// particular class.
355
356 /// FIXME: this could likely be a common helper and not necessarily related
357 /// with codegen.
359 LValueBaseInfo *baseInfo);
360
361 /// TODO: Add TBAAAccessInfo
363 const CXXRecordDecl *baseDecl,
364 CharUnits expectedTargetAlign);
365
366 /// Returns the assumed alignment of a virtual base of a class.
368 const CXXRecordDecl *derived,
369 const CXXRecordDecl *vbase);
370
371 cir::FuncOp
373 const CIRGenFunctionInfo *fnInfo = nullptr,
374 cir::FuncType fnType = nullptr, bool dontDefer = false,
375 ForDefinition_t isForDefinition = NotForDefinition) {
376 return getAddrAndTypeOfCXXStructor(gd, fnInfo, fnType, dontDefer,
377 isForDefinition)
378 .second;
379 }
380
381 std::pair<cir::FuncType, cir::FuncOp> getAddrAndTypeOfCXXStructor(
382 clang::GlobalDecl gd, const CIRGenFunctionInfo *fnInfo = nullptr,
383 cir::FuncType fnType = nullptr, bool dontDefer = false,
384 ForDefinition_t isForDefinition = NotForDefinition);
385
386 mlir::Type getVTableComponentType();
387 CIRGenVTables &getVTables() { return vtables; }
388
390 return vtables.getItaniumVTableContext();
391 }
393 return vtables.getItaniumVTableContext();
394 }
395
396 /// This contains all the decls which have definitions but which are deferred
397 /// for emission and therefore should only be output if they are actually
398 /// used. If a decl is in this, then it is known to have not been referenced
399 /// yet.
400 std::map<llvm::StringRef, clang::GlobalDecl> deferredDecls;
401
402 // This is a list of deferred decls which we have seen that *are* actually
403 // referenced. These get code generated when the module is done.
404 std::vector<clang::GlobalDecl> deferredDeclsToEmit;
406 deferredDeclsToEmit.emplace_back(GD);
407 }
408
410
411 /// Determine whether the definition must be emitted; if this returns \c
412 /// false, the definition can be emitted lazily if it's used.
413 bool mustBeEmitted(const clang::ValueDecl *d);
414
415 /// Determine whether the definition can be emitted eagerly, or should be
416 /// delayed until the end of the translation unit. This is relevant for
417 /// definitions whose linkage can change, e.g. implicit function
418 /// instantiations which may later be explicitly instantiated.
420
421 bool verifyModule() const;
422
423 /// Return the address of the given function. If funcType is non-null, then
424 /// this function will use the specified type if it has to create it.
425 // TODO: this is a bit weird as `GetAddr` given we give back a FuncOp?
426 cir::FuncOp
427 getAddrOfFunction(clang::GlobalDecl gd, mlir::Type funcType = nullptr,
428 bool forVTable = false, bool dontDefer = false,
429 ForDefinition_t isForDefinition = NotForDefinition);
430
431 mlir::Operation *
433 ForDefinition_t isForDefinition = NotForDefinition);
434
435 // Return whether RTTI information should be emitted for this target.
436 bool shouldEmitRTTI(bool forEH = false) {
437 return (forEH || getLangOpts().RTTI) && !getLangOpts().CUDAIsDevice &&
438 !(getLangOpts().OpenMP && getLangOpts().OpenMPIsTargetDevice &&
439 getTriple().isNVPTX());
440 }
441
442 /// Emit type info if type of an expression is a variably modified
443 /// type. Also emit proper debug info for cast types.
445 CIRGenFunction *cgf = nullptr);
446
447 /// Emit code for a single global function or variable declaration. Forward
448 /// declarations are emitted lazily.
450
451 void emitAliasForGlobal(llvm::StringRef mangledName, mlir::Operation *op,
452 GlobalDecl aliasGD, cir::FuncOp aliasee,
453 cir::GlobalLinkageKind linkage);
454
455 mlir::Type convertType(clang::QualType type);
456
457 /// Set the visibility for the given global.
458 void setGlobalVisibility(mlir::Operation *op, const NamedDecl *d) const;
459 void setDSOLocal(mlir::Operation *op) const;
460 void setDSOLocal(cir::CIRGlobalValueInterface gv) const;
461
462 /// Set visibility, dllimport/dllexport and dso_local.
463 /// This must be called after dllimport/dllexport is set.
464 void setGVProperties(mlir::Operation *op, const NamedDecl *d) const;
465 void setGVPropertiesAux(mlir::Operation *op, const NamedDecl *d) const;
466
467 /// Set TLS mode for the given operation based on the given variable
468 /// declaration.
469 void setTLSMode(mlir::Operation *op, const VarDecl &d);
470
471 /// Get TLS mode from CodeGenOptions.
472 cir::TLS_Model getDefaultCIRTLSModel() const;
473
474 /// Set function attributes for a function declaration.
475 void setFunctionAttributes(GlobalDecl gd, cir::FuncOp f,
476 bool isIncompleteFunction, bool isThunk);
477
478 /// Set the CIR function attributes (Sext, zext, etc).
480 cir::FuncOp func, bool isThunk);
481
482 /// Set extra attributes (inline, etc.) for a function.
484 cir::FuncOp f);
485
487 mlir::Operation *op = nullptr);
488 void emitGlobalFunctionDefinition(clang::GlobalDecl gd, mlir::Operation *op);
490 bool isTentative = false);
491
492 /// Emit the function that initializes the specified global
493 void emitCXXGlobalVarDeclInit(const VarDecl *varDecl, cir::GlobalOp addr,
494 bool performInit);
495
496 void emitCXXGlobalVarDeclInitFunc(const VarDecl *vd, cir::GlobalOp addr,
497 bool performInit);
498
502 template <typename BeforeOpTy, typename DataClauseTy>
503 void emitGlobalOpenACCDeclareDataOperands(const Expr *varOperand,
504 DataClauseTy dataClause,
505 OpenACCModifierKind modifiers,
506 bool structured, bool implicit,
507 bool requiresDtor);
508 // Each of the acc.routine operations must have a unique name, so we just use
509 // an integer counter. This is how Flang does it, so it seems reasonable.
510 unsigned routineCounter = 0;
511 void emitOpenACCRoutineDecl(const clang::FunctionDecl *funcDecl,
512 cir::FuncOp func, SourceLocation pragmaLoc,
514
522
523 // C++ related functions.
524 void emitDeclContext(const DeclContext *dc);
525
526 /// Return the result of value-initializing the given type, i.e. a null
527 /// expression of the given type.
528 mlir::Value emitNullConstant(QualType t, mlir::Location loc);
529
530 mlir::TypedAttr emitNullConstantAttr(QualType t);
531
532 /// Return a null constant appropriate for zero-initializing a base class with
533 /// the given type. This is usually, but not always, an LLVM null constant.
534 mlir::TypedAttr emitNullConstantForBase(const CXXRecordDecl *record);
535
536 mlir::Value emitMemberPointerConstant(const UnaryOperator *e);
537
538 llvm::StringRef getMangledName(clang::GlobalDecl gd);
539 // This function is to support the OpenACC 'bind' clause, which names an
540 // alternate name for the function to be called by. This function mangles
541 // `attachedFunction` as-if its name was actually `bindName` (that is, with
542 // the same signature). It has some additional complications, as the 'bind'
543 // target is always going to be a global function, so member functions need an
544 // explicit instead of implicit 'this' parameter, and thus gets mangled
545 // differently.
546 std::string getOpenACCBindMangledName(const IdentifierInfo *bindName,
547 const FunctionDecl *attachedFunction);
548
549 void emitTentativeDefinition(const VarDecl *d);
550
551 // Make sure that this type is translated.
552 void updateCompletedType(const clang::TagDecl *td);
553
554 // Produce code for this constructor/destructor. This method doesn't try to
555 // apply any ABI rules about which other constructors/destructors are needed
556 // or if they are alias to each other.
558
559 bool supportsCOMDAT() const;
560 void maybeSetTrivialComdat(const clang::Decl &d, mlir::Operation *op);
561
562 static void setInitializer(cir::GlobalOp &op, mlir::Attribute value);
563
564 void replaceUsesOfNonProtoTypeWithRealFunction(mlir::Operation *old,
565 cir::FuncOp newFn);
566
567 cir::FuncOp
568 getOrCreateCIRFunction(llvm::StringRef mangledName, mlir::Type funcType,
569 clang::GlobalDecl gd, bool forVTable,
570 bool dontDefer = false, bool isThunk = false,
571 ForDefinition_t isForDefinition = NotForDefinition,
572 mlir::ArrayAttr extraAttrs = {});
573
574 cir::FuncOp createCIRFunction(mlir::Location loc, llvm::StringRef name,
575 cir::FuncType funcType,
576 const clang::FunctionDecl *funcDecl);
577
578 /// Create a CIR function with builtin attribute set.
579 cir::FuncOp createCIRBuiltinFunction(mlir::Location loc, llvm::StringRef name,
580 cir::FuncType ty,
581 const clang::FunctionDecl *fd);
582
583 /// Mark the function as a special member (e.g. constructor, destructor)
584 void setCXXSpecialMemberAttr(cir::FuncOp funcOp,
585 const clang::FunctionDecl *funcDecl);
586
587 cir::FuncOp createRuntimeFunction(cir::FuncType ty, llvm::StringRef name,
588 mlir::ArrayAttr = {}, bool isLocal = false,
589 bool assumeConvergent = false);
590
591 static constexpr const char *builtinCoroId = "__builtin_coro_id";
592 static constexpr const char *builtinCoroAlloc = "__builtin_coro_alloc";
593 static constexpr const char *builtinCoroBegin = "__builtin_coro_begin";
594 static constexpr const char *builtinCoroEnd = "__builtin_coro_end";
595
596 /// Given a builtin id for a function like "__builtin_fabsf", return a
597 /// Function* for "fabsf".
598 cir::FuncOp getBuiltinLibFunction(const FunctionDecl *fd, unsigned builtinID);
599
600 mlir::IntegerAttr getSize(CharUnits size) {
601 return builder.getSizeFromCharUnits(size);
602 }
603
604 /// Emit any needed decls for which code generation was deferred.
605 void emitDeferred();
606
607 /// Helper for `emitDeferred` to apply actual codegen.
608 void emitGlobalDecl(const clang::GlobalDecl &d);
609
610 const llvm::Triple &getTriple() const { return target.getTriple(); }
611
612 // Finalize CIR code generation.
613 void release();
614
615 /// -------
616 /// Visibility and Linkage
617 /// -------
618
619 static mlir::SymbolTable::Visibility
620 getMLIRVisibilityFromCIRLinkage(cir::GlobalLinkageKind GLK);
621 static cir::VisibilityKind getGlobalVisibilityKindFromClangVisibility(
622 clang::VisibilityAttr::VisibilityType visibility);
623 cir::VisibilityAttr getGlobalVisibilityAttrFromDecl(const Decl *decl);
624 cir::GlobalLinkageKind getFunctionLinkage(GlobalDecl gd);
625 static mlir::SymbolTable::Visibility getMLIRVisibility(cir::GlobalOp op);
626 cir::GlobalLinkageKind getCIRLinkageForDeclarator(const DeclaratorDecl *dd,
627 GVALinkage linkage,
628 bool isConstantVariable);
629 void setFunctionLinkage(GlobalDecl gd, cir::FuncOp f) {
630 cir::GlobalLinkageKind l = getFunctionLinkage(gd);
631 f.setLinkageAttr(cir::GlobalLinkageKindAttr::get(&getMLIRContext(), l));
632 mlir::SymbolTable::setSymbolVisibility(f,
634 }
635
636 cir::GlobalLinkageKind getCIRLinkageVarDefinition(const VarDecl *vd,
637 bool isConstant);
638
639 void addReplacement(llvm::StringRef name, mlir::Operation *op);
640
641 /// Helpers to emit "not yet implemented" error diagnostics
642 DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef);
643
644 template <typename T>
645 DiagnosticBuilder errorNYI(SourceLocation loc, llvm::StringRef feature,
646 const T &name) {
647 unsigned diagID =
648 diags.getCustomDiagID(DiagnosticsEngine::Error,
649 "ClangIR code gen Not Yet Implemented: %0: %1");
650 return diags.Report(loc, diagID) << feature << name;
651 }
652
653 DiagnosticBuilder errorNYI(mlir::Location loc, llvm::StringRef feature) {
654 // TODO: Convert the location to a SourceLocation
655 unsigned diagID = diags.getCustomDiagID(
656 DiagnosticsEngine::Error, "ClangIR code gen Not Yet Implemented: %0");
657 return diags.Report(diagID) << feature;
658 }
659
660 DiagnosticBuilder errorNYI(llvm::StringRef feature) const {
661 // TODO: Make a default location? currSrcLoc?
662 unsigned diagID = diags.getCustomDiagID(
663 DiagnosticsEngine::Error, "ClangIR code gen Not Yet Implemented: %0");
664 return diags.Report(diagID) << feature;
665 }
666
667 DiagnosticBuilder errorNYI(SourceRange, llvm::StringRef);
668
669 template <typename T>
670 DiagnosticBuilder errorNYI(SourceRange loc, llvm::StringRef feature,
671 const T &name) {
672 return errorNYI(loc.getBegin(), feature, name) << loc;
673 }
674
675 /// Emit a general error that something can't be done.
676 void error(SourceLocation loc, llvm::StringRef error);
677
678 /// Print out an error that codegen doesn't support the specified stmt yet.
679 void errorUnsupported(const Stmt *s, llvm::StringRef type);
680
681 /// Print out an error that codegen doesn't support the specified decl yet.
682 void errorUnsupported(const Decl *d, llvm::StringRef type);
683
684private:
685 // An ordered map of canonical GlobalDecls to their mangled names.
686 llvm::MapVector<clang::GlobalDecl, llvm::StringRef> mangledDeclNames;
687 llvm::StringMap<clang::GlobalDecl, llvm::BumpPtrAllocator> manglings;
688
689 // FIXME: should we use llvm::TrackingVH<mlir::Operation> here?
690 typedef llvm::StringMap<mlir::Operation *> ReplacementsTy;
691 ReplacementsTy replacements;
692 /// Call replaceAllUsesWith on all pairs in replacements.
693 void applyReplacements();
694
695 /// A helper function to replace all uses of OldF to NewF that replace
696 /// the type of pointer arguments. This is not needed to tradtional
697 /// pipeline since LLVM has opaque pointers but CIR not.
698 void replacePointerTypeArgs(cir::FuncOp oldF, cir::FuncOp newF);
699
700 void setNonAliasAttributes(GlobalDecl gd, mlir::Operation *op);
701
702 /// Map source language used to a CIR attribute.
703 std::optional<cir::SourceLanguage> getCIRSourceLanguage() const;
704};
705} // namespace CIRGen
706
707} // namespace clang
708
709#endif // LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENMODULE_H
Defines the SourceManager interface.
__device__ __2f16 float __ockl_bool s
__device__ __2f16 float c
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:220
Implements C++ ABI-specific code generation functions.
Abstract information about a function or function prototype.
Definition CIRGenCall.h:27
void updateResolvedBlockAddress(cir::BlockAddressOp op, cir::LabelOp newLabel)
void emitCXXGlobalVarDeclInit(const VarDecl *varDecl, cir::GlobalOp addr, bool performInit)
Emit the function that initializes the specified global.
void replaceUsesOfNonProtoTypeWithRealFunction(mlir::Operation *old, cir::FuncOp newFn)
This function is called when we implement a function with no prototype, e.g.
llvm::StringRef getMangledName(clang::GlobalDecl gd)
cir::GlobalOp getOrCreateStaticVarDecl(const VarDecl &d, cir::GlobalLinkageKind linkage)
CharUnits computeNonVirtualBaseClassOffset(const CXXRecordDecl *derivedClass, llvm::iterator_range< CastExpr::path_const_iterator > path)
void setGlobalVisibility(mlir::Operation *op, const NamedDecl *d) const
Set the visibility for the given global.
DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef)
Helpers to emit "not yet implemented" error diagnostics.
void emitDeferred()
Emit any needed decls for which code generation was deferred.
clang::ASTContext & getASTContext() const
cir::FuncOp getAddrOfCXXStructor(clang::GlobalDecl gd, const CIRGenFunctionInfo *fnInfo=nullptr, cir::FuncType fnType=nullptr, bool dontDefer=false, ForDefinition_t isForDefinition=NotForDefinition)
cir::FuncOp createRuntimeFunction(cir::FuncType ty, llvm::StringRef name, mlir::ArrayAttr={}, bool isLocal=false, bool assumeConvergent=false)
llvm::DenseMap< cir::BlockAddrInfoAttr, cir::LabelOp > blockAddressInfoToLabel
Map BlockAddrInfoAttr (function name, label name) to the corresponding CIR LabelOp.
void emitTopLevelDecl(clang::Decl *decl)
CharUnits getDynamicOffsetAlignment(CharUnits actualBaseAlign, const CXXRecordDecl *baseDecl, CharUnits expectedTargetAlign)
TODO: Add TBAAAccessInfo.
void emitGlobalOpenACCDeclareDataOperands(const Expr *varOperand, DataClauseTy dataClause, OpenACCModifierKind modifiers, bool structured, bool implicit, bool requiresDtor)
void emitOMPDeclareMapper(const OMPDeclareMapperDecl *d)
void addReplacement(llvm::StringRef name, mlir::Operation *op)
mlir::Type convertType(clang::QualType type)
bool shouldEmitRTTI(bool forEH=false)
cir::GlobalOp getGlobalForStringLiteral(const StringLiteral *s, llvm::StringRef name=".str")
Return a global symbol reference to a constant array for the given string literal.
void emitOMPCapturedExpr(const OMPCapturedExprDecl *d)
llvm::DenseMap< const VarDecl *, cir::GlobalOp > initializerConstants
void mapUnresolvedBlockAddress(cir::BlockAddressOp op)
bool mustBeEmitted(const clang::ValueDecl *d)
Determine whether the definition must be emitted; if this returns false, the definition can be emitte...
void emitGlobalOpenACCDeclareDecl(const clang::OpenACCDeclareDecl *cd)
mlir::IntegerAttr getSize(CharUnits size)
DiagnosticBuilder errorNYI(SourceRange loc, llvm::StringRef feature, const T &name)
CIRGenBuilderTy & getBuilder()
void setDSOLocal(mlir::Operation *op) const
std::string getUniqueGlobalName(const std::string &baseName)
std::pair< cir::FuncType, cir::FuncOp > getAddrAndTypeOfCXXStructor(clang::GlobalDecl gd, const CIRGenFunctionInfo *fnInfo=nullptr, cir::FuncType fnType=nullptr, bool dontDefer=false, ForDefinition_t isForDefinition=NotForDefinition)
ItaniumVTableContext & getItaniumVTableContext()
void setGVProperties(mlir::Operation *op, const NamedDecl *d) const
Set visibility, dllimport/dllexport and dso_local.
cir::GlobalOp getOrCreateCIRGlobal(llvm::StringRef mangledName, mlir::Type ty, LangAS langAS, const VarDecl *d, ForDefinition_t isForDefinition)
If the specified mangled name is not in the module, create and return an mlir::GlobalOp value.
cir::FuncOp createCIRBuiltinFunction(mlir::Location loc, llvm::StringRef name, cir::FuncType ty, const clang::FunctionDecl *fd)
Create a CIR function with builtin attribute set.
llvm::DenseMap< const Decl *, cir::GlobalOp > staticLocalDeclMap
void emitGlobalOpenACCRoutineDecl(const clang::OpenACCRoutineDecl *cd)
clang::CharUnits getClassPointerAlignment(const clang::CXXRecordDecl *rd)
Return the best known alignment for an unknown pointer to a particular class.
void handleCXXStaticMemberVarInstantiation(VarDecl *vd)
Tell the consumer that this variable has been instantiated.
void emitOMPRequiresDecl(const OMPRequiresDecl *d)
void emitGlobalDefinition(clang::GlobalDecl gd, mlir::Operation *op=nullptr)
void mapResolvedBlockAddress(cir::BlockAddressOp op, cir::LabelOp)
clang::DiagnosticsEngine & getDiags() const
CharUnits getVBaseAlignment(CharUnits derivedAlign, const CXXRecordDecl *derived, const CXXRecordDecl *vbase)
Returns the assumed alignment of a virtual base of a class.
mlir::Attribute getAddrOfRTTIDescriptor(mlir::Location loc, QualType ty, bool forEH=false)
Get the address of the RTTI descriptor for the given type.
clang::CharUnits getNaturalTypeAlignment(clang::QualType t, LValueBaseInfo *baseInfo)
FIXME: this could likely be a common helper and not necessarily related with codegen.
void setFunctionAttributes(GlobalDecl gd, cir::FuncOp f, bool isIncompleteFunction, bool isThunk)
Set function attributes for a function declaration.
static mlir::SymbolTable::Visibility getMLIRVisibilityFromCIRLinkage(cir::GlobalLinkageKind GLK)
const ItaniumVTableContext & getItaniumVTableContext() const
const clang::TargetInfo & getTarget() const
mlir::TypedAttr emitNullConstantForBase(const CXXRecordDecl *record)
Return a null constant appropriate for zero-initializing a base class with the given type.
void setCIRFunctionAttributes(GlobalDecl gd, const CIRGenFunctionInfo &info, cir::FuncOp func, bool isThunk)
Set the CIR function attributes (Sext, zext, etc).
cir::FuncOp getBuiltinLibFunction(const FunctionDecl *fd, unsigned builtinID)
Given a builtin id for a function like "__builtin_fabsf", return a Function* for "fabsf".
const llvm::Triple & getTriple() const
static mlir::SymbolTable::Visibility getMLIRVisibility(Visibility v)
void emitTentativeDefinition(const VarDecl *d)
cir::GlobalOp createOrReplaceCXXRuntimeVariable(mlir::Location loc, llvm::StringRef name, mlir::Type ty, cir::GlobalLinkageKind linkage, clang::CharUnits alignment)
Will return a global variable of the given type.
void emitOMPAllocateDecl(const OMPAllocateDecl *d)
void error(SourceLocation loc, llvm::StringRef error)
Emit a general error that something can't be done.
void emitGlobalDecl(const clang::GlobalDecl &d)
Helper for emitDeferred to apply actual codegen.
cir::FuncOp getOrCreateCIRFunction(llvm::StringRef mangledName, mlir::Type funcType, clang::GlobalDecl gd, bool forVTable, bool dontDefer=false, bool isThunk=false, ForDefinition_t isForDefinition=NotForDefinition, mlir::ArrayAttr extraAttrs={})
void emitGlobalVarDefinition(const clang::VarDecl *vd, bool isTentative=false)
void setTLSMode(mlir::Operation *op, const VarDecl &d)
Set TLS mode for the given operation based on the given variable declaration.
DiagnosticBuilder errorNYI(mlir::Location loc, llvm::StringRef feature)
cir::FuncOp getAddrOfFunction(clang::GlobalDecl gd, mlir::Type funcType=nullptr, bool forVTable=false, bool dontDefer=false, ForDefinition_t isForDefinition=NotForDefinition)
Return the address of the given function.
mlir::TypedAttr emitNullConstantAttr(QualType t)
void emitAliasForGlobal(llvm::StringRef mangledName, mlir::Operation *op, GlobalDecl aliasGD, cir::FuncOp aliasee, cir::GlobalLinkageKind linkage)
mlir::Value emitMemberPointerConstant(const UnaryOperator *e)
void emitGlobalOpenACCDecl(const clang::OpenACCConstructDecl *cd)
void emitExplicitCastExprType(const ExplicitCastExpr *e, CIRGenFunction *cgf=nullptr)
Emit type info if type of an expression is a variably modified type.
const cir::CIRDataLayout getDataLayout() const
std::map< llvm::StringRef, clang::GlobalDecl > deferredDecls
This contains all the decls which have definitions but which are deferred for emission and therefore ...
void errorUnsupported(const Stmt *s, llvm::StringRef type)
Print out an error that codegen doesn't support the specified stmt yet.
mlir::Value getAddrOfGlobalVar(const VarDecl *d, mlir::Type ty={}, ForDefinition_t isForDefinition=NotForDefinition)
Return the mlir::Value for the address of the given global variable.
static void setInitializer(cir::GlobalOp &op, mlir::Attribute value)
cir::GlobalViewAttr getAddrOfGlobalVarAttr(const VarDecl *d)
Return the mlir::GlobalViewAttr for the address of the given global.
void addGlobalCtor(cir::FuncOp ctor, std::optional< int > priority=std::nullopt)
Add a global constructor or destructor to the module.
cir::GlobalLinkageKind getFunctionLinkage(GlobalDecl gd)
void updateCompletedType(const clang::TagDecl *td)
const clang::CodeGenOptions & getCodeGenOpts() const
const clang::LangOptions & getLangOpts() const
void emitOpenACCRoutineDecl(const clang::FunctionDecl *funcDecl, cir::FuncOp func, SourceLocation pragmaLoc, ArrayRef< const OpenACCClause * > clauses)
static constexpr const char * builtinCoroAlloc
cir::TLS_Model getDefaultCIRTLSModel() const
Get TLS mode from CodeGenOptions.
void addGlobalDtor(cir::FuncOp dtor, std::optional< int > priority=std::nullopt)
Add a function to the list that will be called when the module is unloaded.
void addDeferredDeclToEmit(clang::GlobalDecl GD)
cir::FuncOp createCIRFunction(mlir::Location loc, llvm::StringRef name, cir::FuncType funcType, const clang::FunctionDecl *funcDecl)
const TargetCIRGenInfo & getTargetCIRGenInfo()
void emitCXXGlobalVarDeclInitFunc(const VarDecl *vd, cir::GlobalOp addr, bool performInit)
void setStaticLocalDeclAddress(const VarDecl *d, cir::GlobalOp c)
void setGVPropertiesAux(mlir::Operation *op, const NamedDecl *d) const
LangAS getLangTempAllocaAddressSpace() const
Returns the address space for temporary allocations in the language.
llvm::DenseSet< cir::BlockAddressOp > unresolvedBlockAddressToLabel
Track CIR BlockAddressOps that cannot be resolved immediately because their LabelOp has not yet been ...
cir::FuncOp codegenCXXStructor(clang::GlobalDecl gd)
mlir::Location getLoc(clang::SourceLocation cLoc)
Helpers to convert the presumed location of Clang's SourceLocation to an MLIR Location.
llvm::DenseMap< mlir::Attribute, cir::GlobalOp > constantStringMap
mlir::Operation * lastGlobalOp
static cir::VisibilityKind getGlobalVisibilityKindFromClangVisibility(clang::VisibilityAttr::VisibilityType visibility)
llvm::StringMap< unsigned > cgGlobalNames
void setCXXSpecialMemberAttr(cir::FuncOp funcOp, const clang::FunctionDecl *funcDecl)
Mark the function as a special member (e.g. constructor, destructor)
mlir::Operation * getGlobalValue(llvm::StringRef ref)
mlir::Value emitNullConstant(QualType t, mlir::Location loc)
Return the result of value-initializing the given type, i.e.
void emitOMPDeclareReduction(const OMPDeclareReductionDecl *d)
mlir::ModuleOp getModule() const
cir::GlobalLinkageKind getCIRLinkageForDeclarator(const DeclaratorDecl *dd, GVALinkage linkage, bool isConstantVariable)
mlir::MLIRContext & getMLIRContext()
mlir::Operation * getAddrOfGlobal(clang::GlobalDecl gd, ForDefinition_t isForDefinition=NotForDefinition)
DiagnosticBuilder errorNYI(llvm::StringRef feature) const
static cir::GlobalOp createGlobalOp(CIRGenModule &cgm, mlir::Location loc, llvm::StringRef name, mlir::Type t, bool isConstant=false, mlir::Operation *insertPoint=nullptr)
void maybeSetTrivialComdat(const clang::Decl &d, mlir::Operation *op)
cir::GlobalOp getStaticLocalDeclAddress(const VarDecl *d)
CIRGenCXXABI & getCXXABI() const
cir::GlobalViewAttr getAddrOfConstantStringFromLiteral(const StringLiteral *s, llvm::StringRef name=".str")
Return a global symbol reference to a constant array for the given string literal.
llvm::MapVector< cir::BlockAddressOp, cir::LabelOp > blockAddressToLabel
Map CIR BlockAddressOps directly to their resolved LabelOps.
void emitDeclContext(const DeclContext *dc)
static constexpr const char * builtinCoroBegin
static constexpr const char * builtinCoroId
void emitGlobal(clang::GlobalDecl gd)
Emit code for a single global function or variable declaration.
cir::LabelOp lookupBlockAddressInfo(cir::BlockAddrInfoAttr blockInfo)
bool mayBeEmittedEagerly(const clang::ValueDecl *d)
Determine whether the definition can be emitted eagerly, or should be delayed until the end of the tr...
llvm::DenseMap< const clang::FieldDecl *, llvm::StringRef > lambdaFieldToName
Keep a map between lambda fields and names, this needs to be per module since lambdas might get gener...
DiagnosticBuilder errorNYI(SourceLocation loc, llvm::StringRef feature, const T &name)
cir::GlobalLinkageKind getCIRLinkageVarDefinition(const VarDecl *vd, bool isConstant)
void mapBlockAddress(cir::BlockAddrInfoAttr blockInfo, cir::LabelOp label)
static constexpr const char * builtinCoroEnd
void setCIRFunctionAttributesForDefinition(const clang::FunctionDecl *fd, cir::FuncOp f)
Set extra attributes (inline, etc.) for a function.
std::string getOpenACCBindMangledName(const IdentifierInfo *bindName, const FunctionDecl *attachedFunction)
void emitGlobalFunctionDefinition(clang::GlobalDecl gd, mlir::Operation *op)
CIRGenVTables & getVTables()
void setFunctionLinkage(GlobalDecl gd, cir::FuncOp f)
void constructAttributeList(llvm::StringRef name, const CIRGenFunctionInfo &info, CIRGenCalleeInfo calleeInfo, mlir::NamedAttrList &attrs, cir::CallingConv &callingConv, cir::SideEffect &sideEffect, bool attrOnCallSite, bool isThunk)
Get the CIR attributes and calling convention to use for a particular function type.
std::vector< clang::GlobalDecl > deferredDeclsToEmit
void emitVTable(const CXXRecordDecl *rd)
This is a callback from Sema to tell us that a particular vtable is required to be emitted in this tr...
void emitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *d)
void emitOMPGroupPrivateDecl(const OMPGroupPrivateDecl *d)
cir::GlobalLinkageKind getVTableLinkage(const CXXRecordDecl *rd)
Return the appropriate linkage for the vtable, VTT, and type information of the given class.
Address createUnnamedGlobalFrom(const VarDecl &d, mlir::Attribute constAttr, CharUnits align)
mlir::Attribute getConstantArrayFromStringLiteral(const StringLiteral *e)
Return a constant array for the given string.
cir::VisibilityAttr getGlobalVisibilityAttrFromDecl(const Decl *decl)
void setCommonAttributes(GlobalDecl gd, mlir::Operation *op)
Set attributes which are common to any form of a global definition (alias, Objective-C method,...
This class organizes the cross-module state that is used while lowering AST types to CIR types.
Definition CIRGenTypes.h:48
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
CharUnits - This is an opaque type for sizes expressed in character units.
Definition CharUnits.h:38
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1449
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
Represents a ValueDecl that came out of a declarator.
Definition Decl.h:780
A little helper class used to produce diagnostics.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:232
ExplicitCastExpr - An explicit cast written in the source code.
Definition Expr.h:3928
This represents one expression.
Definition Expr.h:112
Represents a function declaration or definition.
Definition Decl.h:2000
GlobalDecl - represents a global declaration.
Definition GlobalDecl.h:57
One of these records is kept for each identifier that is lexed.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
This represents a decl that may have a name.
Definition Decl.h:274
This represents 'pragma omp allocate ...' directive.
Definition DeclOpenMP.h:536
Pseudo declaration for capturing expressions.
Definition DeclOpenMP.h:445
This represents 'pragma omp declare mapper ...' directive.
Definition DeclOpenMP.h:349
This represents 'pragma omp declare reduction ...' directive.
Definition DeclOpenMP.h:239
This represents 'pragma omp groupprivate ...' directive.
Definition DeclOpenMP.h:173
This represents 'pragma omp requires...' directive.
Definition DeclOpenMP.h:479
This represents 'pragma omp threadprivate ...' directive.
Definition DeclOpenMP.h:110
A (possibly-)qualified type.
Definition TypeBase.h:937
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
Stmt - This represents one statement.
Definition Stmt.h:86
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1799
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3717
Exposes information about the current target.
Definition TargetInfo.h:226
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2244
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
Represents a variable declaration or definition.
Definition Decl.h:926
Defines the clang::TargetInfo interface.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
const internal::VariadicDynCastAllOfMatcher< Decl, VarDecl > varDecl
Matches variable declarations.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
The JSON file list parser is used to communicate input to InstallAPI.
GVALinkage
A more specific kind of linkage than enum Linkage.
Definition Linkage.h:72
OpenACCModifierKind
const FunctionProtoType * T
LangAS
Defines the address space values used by the address space qualifier of QualType.
Visibility
Describes the different kinds of visibility that a declaration may have.
Definition Visibility.h:34
@ HiddenVisibility
Objects with "hidden" visibility are not seen by the dynamic linker.
Definition Visibility.h:37
@ ProtectedVisibility
Objects with "protected" visibility are seen by the dynamic linker but always dynamically resolve to ...
Definition Visibility.h:42
@ DefaultVisibility
Objects with "default" visibility are seen by the dynamic linker and act like normal objects.
Definition Visibility.h:46