| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | #ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H |
| 14 | #define LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H |
| 15 | |
| 16 | #include "CGVTables.h" |
| 17 | #include "CodeGenTypeCache.h" |
| 18 | #include "CodeGenTypes.h" |
| 19 | #include "SanitizerMetadata.h" |
| 20 | #include "clang/AST/Attr.h" |
| 21 | #include "clang/AST/DeclCXX.h" |
| 22 | #include "clang/AST/DeclObjC.h" |
| 23 | #include "clang/AST/DeclOpenMP.h" |
| 24 | #include "clang/AST/GlobalDecl.h" |
| 25 | #include "clang/AST/Mangle.h" |
| 26 | #include "clang/Basic/ABI.h" |
| 27 | #include "clang/Basic/LangOptions.h" |
| 28 | #include "clang/Basic/Module.h" |
| 29 | #include "clang/Basic/SanitizerBlacklist.h" |
| 30 | #include "clang/Basic/XRayLists.h" |
| 31 | #include "llvm/ADT/DenseMap.h" |
| 32 | #include "llvm/ADT/SetVector.h" |
| 33 | #include "llvm/ADT/SmallPtrSet.h" |
| 34 | #include "llvm/ADT/StringMap.h" |
| 35 | #include "llvm/IR/Module.h" |
| 36 | #include "llvm/IR/ValueHandle.h" |
| 37 | #include "llvm/Transforms/Utils/SanitizerStats.h" |
| 38 | |
| 39 | namespace llvm { |
| 40 | class Module; |
| 41 | class Constant; |
| 42 | class ConstantInt; |
| 43 | class Function; |
| 44 | class GlobalValue; |
| 45 | class DataLayout; |
| 46 | class FunctionType; |
| 47 | class LLVMContext; |
| 48 | class IndexedInstrProfReader; |
| 49 | } |
| 50 | |
| 51 | namespace clang { |
| 52 | class ASTContext; |
| 53 | class AtomicType; |
| 54 | class FunctionDecl; |
| 55 | class IdentifierInfo; |
| 56 | class ObjCMethodDecl; |
| 57 | class ObjCImplementationDecl; |
| 58 | class ObjCCategoryImplDecl; |
| 59 | class ObjCProtocolDecl; |
| 60 | class ObjCEncodeExpr; |
| 61 | class BlockExpr; |
| 62 | class CharUnits; |
| 63 | class Decl; |
| 64 | class Expr; |
| 65 | class Stmt; |
| 66 | class InitListExpr; |
| 67 | class StringLiteral; |
| 68 | class NamedDecl; |
| 69 | class ValueDecl; |
| 70 | class VarDecl; |
| 71 | class LangOptions; |
| 72 | class CodeGenOptions; |
| 73 | class ; |
| 74 | class PreprocessorOptions; |
| 75 | class DiagnosticsEngine; |
| 76 | class AnnotateAttr; |
| 77 | class CXXDestructorDecl; |
| 78 | class Module; |
| 79 | class CoverageSourceInfo; |
| 80 | |
| 81 | namespace CodeGen { |
| 82 | |
| 83 | class CallArgList; |
| 84 | class CodeGenFunction; |
| 85 | class CodeGenTBAA; |
| 86 | class CGCXXABI; |
| 87 | class CGDebugInfo; |
| 88 | class CGObjCRuntime; |
| 89 | class CGOpenCLRuntime; |
| 90 | class CGOpenMPRuntime; |
| 91 | class CGCUDARuntime; |
| 92 | class BlockFieldFlags; |
| 93 | class FunctionArgList; |
| 94 | class CoverageMappingModuleGen; |
| 95 | class TargetCodeGenInfo; |
| 96 | |
| 97 | enum ForDefinition_t : bool { |
| 98 | NotForDefinition = false, |
| 99 | ForDefinition = true |
| 100 | }; |
| 101 | |
| 102 | struct OrderGlobalInits { |
| 103 | unsigned int priority; |
| 104 | unsigned int lex_order; |
| 105 | OrderGlobalInits(unsigned int p, unsigned int l) |
| 106 | : priority(p), lex_order(l) {} |
| 107 | |
| 108 | bool operator==(const OrderGlobalInits &RHS) const { |
| 109 | return priority == RHS.priority && lex_order == RHS.lex_order; |
| 110 | } |
| 111 | |
| 112 | bool operator<(const OrderGlobalInits &RHS) const { |
| 113 | return std::tie(priority, lex_order) < |
| 114 | std::tie(RHS.priority, RHS.lex_order); |
| 115 | } |
| 116 | }; |
| 117 | |
| 118 | struct ObjCEntrypoints { |
| 119 | ObjCEntrypoints() { memset(this, 0, sizeof(*this)); } |
| 120 | |
| 121 | |
| 122 | llvm::FunctionCallee objc_alloc; |
| 123 | |
| 124 | |
| 125 | llvm::FunctionCallee objc_allocWithZone; |
| 126 | |
| 127 | |
| 128 | llvm::FunctionCallee objc_alloc_init; |
| 129 | |
| 130 | |
| 131 | llvm::FunctionCallee objc_autoreleasePoolPop; |
| 132 | |
| 133 | |
| 134 | |
| 135 | llvm::FunctionCallee objc_autoreleasePoolPopInvoke; |
| 136 | |
| 137 | |
| 138 | llvm::Function *objc_autoreleasePoolPush; |
| 139 | |
| 140 | |
| 141 | llvm::Function *objc_autorelease; |
| 142 | |
| 143 | |
| 144 | |
| 145 | llvm::FunctionCallee objc_autoreleaseRuntimeFunction; |
| 146 | |
| 147 | |
| 148 | llvm::Function *objc_autoreleaseReturnValue; |
| 149 | |
| 150 | |
| 151 | llvm::Function *objc_copyWeak; |
| 152 | |
| 153 | |
| 154 | llvm::Function *objc_destroyWeak; |
| 155 | |
| 156 | |
| 157 | llvm::Function *objc_initWeak; |
| 158 | |
| 159 | |
| 160 | llvm::Function *objc_loadWeak; |
| 161 | |
| 162 | |
| 163 | llvm::Function *objc_loadWeakRetained; |
| 164 | |
| 165 | |
| 166 | llvm::Function *objc_moveWeak; |
| 167 | |
| 168 | |
| 169 | llvm::Function *objc_retain; |
| 170 | |
| 171 | |
| 172 | |
| 173 | llvm::FunctionCallee objc_retainRuntimeFunction; |
| 174 | |
| 175 | |
| 176 | llvm::Function *objc_retainAutorelease; |
| 177 | |
| 178 | |
| 179 | llvm::Function *objc_retainAutoreleaseReturnValue; |
| 180 | |
| 181 | |
| 182 | llvm::Function *objc_retainAutoreleasedReturnValue; |
| 183 | |
| 184 | |
| 185 | llvm::Function *objc_retainBlock; |
| 186 | |
| 187 | |
| 188 | llvm::Function *objc_release; |
| 189 | |
| 190 | |
| 191 | |
| 192 | llvm::FunctionCallee objc_releaseRuntimeFunction; |
| 193 | |
| 194 | |
| 195 | llvm::Function *objc_storeStrong; |
| 196 | |
| 197 | |
| 198 | llvm::Function *objc_storeWeak; |
| 199 | |
| 200 | |
| 201 | llvm::Function *objc_unsafeClaimAutoreleasedReturnValue; |
| 202 | |
| 203 | |
| 204 | |
| 205 | llvm::InlineAsm *retainAutoreleasedReturnValueMarker; |
| 206 | |
| 207 | |
| 208 | llvm::Function *clang_arc_use; |
| 209 | }; |
| 210 | |
| 211 | |
| 212 | class InstrProfStats { |
| 213 | uint32_t VisitedInMainFile; |
| 214 | uint32_t MissingInMainFile; |
| 215 | uint32_t Visited; |
| 216 | uint32_t Missing; |
| 217 | uint32_t Mismatched; |
| 218 | |
| 219 | public: |
| 220 | InstrProfStats() |
| 221 | : VisitedInMainFile(0), MissingInMainFile(0), Visited(0), Missing(0), |
| 222 | Mismatched(0) {} |
| 223 | |
| 224 | |
| 225 | void addVisited(bool MainFile) { |
| 226 | if (MainFile) |
| 227 | ++VisitedInMainFile; |
| 228 | ++Visited; |
| 229 | } |
| 230 | |
| 231 | void addMissing(bool MainFile) { |
| 232 | if (MainFile) |
| 233 | ++MissingInMainFile; |
| 234 | ++Missing; |
| 235 | } |
| 236 | |
| 237 | void addMismatched(bool MainFile) { ++Mismatched; } |
| 238 | |
| 239 | bool hasDiagnostics() { return Missing || Mismatched; } |
| 240 | |
| 241 | void reportDiagnostics(DiagnosticsEngine &Diags, StringRef MainFile); |
| 242 | }; |
| 243 | |
| 244 | |
| 245 | class BlockByrefHelpers : public llvm::FoldingSetNode { |
| 246 | |
| 247 | |
| 248 | public: |
| 249 | llvm::Constant *CopyHelper; |
| 250 | llvm::Constant *DisposeHelper; |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | CharUnits Alignment; |
| 256 | |
| 257 | BlockByrefHelpers(CharUnits alignment) : Alignment(alignment) {} |
| 258 | BlockByrefHelpers(const BlockByrefHelpers &) = default; |
| 259 | virtual ~BlockByrefHelpers(); |
| 260 | |
| 261 | void Profile(llvm::FoldingSetNodeID &id) const { |
| 262 | id.AddInteger(Alignment.getQuantity()); |
| 263 | profileImpl(id); |
| 264 | } |
| 265 | virtual void profileImpl(llvm::FoldingSetNodeID &id) const = 0; |
| 266 | |
| 267 | virtual bool needsCopy() const { return true; } |
| 268 | virtual void emitCopy(CodeGenFunction &CGF, Address dest, Address src) = 0; |
| 269 | |
| 270 | virtual bool needsDispose() const { return true; } |
| 271 | virtual void emitDispose(CodeGenFunction &CGF, Address field) = 0; |
| 272 | }; |
| 273 | |
| 274 | |
| 275 | |
| 276 | class CodeGenModule : public CodeGenTypeCache { |
| 277 | CodeGenModule(const CodeGenModule &) = delete; |
| 278 | void operator=(const CodeGenModule &) = delete; |
| 279 | |
| 280 | public: |
| 281 | struct Structor { |
| 282 | Structor() : Priority(0), Initializer(nullptr), AssociatedData(nullptr) {} |
| 283 | Structor(int Priority, llvm::Constant *Initializer, |
| 284 | llvm::Constant *AssociatedData) |
| 285 | : Priority(Priority), Initializer(Initializer), |
| 286 | AssociatedData(AssociatedData) {} |
| 287 | int Priority; |
| 288 | llvm::Constant *Initializer; |
| 289 | llvm::Constant *AssociatedData; |
| 290 | }; |
| 291 | |
| 292 | typedef std::vector<Structor> CtorList; |
| 293 | |
| 294 | private: |
| 295 | ASTContext &Context; |
| 296 | const LangOptions &LangOpts; |
| 297 | const HeaderSearchOptions &; |
| 298 | const PreprocessorOptions &PreprocessorOpts; |
| 299 | const CodeGenOptions &CodeGenOpts; |
| 300 | llvm::Module &TheModule; |
| 301 | DiagnosticsEngine &Diags; |
| 302 | const TargetInfo &Target; |
| 303 | std::unique_ptr<CGCXXABI> ABI; |
| 304 | llvm::LLVMContext &VMContext; |
| 305 | |
| 306 | std::unique_ptr<CodeGenTBAA> TBAA; |
| 307 | |
| 308 | mutable std::unique_ptr<TargetCodeGenInfo> TheTargetCodeGenInfo; |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | CodeGenTypes Types; |
| 314 | |
| 315 | |
| 316 | CodeGenVTables VTables; |
| 317 | |
| 318 | std::unique_ptr<CGObjCRuntime> ObjCRuntime; |
| 319 | std::unique_ptr<CGOpenCLRuntime> OpenCLRuntime; |
| 320 | std::unique_ptr<CGOpenMPRuntime> OpenMPRuntime; |
| 321 | std::unique_ptr<CGCUDARuntime> CUDARuntime; |
| 322 | std::unique_ptr<CGDebugInfo> DebugInfo; |
| 323 | std::unique_ptr<ObjCEntrypoints> ObjCData; |
| 324 | llvm::MDNode *NoObjCARCExceptionsMetadata = nullptr; |
| 325 | std::unique_ptr<llvm::IndexedInstrProfReader> PGOReader; |
| 326 | InstrProfStats PGOStats; |
| 327 | std::unique_ptr<llvm::SanitizerStatReport> SanStats; |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | llvm::SmallPtrSet<llvm::GlobalValue*, 10> WeakRefReferences; |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | std::map<StringRef, GlobalDecl> DeferredDecls; |
| 339 | |
| 340 | |
| 341 | |
| 342 | std::vector<GlobalDecl> DeferredDeclsToEmit; |
| 343 | void addDeferredDeclToEmit(GlobalDecl GD) { |
| 344 | DeferredDeclsToEmit.emplace_back(GD); |
| 345 | } |
| 346 | |
| 347 | |
| 348 | |
| 349 | std::vector<GlobalDecl> Aliases; |
| 350 | |
| 351 | |
| 352 | |
| 353 | std::vector<GlobalDecl> MultiVersionFuncs; |
| 354 | |
| 355 | typedef llvm::StringMap<llvm::TrackingVH<llvm::Constant> > ReplacementsTy; |
| 356 | ReplacementsTy Replacements; |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | llvm::SmallVector<std::pair<llvm::GlobalValue *, llvm::Constant *>, 8> |
| 362 | GlobalValReplacements; |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | llvm::DenseSet<GlobalDecl> DiagnosedConflictingDefinitions; |
| 368 | |
| 369 | |
| 370 | std::vector<const CXXRecordDecl*> DeferredVTables; |
| 371 | |
| 372 | |
| 373 | std::vector<const CXXRecordDecl *> OpportunisticVTables; |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | std::vector<llvm::WeakTrackingVH> LLVMUsed; |
| 379 | std::vector<llvm::WeakTrackingVH> LLVMCompilerUsed; |
| 380 | |
| 381 | |
| 382 | |
| 383 | CtorList GlobalCtors; |
| 384 | |
| 385 | |
| 386 | |
| 387 | CtorList GlobalDtors; |
| 388 | |
| 389 | |
| 390 | llvm::MapVector<GlobalDecl, StringRef> MangledDeclNames; |
| 391 | llvm::StringMap<GlobalDecl, llvm::BumpPtrAllocator> Manglings; |
| 392 | |
| 393 | |
| 394 | |
| 395 | llvm::MapVector<std::pair<GlobalDecl, unsigned>, StringRef> |
| 396 | CPUSpecificMangledDeclNames; |
| 397 | llvm::StringMap<std::pair<GlobalDecl, unsigned>, llvm::BumpPtrAllocator> |
| 398 | CPUSpecificManglings; |
| 399 | |
| 400 | |
| 401 | std::vector<llvm::Constant*> Annotations; |
| 402 | |
| 403 | |
| 404 | llvm::StringMap<llvm::Constant*> AnnotationStrings; |
| 405 | |
| 406 | llvm::StringMap<llvm::GlobalVariable *> CFConstantStringMap; |
| 407 | |
| 408 | llvm::DenseMap<llvm::Constant *, llvm::GlobalVariable *> ConstantStringMap; |
| 409 | llvm::DenseMap<const Decl*, llvm::Constant *> StaticLocalDeclMap; |
| 410 | llvm::DenseMap<const Decl*, llvm::GlobalVariable*> StaticLocalDeclGuardMap; |
| 411 | llvm::DenseMap<const Expr*, llvm::Constant *> MaterializedGlobalTemporaryMap; |
| 412 | |
| 413 | llvm::DenseMap<QualType, llvm::Constant *> AtomicSetterHelperFnMap; |
| 414 | llvm::DenseMap<QualType, llvm::Constant *> AtomicGetterHelperFnMap; |
| 415 | |
| 416 | |
| 417 | llvm::DenseMap<QualType, llvm::Constant *> TypeDescriptorMap; |
| 418 | |
| 419 | |
| 420 | |
| 421 | typedef llvm::MapVector<IdentifierInfo *, |
| 422 | llvm::GlobalValue *> StaticExternCMap; |
| 423 | StaticExternCMap StaticExternCValues; |
| 424 | |
| 425 | |
| 426 | std::vector<const VarDecl *> CXXThreadLocals; |
| 427 | |
| 428 | |
| 429 | |
| 430 | std::vector<llvm::Function *> CXXThreadLocalInits; |
| 431 | std::vector<const VarDecl *> CXXThreadLocalInitVars; |
| 432 | |
| 433 | |
| 434 | std::vector<llvm::Function *> CXXGlobalInits; |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | llvm::DenseMap<const Decl*, unsigned> DelayedCXXInitPosition; |
| 442 | |
| 443 | typedef std::pair<OrderGlobalInits, llvm::Function*> GlobalInitData; |
| 444 | |
| 445 | struct GlobalInitPriorityCmp { |
| 446 | bool operator()(const GlobalInitData &LHS, |
| 447 | const GlobalInitData &RHS) const { |
| 448 | return LHS.first.priority < RHS.first.priority; |
| 449 | } |
| 450 | }; |
| 451 | |
| 452 | |
| 453 | |
| 454 | SmallVector<GlobalInitData, 8> PrioritizedCXXGlobalInits; |
| 455 | |
| 456 | |
| 457 | std::vector< |
| 458 | std::tuple<llvm::FunctionType *, llvm::WeakTrackingVH, llvm::Constant *>> |
| 459 | CXXGlobalDtors; |
| 460 | |
| 461 | |
| 462 | llvm::SetVector<clang::Module *> ImportedModules; |
| 463 | |
| 464 | |
| 465 | |
| 466 | llvm::SmallPtrSet<clang::Module *, 16> EmittedModuleInitializers; |
| 467 | |
| 468 | |
| 469 | SmallVector<llvm::MDNode *, 16> LinkerOptionsMetadata; |
| 470 | |
| 471 | |
| 472 | |
| 473 | |
| 474 | |
| 475 | |
| 476 | llvm::WeakTrackingVH CFConstantStringClassRef; |
| 477 | |
| 478 | |
| 479 | |
| 480 | QualType ObjCFastEnumerationStateType; |
| 481 | |
| 482 | |
| 483 | |
| 484 | |
| 485 | void createObjCRuntime(); |
| 486 | |
| 487 | void createOpenCLRuntime(); |
| 488 | void createOpenMPRuntime(); |
| 489 | void createCUDARuntime(); |
| 490 | |
| 491 | bool isTriviallyRecursive(const FunctionDecl *F); |
| 492 | bool shouldEmitFunction(GlobalDecl GD); |
| 493 | bool shouldOpportunisticallyEmitVTables(); |
| 494 | |
| 495 | llvm::DenseMap<const CompoundLiteralExpr *, llvm::GlobalVariable *> |
| 496 | EmittedCompoundLiterals; |
| 497 | |
| 498 | |
| 499 | |
| 500 | llvm::DenseMap<const BlockExpr *, llvm::Constant *> EmittedGlobalBlocks; |
| 501 | |
| 502 | |
| 503 | |
| 504 | |
| 505 | llvm::Constant *NSConcreteGlobalBlock = nullptr; |
| 506 | llvm::Constant *NSConcreteStackBlock = nullptr; |
| 507 | |
| 508 | llvm::FunctionCallee BlockObjectAssign = nullptr; |
| 509 | llvm::FunctionCallee BlockObjectDispose = nullptr; |
| 510 | |
| 511 | llvm::Type *BlockDescriptorType = nullptr; |
| 512 | llvm::Type *GenericBlockLiteralType = nullptr; |
| 513 | |
| 514 | struct { |
| 515 | int GlobalUniqueCount; |
| 516 | } Block; |
| 517 | |
| 518 | |
| 519 | llvm::Function *LifetimeStartFn = nullptr; |
| 520 | |
| 521 | |
| 522 | llvm::Function *LifetimeEndFn = nullptr; |
| 523 | |
| 524 | GlobalDecl initializedGlobalDecl; |
| 525 | |
| 526 | std::unique_ptr<SanitizerMetadata> SanitizerMD; |
| 527 | |
| 528 | |
| 529 | |
| 530 | llvm::MapVector<const Decl *, bool> DeferredEmptyCoverageMappingDecls; |
| 531 | |
| 532 | std::unique_ptr<CoverageMappingModuleGen> CoverageMapping; |
| 533 | |
| 534 | |
| 535 | |
| 536 | |
| 537 | typedef llvm::DenseMap<QualType, llvm::Metadata *> MetadataTypeMap; |
| 538 | MetadataTypeMap MetadataIdMap; |
| 539 | MetadataTypeMap VirtualMetadataIdMap; |
| 540 | MetadataTypeMap GeneralizedMetadataIdMap; |
| 541 | |
| 542 | public: |
| 543 | CodeGenModule(ASTContext &C, const HeaderSearchOptions &, |
| 544 | const PreprocessorOptions &ppopts, |
| 545 | const CodeGenOptions &CodeGenOpts, llvm::Module &M, |
| 546 | DiagnosticsEngine &Diags, |
| 547 | CoverageSourceInfo *CoverageInfo = nullptr); |
| 548 | |
| 549 | ~CodeGenModule(); |
| 550 | |
| 551 | void clear(); |
| 552 | |
| 553 | |
| 554 | void Release(); |
| 555 | |
| 556 | |
| 557 | bool getExpressionLocationsEnabled() const; |
| 558 | |
| 559 | |
| 560 | CGObjCRuntime &getObjCRuntime() { |
| 561 | if (!ObjCRuntime) createObjCRuntime(); |
| 562 | return *ObjCRuntime; |
| 563 | } |
| 564 | |
| 565 | |
| 566 | bool hasObjCRuntime() { return !!ObjCRuntime; } |
| 567 | |
| 568 | |
| 569 | CGOpenCLRuntime &getOpenCLRuntime() { |
| 570 | assert(OpenCLRuntime != nullptr); |
| 571 | return *OpenCLRuntime; |
| 572 | } |
| 573 | |
| 574 | |
| 575 | CGOpenMPRuntime &getOpenMPRuntime() { |
| 576 | assert(OpenMPRuntime != nullptr); |
| 577 | return *OpenMPRuntime; |
| 578 | } |
| 579 | |
| 580 | |
| 581 | CGCUDARuntime &getCUDARuntime() { |
| 582 | assert(CUDARuntime != nullptr); |
| 583 | return *CUDARuntime; |
| 584 | } |
| 585 | |
| 586 | ObjCEntrypoints &getObjCEntrypoints() const { |
| 587 | assert(ObjCData != nullptr); |
| 588 | return *ObjCData; |
| 589 | } |
| 590 | |
| 591 | |
| 592 | |
| 593 | llvm::FunctionCallee IsOSVersionAtLeastFn = nullptr; |
| 594 | |
| 595 | InstrProfStats &getPGOStats() { return PGOStats; } |
| 596 | llvm::IndexedInstrProfReader *getPGOReader() const { return PGOReader.get(); } |
| 597 | |
| 598 | CoverageMappingModuleGen *getCoverageMapping() const { |
| 599 | return CoverageMapping.get(); |
| 600 | } |
| 601 | |
| 602 | llvm::Constant *getStaticLocalDeclAddress(const VarDecl *D) { |
| 603 | return StaticLocalDeclMap[D]; |
| 604 | } |
| 605 | void setStaticLocalDeclAddress(const VarDecl *D, |
| 606 | llvm::Constant *C) { |
| 607 | StaticLocalDeclMap[D] = C; |
| 608 | } |
| 609 | |
| 610 | llvm::Constant * |
| 611 | getOrCreateStaticVarDecl(const VarDecl &D, |
| 612 | llvm::GlobalValue::LinkageTypes Linkage); |
| 613 | |
| 614 | llvm::GlobalVariable *getStaticLocalDeclGuardAddress(const VarDecl *D) { |
| 615 | return StaticLocalDeclGuardMap[D]; |
| 616 | } |
| 617 | void setStaticLocalDeclGuardAddress(const VarDecl *D, |
| 618 | llvm::GlobalVariable *C) { |
| 619 | StaticLocalDeclGuardMap[D] = C; |
| 620 | } |
| 621 | |
| 622 | bool lookupRepresentativeDecl(StringRef MangledName, |
| 623 | GlobalDecl &Result) const; |
| 624 | |
| 625 | llvm::Constant *getAtomicSetterHelperFnMap(QualType Ty) { |
| 626 | return AtomicSetterHelperFnMap[Ty]; |
| 627 | } |
| 628 | void setAtomicSetterHelperFnMap(QualType Ty, |
| 629 | llvm::Constant *Fn) { |
| 630 | AtomicSetterHelperFnMap[Ty] = Fn; |
| 631 | } |
| 632 | |
| 633 | llvm::Constant *getAtomicGetterHelperFnMap(QualType Ty) { |
| 634 | return AtomicGetterHelperFnMap[Ty]; |
| 635 | } |
| 636 | void setAtomicGetterHelperFnMap(QualType Ty, |
| 637 | llvm::Constant *Fn) { |
| 638 | AtomicGetterHelperFnMap[Ty] = Fn; |
| 639 | } |
| 640 | |
| 641 | llvm::Constant *getTypeDescriptorFromMap(QualType Ty) { |
| 642 | return TypeDescriptorMap[Ty]; |
| 643 | } |
| 644 | void setTypeDescriptorInMap(QualType Ty, llvm::Constant *C) { |
| 645 | TypeDescriptorMap[Ty] = C; |
| 646 | } |
| 647 | |
| 648 | CGDebugInfo *getModuleDebugInfo() { return DebugInfo.get(); } |
| 649 | |
| 650 | llvm::MDNode *getNoObjCARCExceptionsMetadata() { |
| 651 | if (!NoObjCARCExceptionsMetadata) |
| 652 | NoObjCARCExceptionsMetadata = llvm::MDNode::get(getLLVMContext(), None); |
| 653 | return NoObjCARCExceptionsMetadata; |
| 654 | } |
| 655 | |
| 656 | ASTContext &getContext() const { return Context; } |
| 657 | const LangOptions &getLangOpts() const { return LangOpts; } |
| 658 | const HeaderSearchOptions &() |
| 659 | const { return HeaderSearchOpts; } |
| 660 | const PreprocessorOptions &getPreprocessorOpts() |
| 661 | const { return PreprocessorOpts; } |
| 662 | const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; } |
| 663 | llvm::Module &getModule() const { return TheModule; } |
| 664 | DiagnosticsEngine &getDiags() const { return Diags; } |
| 665 | const llvm::DataLayout &getDataLayout() const { |
| 666 | return TheModule.getDataLayout(); |
| 667 | } |
| 668 | const TargetInfo &getTarget() const { return Target; } |
| 669 | const llvm::Triple &getTriple() const { return Target.getTriple(); } |
| 670 | bool supportsCOMDAT() const; |
| 671 | void maybeSetTrivialComdat(const Decl &D, llvm::GlobalObject &GO); |
| 672 | |
| 673 | CGCXXABI &getCXXABI() const { return *ABI; } |
| 674 | llvm::LLVMContext &getLLVMContext() { return VMContext; } |
| 675 | |
| 676 | bool shouldUseTBAA() const { return TBAA != nullptr; } |
| 677 | |
| 678 | const TargetCodeGenInfo &getTargetCodeGenInfo(); |
| 679 | |
| 680 | CodeGenTypes &getTypes() { return Types; } |
| 681 | |
| 682 | CodeGenVTables &getVTables() { return VTables; } |
| 683 | |
| 684 | ItaniumVTableContext &getItaniumVTableContext() { |
| 685 | return VTables.getItaniumVTableContext(); |
| 686 | } |
| 687 | |
| 688 | MicrosoftVTableContext &getMicrosoftVTableContext() { |
| 689 | return VTables.getMicrosoftVTableContext(); |
| 690 | } |
| 691 | |
| 692 | CtorList &getGlobalCtors() { return GlobalCtors; } |
| 693 | CtorList &getGlobalDtors() { return GlobalDtors; } |
| 694 | |
| 695 | |
| 696 | |
| 697 | llvm::MDNode *getTBAATypeInfo(QualType QTy); |
| 698 | |
| 699 | |
| 700 | |
| 701 | TBAAAccessInfo getTBAAAccessInfo(QualType AccessType); |
| 702 | |
| 703 | |
| 704 | |
| 705 | TBAAAccessInfo getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType); |
| 706 | |
| 707 | llvm::MDNode *getTBAAStructInfo(QualType QTy); |
| 708 | |
| 709 | |
| 710 | |
| 711 | llvm::MDNode *getTBAABaseTypeInfo(QualType QTy); |
| 712 | |
| 713 | |
| 714 | llvm::MDNode *getTBAAAccessTagInfo(TBAAAccessInfo Info); |
| 715 | |
| 716 | |
| 717 | |
| 718 | TBAAAccessInfo mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo, |
| 719 | TBAAAccessInfo TargetInfo); |
| 720 | |
| 721 | |
| 722 | |
| 723 | TBAAAccessInfo mergeTBAAInfoForConditionalOperator(TBAAAccessInfo InfoA, |
| 724 | TBAAAccessInfo InfoB); |
| 725 | |
| 726 | |
| 727 | |
| 728 | TBAAAccessInfo mergeTBAAInfoForMemoryTransfer(TBAAAccessInfo DestInfo, |
| 729 | TBAAAccessInfo SrcInfo); |
| 730 | |
| 731 | |
| 732 | |
| 733 | TBAAAccessInfo getTBAAInfoForSubobject(LValue Base, QualType AccessType) { |
| 734 | if (Base.getTBAAInfo().isMayAlias()) |
| 735 | return TBAAAccessInfo::getMayAliasInfo(); |
| 736 | return getTBAAAccessInfo(AccessType); |
| 737 | } |
| 738 | |
| 739 | bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor); |
| 740 | |
| 741 | bool isPaddedAtomicType(QualType type); |
| 742 | bool isPaddedAtomicType(const AtomicType *type); |
| 743 | |
| 744 | |
| 745 | void DecorateInstructionWithTBAA(llvm::Instruction *Inst, |
| 746 | TBAAAccessInfo TBAAInfo); |
| 747 | |
| 748 | |
| 749 | void DecorateInstructionWithInvariantGroup(llvm::Instruction *I, |
| 750 | const CXXRecordDecl *RD); |
| 751 | |
| 752 | |
| 753 | llvm::ConstantInt *getSize(CharUnits numChars); |
| 754 | |
| 755 | |
| 756 | void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const; |
| 757 | |
| 758 | void setGlobalVisibilityAndLocal(llvm::GlobalValue *GV, |
| 759 | const NamedDecl *D) const; |
| 760 | |
| 761 | void setDSOLocal(llvm::GlobalValue *GV) const; |
| 762 | |
| 763 | void setDLLImportDLLExport(llvm::GlobalValue *GV, GlobalDecl D) const; |
| 764 | void setDLLImportDLLExport(llvm::GlobalValue *GV, const NamedDecl *D) const; |
| 765 | |
| 766 | |
| 767 | void setGVProperties(llvm::GlobalValue *GV, GlobalDecl GD) const; |
| 768 | void setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D) const; |
| 769 | |
| 770 | |
| 771 | |
| 772 | void setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const; |
| 773 | |
| 774 | static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V) { |
| 775 | switch (V) { |
| 776 | case DefaultVisibility: return llvm::GlobalValue::DefaultVisibility; |
| 777 | case HiddenVisibility: return llvm::GlobalValue::HiddenVisibility; |
| 778 | case ProtectedVisibility: return llvm::GlobalValue::ProtectedVisibility; |
| 779 | } |
| 780 | llvm_unreachable("unknown visibility!"); |
| 781 | } |
| 782 | |
| 783 | llvm::Constant *GetAddrOfGlobal(GlobalDecl GD, |
| 784 | ForDefinition_t IsForDefinition |
| 785 | = NotForDefinition); |
| 786 | |
| 787 | |
| 788 | |
| 789 | |
| 790 | |
| 791 | llvm::GlobalVariable * |
| 792 | CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty, |
| 793 | llvm::GlobalValue::LinkageTypes Linkage, |
| 794 | unsigned Alignment); |
| 795 | |
| 796 | llvm::Function * |
| 797 | CreateGlobalInitOrDestructFunction(llvm::FunctionType *ty, const Twine &name, |
| 798 | const CGFunctionInfo &FI, |
| 799 | SourceLocation Loc = SourceLocation(), |
| 800 | bool TLS = false); |
| 801 | |
| 802 | |
| 803 | |
| 804 | |
| 805 | |
| 806 | |
| 807 | |
| 808 | |
| 809 | |
| 810 | LangAS GetGlobalVarAddressSpace(const VarDecl *D); |
| 811 | |
| 812 | |
| 813 | |
| 814 | |
| 815 | |
| 816 | |
| 817 | |
| 818 | llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D, |
| 819 | llvm::Type *Ty = nullptr, |
| 820 | ForDefinition_t IsForDefinition |
| 821 | = NotForDefinition); |
| 822 | |
| 823 | |
| 824 | |
| 825 | |
| 826 | |
| 827 | |
| 828 | LangAS getStringLiteralAddressSpace() const; |
| 829 | |
| 830 | |
| 831 | |
| 832 | llvm::Constant *GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty = nullptr, |
| 833 | bool ForVTable = false, |
| 834 | bool DontDefer = false, |
| 835 | ForDefinition_t IsForDefinition |
| 836 | = NotForDefinition); |
| 837 | |
| 838 | |
| 839 | llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false); |
| 840 | |
| 841 | |
| 842 | ConstantAddress GetAddrOfUuidDescriptor(const CXXUuidofExpr* E); |
| 843 | |
| 844 | |
| 845 | llvm::Constant *GetAddrOfThunk(StringRef Name, llvm::Type *FnTy, |
| 846 | GlobalDecl GD); |
| 847 | |
| 848 | |
| 849 | ConstantAddress GetWeakRefReference(const ValueDecl *VD); |
| 850 | |
| 851 | |
| 852 | CharUnits getClassPointerAlignment(const CXXRecordDecl *CD); |
| 853 | |
| 854 | |
| 855 | CharUnits getVBaseAlignment(CharUnits DerivedAlign, |
| 856 | const CXXRecordDecl *Derived, |
| 857 | const CXXRecordDecl *VBase); |
| 858 | |
| 859 | |
| 860 | |
| 861 | |
| 862 | CharUnits getDynamicOffsetAlignment(CharUnits ActualAlign, |
| 863 | const CXXRecordDecl *Class, |
| 864 | CharUnits ExpectedTargetAlign); |
| 865 | |
| 866 | CharUnits |
| 867 | computeNonVirtualBaseClassOffset(const CXXRecordDecl *DerivedClass, |
| 868 | CastExpr::path_const_iterator Start, |
| 869 | CastExpr::path_const_iterator End); |
| 870 | |
| 871 | |
| 872 | |
| 873 | llvm::Constant * |
| 874 | GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl, |
| 875 | CastExpr::path_const_iterator PathBegin, |
| 876 | CastExpr::path_const_iterator PathEnd); |
| 877 | |
| 878 | llvm::FoldingSet<BlockByrefHelpers> ByrefHelpersCache; |
| 879 | |
| 880 | |
| 881 | int getUniqueBlockCount() { return ++Block.GlobalUniqueCount; } |
| 882 | |
| 883 | |
| 884 | llvm::Type *getBlockDescriptorType(); |
| 885 | |
| 886 | |
| 887 | llvm::Type *getGenericBlockLiteralType(); |
| 888 | |
| 889 | |
| 890 | llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, StringRef Name); |
| 891 | |
| 892 | |
| 893 | |
| 894 | llvm::Constant *getAddrOfGlobalBlockIfEmitted(const BlockExpr *BE) { |
| 895 | return EmittedGlobalBlocks.lookup(BE); |
| 896 | } |
| 897 | |
| 898 | |
| 899 | |
| 900 | void setAddrOfGlobalBlock(const BlockExpr *BE, llvm::Constant *Addr); |
| 901 | |
| 902 | |
| 903 | ConstantAddress GetAddrOfConstantCFString(const StringLiteral *Literal); |
| 904 | |
| 905 | |
| 906 | |
| 907 | |
| 908 | ConstantAddress GetAddrOfConstantString(const StringLiteral *Literal); |
| 909 | |
| 910 | |
| 911 | llvm::Constant *GetConstantArrayFromStringLiteral(const StringLiteral *E); |
| 912 | |
| 913 | |
| 914 | ConstantAddress |
| 915 | GetAddrOfConstantStringFromLiteral(const StringLiteral *S, |
| 916 | StringRef Name = ".str"); |
| 917 | |
| 918 | |
| 919 | ConstantAddress |
| 920 | GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *); |
| 921 | |
| 922 | |
| 923 | |
| 924 | |
| 925 | |
| 926 | |
| 927 | ConstantAddress |
| 928 | GetAddrOfConstantCString(const std::string &Str, |
| 929 | const char *GlobalName = nullptr); |
| 930 | |
| 931 | |
| 932 | |
| 933 | ConstantAddress GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr*E); |
| 934 | |
| 935 | |
| 936 | |
| 937 | llvm::GlobalVariable * |
| 938 | getAddrOfConstantCompoundLiteralIfEmitted(const CompoundLiteralExpr *E); |
| 939 | |
| 940 | |
| 941 | |
| 942 | void setAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *CLE, |
| 943 | llvm::GlobalVariable *GV); |
| 944 | |
| 945 | |
| 946 | |
| 947 | ConstantAddress GetAddrOfGlobalTemporary(const MaterializeTemporaryExpr *E, |
| 948 | const Expr *Inner); |
| 949 | |
| 950 | |
| 951 | |
| 952 | QualType getObjCFastEnumerationStateType(); |
| 953 | |
| 954 | |
| 955 | |
| 956 | |
| 957 | llvm::Function *codegenCXXStructor(GlobalDecl GD); |
| 958 | |
| 959 | |
| 960 | llvm::Constant * |
| 961 | getAddrOfCXXStructor(GlobalDecl GD, const CGFunctionInfo *FnInfo = nullptr, |
| 962 | llvm::FunctionType *FnType = nullptr, |
| 963 | bool DontDefer = false, |
| 964 | ForDefinition_t IsForDefinition = NotForDefinition) { |
| 965 | return cast<llvm::Constant>(getAddrAndTypeOfCXXStructor(GD, FnInfo, FnType, |
| 966 | DontDefer, |
| 967 | IsForDefinition) |
| 968 | .getCallee()); |
| 969 | } |
| 970 | |
| 971 | llvm::FunctionCallee getAddrAndTypeOfCXXStructor( |
| 972 | GlobalDecl GD, const CGFunctionInfo *FnInfo = nullptr, |
| 973 | llvm::FunctionType *FnType = nullptr, bool DontDefer = false, |
| 974 | ForDefinition_t IsForDefinition = NotForDefinition); |
| 975 | |
| 976 | |
| 977 | |
| 978 | llvm::Constant *getBuiltinLibFunction(const FunctionDecl *FD, |
| 979 | unsigned BuiltinID); |
| 980 | |
| 981 | llvm::Function *getIntrinsic(unsigned IID, ArrayRef<llvm::Type*> Tys = None); |
| 982 | |
| 983 | |
| 984 | void EmitTopLevelDecl(Decl *D); |
| 985 | |
| 986 | |
| 987 | |
| 988 | void AddDeferredUnusedCoverageMapping(Decl *D); |
| 989 | |
| 990 | |
| 991 | |
| 992 | void ClearUnusedCoverageMapping(const Decl *D); |
| 993 | |
| 994 | |
| 995 | |
| 996 | void EmitDeferredUnusedCoverageMappings(); |
| 997 | |
| 998 | |
| 999 | void HandleCXXStaticMemberVarInstantiation(VarDecl *VD); |
| 1000 | |
| 1001 | |
| 1002 | |
| 1003 | |
| 1004 | template<typename SomeDecl> |
| 1005 | void MaybeHandleStaticInExternC(const SomeDecl *D, llvm::GlobalValue *GV); |
| 1006 | |
| 1007 | |
| 1008 | void addUsedGlobal(llvm::GlobalValue *GV); |
| 1009 | |
| 1010 | |
| 1011 | void addCompilerUsedGlobal(llvm::GlobalValue *GV); |
| 1012 | |
| 1013 | |
| 1014 | void AddCXXDtorEntry(llvm::FunctionCallee DtorFn, llvm::Constant *Object) { |
| 1015 | CXXGlobalDtors.emplace_back(DtorFn.getFunctionType(), DtorFn.getCallee(), |
| 1016 | Object); |
| 1017 | } |
| 1018 | |
| 1019 | |
| 1020 | |
| 1021 | llvm::FunctionCallee |
| 1022 | CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, |
| 1023 | llvm::AttributeList ExtraAttrs = llvm::AttributeList(), |
| 1024 | bool Local = false); |
| 1025 | |
| 1026 | |
| 1027 | llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty, |
| 1028 | StringRef Name); |
| 1029 | |
| 1030 | |
| 1031 | |
| 1032 | |
| 1033 | llvm::Constant *getNSConcreteGlobalBlock(); |
| 1034 | llvm::Constant *getNSConcreteStackBlock(); |
| 1035 | llvm::FunctionCallee getBlockObjectAssign(); |
| 1036 | llvm::FunctionCallee getBlockObjectDispose(); |
| 1037 | |
| 1038 | |
| 1039 | |
| 1040 | llvm::Function *getLLVMLifetimeStartFn(); |
| 1041 | llvm::Function *getLLVMLifetimeEndFn(); |
| 1042 | |
| 1043 | |
| 1044 | void UpdateCompletedType(const TagDecl *TD); |
| 1045 | |
| 1046 | llvm::Constant *getMemberPointerConstant(const UnaryOperator *e); |
| 1047 | |
| 1048 | |
| 1049 | |
| 1050 | void EmitExplicitCastExprType(const ExplicitCastExpr *E, |
| 1051 | CodeGenFunction *CGF = nullptr); |
| 1052 | |
| 1053 | |
| 1054 | |
| 1055 | |
| 1056 | llvm::Constant *EmitNullConstant(QualType T); |
| 1057 | |
| 1058 | |
| 1059 | |
| 1060 | llvm::Constant *EmitNullConstantForBase(const CXXRecordDecl *Record); |
| 1061 | |
| 1062 | |
| 1063 | void Error(SourceLocation loc, StringRef error); |
| 1064 | |
| 1065 | |
| 1066 | void ErrorUnsupported(const Stmt *S, const char *Type); |
| 1067 | |
| 1068 | |
| 1069 | void ErrorUnsupported(const Decl *D, const char *Type); |
| 1070 | |
| 1071 | |
| 1072 | |
| 1073 | |
| 1074 | void SetInternalFunctionAttributes(GlobalDecl GD, llvm::Function *F, |
| 1075 | const CGFunctionInfo &FI); |
| 1076 | |
| 1077 | |
| 1078 | void SetLLVMFunctionAttributes(GlobalDecl GD, const CGFunctionInfo &Info, |
| 1079 | llvm::Function *F); |
| 1080 | |
| 1081 | |
| 1082 | |
| 1083 | void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F); |
| 1084 | |
| 1085 | |
| 1086 | bool ReturnTypeUsesSRet(const CGFunctionInfo &FI); |
| 1087 | |
| 1088 | |
| 1089 | |
| 1090 | bool ReturnSlotInterferesWithArgs(const CGFunctionInfo &FI); |
| 1091 | |
| 1092 | |
| 1093 | bool ReturnTypeUsesFPRet(QualType ResultType); |
| 1094 | |
| 1095 | |
| 1096 | bool ReturnTypeUsesFP2Ret(QualType ResultType); |
| 1097 | |
| 1098 | |
| 1099 | |
| 1100 | |
| 1101 | |
| 1102 | |
| 1103 | |
| 1104 | |
| 1105 | |
| 1106 | |
| 1107 | |
| 1108 | void ConstructAttributeList(StringRef Name, const CGFunctionInfo &Info, |
| 1109 | CGCalleeInfo CalleeInfo, |
| 1110 | llvm::AttributeList &Attrs, unsigned &CallingConv, |
| 1111 | bool AttrOnCallSite); |
| 1112 | |
| 1113 | |
| 1114 | |
| 1115 | |
| 1116 | |
| 1117 | |
| 1118 | |
| 1119 | |
| 1120 | |
| 1121 | |
| 1122 | |
| 1123 | |
| 1124 | |
| 1125 | |
| 1126 | |
| 1127 | |
| 1128 | |
| 1129 | |
| 1130 | void AddDefaultFnAttrs(llvm::Function &F); |
| 1131 | |
| 1132 | |
| 1133 | |
| 1134 | TargetAttr::ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD); |
| 1135 | |
| 1136 | |
| 1137 | |
| 1138 | void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap, GlobalDecl GD); |
| 1139 | |
| 1140 | StringRef getMangledName(GlobalDecl GD); |
| 1141 | StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD); |
| 1142 | |
| 1143 | void EmitTentativeDefinition(const VarDecl *D); |
| 1144 | |
| 1145 | void EmitVTable(CXXRecordDecl *Class); |
| 1146 | |
| 1147 | void RefreshTypeCacheForClass(const CXXRecordDecl *Class); |
| 1148 | |
| 1149 | |
| 1150 | void AppendLinkerOptions(StringRef Opts); |
| 1151 | |
| 1152 | |
| 1153 | void AddDetectMismatch(StringRef Name, StringRef Value); |
| 1154 | |
| 1155 | |
| 1156 | |
| 1157 | void AddDependentLib(StringRef Lib); |
| 1158 | |
| 1159 | void AddELFLibDirective(StringRef Lib); |
| 1160 | |
| 1161 | llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD); |
| 1162 | |
| 1163 | void setFunctionLinkage(GlobalDecl GD, llvm::Function *F) { |
| 1164 | F->setLinkage(getFunctionLinkage(GD)); |
| 1165 | } |
| 1166 | |
| 1167 | |
| 1168 | |
| 1169 | llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD); |
| 1170 | |
| 1171 | |
| 1172 | CharUnits GetTargetTypeStoreSize(llvm::Type *Ty) const; |
| 1173 | |
| 1174 | |
| 1175 | llvm::GlobalValue::LinkageTypes |
| 1176 | getLLVMLinkageForDeclarator(const DeclaratorDecl *D, GVALinkage Linkage, |
| 1177 | bool IsConstantVariable); |
| 1178 | |
| 1179 | |
| 1180 | llvm::GlobalValue::LinkageTypes |
| 1181 | getLLVMLinkageVarDefinition(const VarDecl *VD, bool IsConstant); |
| 1182 | |
| 1183 | |
| 1184 | void EmitGlobalAnnotations(); |
| 1185 | |
| 1186 | |
| 1187 | llvm::Constant *EmitAnnotationString(StringRef Str); |
| 1188 | |
| 1189 | |
| 1190 | llvm::Constant *EmitAnnotationUnit(SourceLocation Loc); |
| 1191 | |
| 1192 | |
| 1193 | llvm::Constant *EmitAnnotationLineNo(SourceLocation L); |
| 1194 | |
| 1195 | |
| 1196 | |
| 1197 | |
| 1198 | |
| 1199 | |
| 1200 | |
| 1201 | |
| 1202 | llvm::Constant *EmitAnnotateAttr(llvm::GlobalValue *GV, |
| 1203 | const AnnotateAttr *AA, |
| 1204 | SourceLocation L); |
| 1205 | |
| 1206 | |
| 1207 | |
| 1208 | void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV); |
| 1209 | |
| 1210 | bool isInSanitizerBlacklist(SanitizerMask Kind, llvm::Function *Fn, |
| 1211 | SourceLocation Loc) const; |
| 1212 | |
| 1213 | bool isInSanitizerBlacklist(llvm::GlobalVariable *GV, SourceLocation Loc, |
| 1214 | QualType Ty, |
| 1215 | StringRef Category = StringRef()) const; |
| 1216 | |
| 1217 | |
| 1218 | |
| 1219 | |
| 1220 | bool imbueXRayAttrs(llvm::Function *Fn, SourceLocation Loc, |
| 1221 | StringRef Category = StringRef()) const; |
| 1222 | |
| 1223 | SanitizerMetadata *getSanitizerMetadata() { |
| 1224 | return SanitizerMD.get(); |
| 1225 | } |
| 1226 | |
| 1227 | void addDeferredVTable(const CXXRecordDecl *RD) { |
| 1228 | DeferredVTables.push_back(RD); |
| 1229 | } |
| 1230 | |
| 1231 | |
| 1232 | |
| 1233 | void EmitGlobal(GlobalDecl D); |
| 1234 | |
| 1235 | bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D); |
| 1236 | |
| 1237 | llvm::GlobalValue *GetGlobalValue(StringRef Ref); |
| 1238 | |
| 1239 | |
| 1240 | |
| 1241 | |
| 1242 | |
| 1243 | void SetCommonAttributes(GlobalDecl GD, llvm::GlobalValue *GV); |
| 1244 | |
| 1245 | void addReplacement(StringRef Name, llvm::Constant *C); |
| 1246 | |
| 1247 | void addGlobalValReplacement(llvm::GlobalValue *GV, llvm::Constant *C); |
| 1248 | |
| 1249 | |
| 1250 | |
| 1251 | void EmitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D); |
| 1252 | |
| 1253 | |
| 1254 | void EmitOMPDeclareReduction(const OMPDeclareReductionDecl *D, |
| 1255 | CodeGenFunction *CGF = nullptr); |
| 1256 | |
| 1257 | |
| 1258 | void EmitOMPDeclareMapper(const OMPDeclareMapperDecl *D, |
| 1259 | CodeGenFunction *CGF = nullptr); |
| 1260 | |
| 1261 | |
| 1262 | |
| 1263 | void EmitOMPRequiresDecl(const OMPRequiresDecl *D); |
| 1264 | |
| 1265 | |
| 1266 | |
| 1267 | |
| 1268 | bool HasHiddenLTOVisibility(const CXXRecordDecl *RD); |
| 1269 | |
| 1270 | |
| 1271 | void EmitVTableTypeMetadata(llvm::GlobalVariable *VTable, |
| 1272 | const VTableLayout &VTLayout); |
| 1273 | |
| 1274 | |
| 1275 | llvm::ConstantInt *CreateCrossDsoCfiTypeId(llvm::Metadata *MD); |
| 1276 | |
| 1277 | |
| 1278 | |
| 1279 | |
| 1280 | llvm::Metadata *CreateMetadataIdentifierForType(QualType T); |
| 1281 | |
| 1282 | |
| 1283 | |
| 1284 | llvm::Metadata *CreateMetadataIdentifierForVirtualMemPtrType(QualType T); |
| 1285 | |
| 1286 | |
| 1287 | |
| 1288 | |
| 1289 | llvm::Metadata *CreateMetadataIdentifierGeneralized(QualType T); |
| 1290 | |
| 1291 | |
| 1292 | void CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD, |
| 1293 | llvm::Function *F); |
| 1294 | |
| 1295 | |
| 1296 | bool NeedAllVtablesTypeId() const; |
| 1297 | |
| 1298 | |
| 1299 | void AddVTableTypeMetadata(llvm::GlobalVariable *VTable, CharUnits Offset, |
| 1300 | const CXXRecordDecl *RD); |
| 1301 | |
| 1302 | |
| 1303 | |
| 1304 | |
| 1305 | |
| 1306 | |
| 1307 | std::vector<const CXXRecordDecl *> |
| 1308 | getMostBaseClasses(const CXXRecordDecl *RD); |
| 1309 | |
| 1310 | |
| 1311 | llvm::FunctionCallee getTerminateFn(); |
| 1312 | |
| 1313 | llvm::SanitizerStatReport &getSanStats(); |
| 1314 | |
| 1315 | llvm::Value * |
| 1316 | createOpenCLIntToSamplerConversion(const Expr *E, CodeGenFunction &CGF); |
| 1317 | |
| 1318 | |
| 1319 | |
| 1320 | |
| 1321 | llvm::Constant *getNullPointer(llvm::PointerType *T, QualType QT); |
| 1322 | |
| 1323 | private: |
| 1324 | llvm::Constant *GetOrCreateLLVMFunction( |
| 1325 | StringRef MangledName, llvm::Type *Ty, GlobalDecl D, bool ForVTable, |
| 1326 | bool DontDefer = false, bool IsThunk = false, |
| 1327 | llvm::AttributeList = llvm::AttributeList(), |
| 1328 | ForDefinition_t IsForDefinition = NotForDefinition); |
| 1329 | |
| 1330 | llvm::Constant *GetOrCreateMultiVersionResolver(GlobalDecl GD, |
| 1331 | llvm::Type *DeclTy, |
| 1332 | const FunctionDecl *FD); |
| 1333 | void UpdateMultiVersionNames(GlobalDecl GD, const FunctionDecl *FD); |
| 1334 | |
| 1335 | llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName, |
| 1336 | llvm::PointerType *PTy, |
| 1337 | const VarDecl *D, |
| 1338 | ForDefinition_t IsForDefinition |
| 1339 | = NotForDefinition); |
| 1340 | |
| 1341 | bool GetCPUAndFeaturesAttributes(GlobalDecl GD, |
| 1342 | llvm::AttrBuilder &AttrBuilder); |
| 1343 | void setNonAliasAttributes(GlobalDecl GD, llvm::GlobalObject *GO); |
| 1344 | |
| 1345 | |
| 1346 | void SetFunctionAttributes(GlobalDecl GD, llvm::Function *F, |
| 1347 | bool IsIncompleteFunction, bool IsThunk); |
| 1348 | |
| 1349 | void EmitGlobalDefinition(GlobalDecl D, llvm::GlobalValue *GV = nullptr); |
| 1350 | |
| 1351 | void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV); |
| 1352 | void EmitMultiVersionFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV); |
| 1353 | |
| 1354 | void EmitGlobalVarDefinition(const VarDecl *D, bool IsTentative = false); |
| 1355 | void EmitAliasDefinition(GlobalDecl GD); |
| 1356 | void emitIFuncDefinition(GlobalDecl GD); |
| 1357 | void emitCPUDispatchDefinition(GlobalDecl GD); |
| 1358 | void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D); |
| 1359 | void EmitObjCIvarInitializations(ObjCImplementationDecl *D); |
| 1360 | |
| 1361 | |
| 1362 | |
| 1363 | void EmitDeclContext(const DeclContext *DC); |
| 1364 | void EmitLinkageSpec(const LinkageSpecDecl *D); |
| 1365 | |
| 1366 | |
| 1367 | void EmitCXXThreadLocalInitFunc(); |
| 1368 | |
| 1369 | |
| 1370 | void EmitCXXGlobalInitFunc(); |
| 1371 | |
| 1372 | |
| 1373 | void EmitCXXGlobalDtorFunc(); |
| 1374 | |
| 1375 | |
| 1376 | |
| 1377 | void EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, |
| 1378 | llvm::GlobalVariable *Addr, |
| 1379 | bool PerformInit); |
| 1380 | |
| 1381 | void EmitPointerToInitFunc(const VarDecl *VD, llvm::GlobalVariable *Addr, |
| 1382 | llvm::Function *InitFunc, InitSegAttr *ISA); |
| 1383 | |
| 1384 | |
| 1385 | void AddGlobalCtor(llvm::Function *Ctor, int Priority = 65535, |
| 1386 | llvm::Constant *AssociatedData = nullptr); |
| 1387 | void AddGlobalDtor(llvm::Function *Dtor, int Priority = 65535); |
| 1388 | |
| 1389 | |
| 1390 | |
| 1391 | |
| 1392 | void EmitCtorList(CtorList &Fns, const char *GlobalName); |
| 1393 | |
| 1394 | |
| 1395 | void EmitDeferred(); |
| 1396 | |
| 1397 | |
| 1398 | |
| 1399 | |
| 1400 | |
| 1401 | void EmitVTablesOpportunistically(); |
| 1402 | |
| 1403 | |
| 1404 | void applyReplacements(); |
| 1405 | |
| 1406 | |
| 1407 | void applyGlobalValReplacements(); |
| 1408 | |
| 1409 | void checkAliases(); |
| 1410 | |
| 1411 | std::map<int, llvm::TinyPtrVector<llvm::Function *>> DtorsUsingAtExit; |
| 1412 | |
| 1413 | |
| 1414 | |
| 1415 | void registerGlobalDtorsWithAtExit(); |
| 1416 | |
| 1417 | void emitMultiVersionFunctions(); |
| 1418 | |
| 1419 | |
| 1420 | void EmitDeferredVTables(); |
| 1421 | |
| 1422 | |
| 1423 | |
| 1424 | void emitAtAvailableLinkGuard(); |
| 1425 | |
| 1426 | |
| 1427 | void emitLLVMUsed(); |
| 1428 | |
| 1429 | |
| 1430 | void EmitModuleLinkOptions(); |
| 1431 | |
| 1432 | |
| 1433 | |
| 1434 | void EmitStaticExternCAliases(); |
| 1435 | |
| 1436 | void EmitDeclMetadata(); |
| 1437 | |
| 1438 | |
| 1439 | void EmitVersionIdentMetadata(); |
| 1440 | |
| 1441 | |
| 1442 | void EmitCommandLineMetadata(); |
| 1443 | |
| 1444 | |
| 1445 | void EmitTargetMetadata(); |
| 1446 | |
| 1447 | |
| 1448 | void EmitOpenCLMetadata(); |
| 1449 | |
| 1450 | |
| 1451 | |
| 1452 | void EmitCoverageFile(); |
| 1453 | |
| 1454 | |
| 1455 | llvm::Constant *EmitUuidofInitializer(StringRef uuidstr); |
| 1456 | |
| 1457 | |
| 1458 | |
| 1459 | bool MustBeEmitted(const ValueDecl *D); |
| 1460 | |
| 1461 | |
| 1462 | |
| 1463 | |
| 1464 | |
| 1465 | bool MayBeEmittedEagerly(const ValueDecl *D); |
| 1466 | |
| 1467 | |
| 1468 | |
| 1469 | void SimplifyPersonality(); |
| 1470 | |
| 1471 | |
| 1472 | |
| 1473 | void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone, |
| 1474 | bool AttrOnCallSite, |
| 1475 | llvm::AttrBuilder &FuncAttrs); |
| 1476 | |
| 1477 | llvm::Metadata *CreateMetadataIdentifierImpl(QualType T, MetadataTypeMap &Map, |
| 1478 | StringRef Suffix); |
| 1479 | }; |
| 1480 | |
| 1481 | } |
| 1482 | } |
| 1483 | |
| 1484 | #endif |
| 1485 | |