1 //===--- CodeGenModule.h - Per-Module state for LLVM CodeGen ----*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This is the internal per-translation-unit state used for llvm translation. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef CLANG_CODEGEN_CODEGENMODULE_H 15 #define CLANG_CODEGEN_CODEGENMODULE_H 16 17 #include "CGVTables.h" 18 #include "CodeGenTypes.h" 19 #include "clang/AST/Attr.h" 20 #include "clang/AST/DeclCXX.h" 21 #include "clang/AST/DeclObjC.h" 22 #include "clang/AST/GlobalDecl.h" 23 #include "clang/AST/Mangle.h" 24 #include "clang/Basic/ABI.h" 25 #include "clang/Basic/LangOptions.h" 26 #include "clang/Basic/Module.h" 27 #include "llvm/ADT/DenseMap.h" 28 #include "llvm/ADT/SetVector.h" 29 #include "llvm/ADT/SmallPtrSet.h" 30 #include "llvm/ADT/StringMap.h" 31 #include "llvm/IR/CallingConv.h" 32 #include "llvm/IR/Module.h" 33 #include "llvm/IR/ValueHandle.h" 34 #include "llvm/Transforms/Utils/SpecialCaseList.h" 35 36 namespace llvm { 37 class Module; 38 class Constant; 39 class ConstantInt; 40 class Function; 41 class GlobalValue; 42 class DataLayout; 43 class FunctionType; 44 class LLVMContext; 45 class IndexedInstrProfReader; 46 } 47 48 namespace clang { 49 class TargetCodeGenInfo; 50 class ASTContext; 51 class AtomicType; 52 class FunctionDecl; 53 class IdentifierInfo; 54 class ObjCMethodDecl; 55 class ObjCImplementationDecl; 56 class ObjCCategoryImplDecl; 57 class ObjCProtocolDecl; 58 class ObjCEncodeExpr; 59 class BlockExpr; 60 class CharUnits; 61 class Decl; 62 class Expr; 63 class Stmt; 64 class InitListExpr; 65 class StringLiteral; 66 class NamedDecl; 67 class ValueDecl; 68 class VarDecl; 69 class LangOptions; 70 class CodeGenOptions; 71 class DiagnosticsEngine; 72 class AnnotateAttr; 73 class CXXDestructorDecl; 74 class MangleBuffer; 75 class Module; 76 77 namespace CodeGen { 78 79 class CallArgList; 80 class CodeGenFunction; 81 class CodeGenTBAA; 82 class CGCXXABI; 83 class CGDebugInfo; 84 class CGObjCRuntime; 85 class CGOpenCLRuntime; 86 class CGCUDARuntime; 87 class BlockFieldFlags; 88 class FunctionArgList; 89 90 struct OrderGlobalInits { 91 unsigned int priority; 92 unsigned int lex_order; 93 OrderGlobalInits(unsigned int p, unsigned int l) 94 : priority(p), lex_order(l) {} 95 96 bool operator==(const OrderGlobalInits &RHS) const { 97 return priority == RHS.priority && 98 lex_order == RHS.lex_order; 99 } 100 101 bool operator<(const OrderGlobalInits &RHS) const { 102 return std::tie(priority, lex_order) < 103 std::tie(RHS.priority, RHS.lex_order); 104 } 105 }; 106 107 struct CodeGenTypeCache { 108 /// void 109 llvm::Type *VoidTy; 110 111 /// i8, i16, i32, and i64 112 llvm::IntegerType *Int8Ty, *Int16Ty, *Int32Ty, *Int64Ty; 113 /// float, double 114 llvm::Type *FloatTy, *DoubleTy; 115 116 /// int 117 llvm::IntegerType *IntTy; 118 119 /// intptr_t, size_t, and ptrdiff_t, which we assume are the same size. 120 union { 121 llvm::IntegerType *IntPtrTy; 122 llvm::IntegerType *SizeTy; 123 llvm::IntegerType *PtrDiffTy; 124 }; 125 126 /// void* in address space 0 127 union { 128 llvm::PointerType *VoidPtrTy; 129 llvm::PointerType *Int8PtrTy; 130 }; 131 132 /// void** in address space 0 133 union { 134 llvm::PointerType *VoidPtrPtrTy; 135 llvm::PointerType *Int8PtrPtrTy; 136 }; 137 138 /// The width of a pointer into the generic address space. 139 unsigned char PointerWidthInBits; 140 141 /// The size and alignment of a pointer into the generic address 142 /// space. 143 union { 144 unsigned char PointerAlignInBytes; 145 unsigned char PointerSizeInBytes; 146 unsigned char SizeSizeInBytes; // sizeof(size_t) 147 }; 148 149 llvm::CallingConv::ID RuntimeCC; 150 llvm::CallingConv::ID getRuntimeCC() const { 151 return RuntimeCC; 152 } 153 }; 154 155 struct RREntrypoints { 156 RREntrypoints() { memset(this, 0, sizeof(*this)); } 157 /// void objc_autoreleasePoolPop(void*); 158 llvm::Constant *objc_autoreleasePoolPop; 159 160 /// void *objc_autoreleasePoolPush(void); 161 llvm::Constant *objc_autoreleasePoolPush; 162 }; 163 164 struct ARCEntrypoints { 165 ARCEntrypoints() { memset(this, 0, sizeof(*this)); } 166 167 /// id objc_autorelease(id); 168 llvm::Constant *objc_autorelease; 169 170 /// id objc_autoreleaseReturnValue(id); 171 llvm::Constant *objc_autoreleaseReturnValue; 172 173 /// void objc_copyWeak(id *dest, id *src); 174 llvm::Constant *objc_copyWeak; 175 176 /// void objc_destroyWeak(id*); 177 llvm::Constant *objc_destroyWeak; 178 179 /// id objc_initWeak(id*, id); 180 llvm::Constant *objc_initWeak; 181 182 /// id objc_loadWeak(id*); 183 llvm::Constant *objc_loadWeak; 184 185 /// id objc_loadWeakRetained(id*); 186 llvm::Constant *objc_loadWeakRetained; 187 188 /// void objc_moveWeak(id *dest, id *src); 189 llvm::Constant *objc_moveWeak; 190 191 /// id objc_retain(id); 192 llvm::Constant *objc_retain; 193 194 /// id objc_retainAutorelease(id); 195 llvm::Constant *objc_retainAutorelease; 196 197 /// id objc_retainAutoreleaseReturnValue(id); 198 llvm::Constant *objc_retainAutoreleaseReturnValue; 199 200 /// id objc_retainAutoreleasedReturnValue(id); 201 llvm::Constant *objc_retainAutoreleasedReturnValue; 202 203 /// id objc_retainBlock(id); 204 llvm::Constant *objc_retainBlock; 205 206 /// void objc_release(id); 207 llvm::Constant *objc_release; 208 209 /// id objc_storeStrong(id*, id); 210 llvm::Constant *objc_storeStrong; 211 212 /// id objc_storeWeak(id*, id); 213 llvm::Constant *objc_storeWeak; 214 215 /// A void(void) inline asm to use to mark that the return value of 216 /// a call will be immediately retain. 217 llvm::InlineAsm *retainAutoreleasedReturnValueMarker; 218 219 /// void clang.arc.use(...); 220 llvm::Constant *clang_arc_use; 221 }; 222 223 /// This class records statistics on instrumentation based profiling. 224 struct InstrProfStats { 225 InstrProfStats() : Visited(0), Missing(0), Mismatched(0) {} 226 bool isOutOfDate() { return Missing || Mismatched; } 227 uint32_t Visited; 228 uint32_t Missing; 229 uint32_t Mismatched; 230 }; 231 232 /// CodeGenModule - This class organizes the cross-function state that is used 233 /// while generating LLVM code. 234 class CodeGenModule : public CodeGenTypeCache { 235 CodeGenModule(const CodeGenModule &) LLVM_DELETED_FUNCTION; 236 void operator=(const CodeGenModule &) LLVM_DELETED_FUNCTION; 237 238 typedef std::vector<std::pair<llvm::Constant*, int> > CtorList; 239 240 ASTContext &Context; 241 const LangOptions &LangOpts; 242 const CodeGenOptions &CodeGenOpts; 243 llvm::Module &TheModule; 244 DiagnosticsEngine &Diags; 245 const llvm::DataLayout &TheDataLayout; 246 const TargetInfo &Target; 247 std::unique_ptr<CGCXXABI> ABI; 248 llvm::LLVMContext &VMContext; 249 250 CodeGenTBAA *TBAA; 251 252 mutable const TargetCodeGenInfo *TheTargetCodeGenInfo; 253 254 // This should not be moved earlier, since its initialization depends on some 255 // of the previous reference members being already initialized and also checks 256 // if TheTargetCodeGenInfo is NULL 257 CodeGenTypes Types; 258 259 /// VTables - Holds information about C++ vtables. 260 CodeGenVTables VTables; 261 262 CGObjCRuntime* ObjCRuntime; 263 CGOpenCLRuntime* OpenCLRuntime; 264 CGCUDARuntime* CUDARuntime; 265 CGDebugInfo* DebugInfo; 266 ARCEntrypoints *ARCData; 267 llvm::MDNode *NoObjCARCExceptionsMetadata; 268 RREntrypoints *RRData; 269 std::unique_ptr<llvm::IndexedInstrProfReader> PGOReader; 270 InstrProfStats PGOStats; 271 272 // WeakRefReferences - A set of references that have only been seen via 273 // a weakref so far. This is used to remove the weak of the reference if we 274 // ever see a direct reference or a definition. 275 llvm::SmallPtrSet<llvm::GlobalValue*, 10> WeakRefReferences; 276 277 /// DeferredDecls - This contains all the decls which have definitions but 278 /// which are deferred for emission and therefore should only be output if 279 /// they are actually used. If a decl is in this, then it is known to have 280 /// not been referenced yet. 281 llvm::StringMap<GlobalDecl> DeferredDecls; 282 283 /// DeferredDeclsToEmit - This is a list of deferred decls which we have seen 284 /// that *are* actually referenced. These get code generated when the module 285 /// is done. 286 struct DeferredGlobal { 287 DeferredGlobal(llvm::GlobalValue *GV, GlobalDecl GD) : GV(GV), GD(GD) {} 288 llvm::AssertingVH<llvm::GlobalValue> GV; 289 GlobalDecl GD; 290 }; 291 std::vector<DeferredGlobal> DeferredDeclsToEmit; 292 void addDeferredDeclToEmit(llvm::GlobalValue *GV, GlobalDecl GD) { 293 DeferredDeclsToEmit.push_back(DeferredGlobal(GV, GD)); 294 } 295 296 /// List of alias we have emitted. Used to make sure that what they point to 297 /// is defined once we get to the end of the of the translation unit. 298 std::vector<GlobalDecl> Aliases; 299 300 typedef llvm::StringMap<llvm::TrackingVH<llvm::Constant> > ReplacementsTy; 301 ReplacementsTy Replacements; 302 303 /// DeferredVTables - A queue of (optional) vtables to consider emitting. 304 std::vector<const CXXRecordDecl*> DeferredVTables; 305 306 /// LLVMUsed - List of global values which are required to be 307 /// present in the object file; bitcast to i8*. This is used for 308 /// forcing visibility of symbols which may otherwise be optimized 309 /// out. 310 std::vector<llvm::WeakVH> LLVMUsed; 311 std::vector<llvm::WeakVH> LLVMCompilerUsed; 312 313 /// GlobalCtors - Store the list of global constructors and their respective 314 /// priorities to be emitted when the translation unit is complete. 315 CtorList GlobalCtors; 316 317 /// GlobalDtors - Store the list of global destructors and their respective 318 /// priorities to be emitted when the translation unit is complete. 319 CtorList GlobalDtors; 320 321 /// MangledDeclNames - A map of canonical GlobalDecls to their mangled names. 322 llvm::DenseMap<GlobalDecl, StringRef> MangledDeclNames; 323 llvm::BumpPtrAllocator MangledNamesAllocator; 324 325 /// Global annotations. 326 std::vector<llvm::Constant*> Annotations; 327 328 /// Map used to get unique annotation strings. 329 llvm::StringMap<llvm::Constant*> AnnotationStrings; 330 331 llvm::StringMap<llvm::Constant*> CFConstantStringMap; 332 333 llvm::StringMap<llvm::GlobalVariable *> Constant1ByteStringMap; 334 llvm::StringMap<llvm::GlobalVariable *> Constant2ByteStringMap; 335 llvm::StringMap<llvm::GlobalVariable *> Constant4ByteStringMap; 336 llvm::DenseMap<const Decl*, llvm::Constant *> StaticLocalDeclMap; 337 llvm::DenseMap<const Decl*, llvm::GlobalVariable*> StaticLocalDeclGuardMap; 338 llvm::DenseMap<const Expr*, llvm::Constant *> MaterializedGlobalTemporaryMap; 339 340 llvm::DenseMap<QualType, llvm::Constant *> AtomicSetterHelperFnMap; 341 llvm::DenseMap<QualType, llvm::Constant *> AtomicGetterHelperFnMap; 342 343 /// Map used to get unique type descriptor constants for sanitizers. 344 llvm::DenseMap<QualType, llvm::Constant *> TypeDescriptorMap; 345 346 /// Map used to track internal linkage functions declared within 347 /// extern "C" regions. 348 typedef llvm::MapVector<IdentifierInfo *, 349 llvm::GlobalValue *> StaticExternCMap; 350 StaticExternCMap StaticExternCValues; 351 352 /// \brief thread_local variables defined or used in this TU. 353 std::vector<std::pair<const VarDecl *, llvm::GlobalVariable *> > 354 CXXThreadLocals; 355 356 /// \brief thread_local variables with initializers that need to run 357 /// before any thread_local variable in this TU is odr-used. 358 std::vector<llvm::Constant*> CXXThreadLocalInits; 359 360 /// CXXGlobalInits - Global variables with initializers that need to run 361 /// before main. 362 std::vector<llvm::Constant*> CXXGlobalInits; 363 364 /// When a C++ decl with an initializer is deferred, null is 365 /// appended to CXXGlobalInits, and the index of that null is placed 366 /// here so that the initializer will be performed in the correct 367 /// order. 368 llvm::DenseMap<const Decl*, unsigned> DelayedCXXInitPosition; 369 370 typedef std::pair<OrderGlobalInits, llvm::Function*> GlobalInitData; 371 372 struct GlobalInitPriorityCmp { 373 bool operator()(const GlobalInitData &LHS, 374 const GlobalInitData &RHS) const { 375 return LHS.first.priority < RHS.first.priority; 376 } 377 }; 378 379 /// - Global variables with initializers whose order of initialization 380 /// is set by init_priority attribute. 381 SmallVector<GlobalInitData, 8> PrioritizedCXXGlobalInits; 382 383 /// CXXGlobalDtors - Global destructor functions and arguments that need to 384 /// run on termination. 385 std::vector<std::pair<llvm::WeakVH,llvm::Constant*> > CXXGlobalDtors; 386 387 /// \brief The complete set of modules that has been imported. 388 llvm::SetVector<clang::Module *> ImportedModules; 389 390 /// \brief A vector of metadata strings. 391 SmallVector<llvm::Value *, 16> LinkerOptionsMetadata; 392 393 /// @name Cache for Objective-C runtime types 394 /// @{ 395 396 /// CFConstantStringClassRef - Cached reference to the class for constant 397 /// strings. This value has type int * but is actually an Obj-C class pointer. 398 llvm::WeakVH CFConstantStringClassRef; 399 400 /// ConstantStringClassRef - Cached reference to the class for constant 401 /// strings. This value has type int * but is actually an Obj-C class pointer. 402 llvm::WeakVH ConstantStringClassRef; 403 404 /// \brief The LLVM type corresponding to NSConstantString. 405 llvm::StructType *NSConstantStringType; 406 407 /// \brief The type used to describe the state of a fast enumeration in 408 /// Objective-C's for..in loop. 409 QualType ObjCFastEnumerationStateType; 410 411 /// @} 412 413 /// Lazily create the Objective-C runtime 414 void createObjCRuntime(); 415 416 void createOpenCLRuntime(); 417 void createCUDARuntime(); 418 419 bool isTriviallyRecursive(const FunctionDecl *F); 420 bool shouldEmitFunction(GlobalDecl GD); 421 422 /// @name Cache for Blocks Runtime Globals 423 /// @{ 424 425 llvm::Constant *NSConcreteGlobalBlock; 426 llvm::Constant *NSConcreteStackBlock; 427 428 llvm::Constant *BlockObjectAssign; 429 llvm::Constant *BlockObjectDispose; 430 431 llvm::Type *BlockDescriptorType; 432 llvm::Type *GenericBlockLiteralType; 433 434 struct { 435 int GlobalUniqueCount; 436 } Block; 437 438 /// void @llvm.lifetime.start(i64 %size, i8* nocapture <ptr>) 439 llvm::Constant *LifetimeStartFn; 440 441 /// void @llvm.lifetime.end(i64 %size, i8* nocapture <ptr>) 442 llvm::Constant *LifetimeEndFn; 443 444 GlobalDecl initializedGlobalDecl; 445 446 std::unique_ptr<llvm::SpecialCaseList> SanitizerBlacklist; 447 448 const SanitizerOptions &SanOpts; 449 450 /// @} 451 public: 452 CodeGenModule(ASTContext &C, const CodeGenOptions &CodeGenOpts, 453 llvm::Module &M, const llvm::DataLayout &TD, 454 DiagnosticsEngine &Diags); 455 456 ~CodeGenModule(); 457 458 void clear(); 459 460 /// Release - Finalize LLVM code generation. 461 void Release(); 462 463 /// getObjCRuntime() - Return a reference to the configured 464 /// Objective-C runtime. 465 CGObjCRuntime &getObjCRuntime() { 466 if (!ObjCRuntime) createObjCRuntime(); 467 return *ObjCRuntime; 468 } 469 470 /// hasObjCRuntime() - Return true iff an Objective-C runtime has 471 /// been configured. 472 bool hasObjCRuntime() { return !!ObjCRuntime; } 473 474 /// getOpenCLRuntime() - Return a reference to the configured OpenCL runtime. 475 CGOpenCLRuntime &getOpenCLRuntime() { 476 assert(OpenCLRuntime != 0); 477 return *OpenCLRuntime; 478 } 479 480 /// getCUDARuntime() - Return a reference to the configured CUDA runtime. 481 CGCUDARuntime &getCUDARuntime() { 482 assert(CUDARuntime != 0); 483 return *CUDARuntime; 484 } 485 486 ARCEntrypoints &getARCEntrypoints() const { 487 assert(getLangOpts().ObjCAutoRefCount && ARCData != 0); 488 return *ARCData; 489 } 490 491 RREntrypoints &getRREntrypoints() const { 492 assert(RRData != 0); 493 return *RRData; 494 } 495 496 InstrProfStats &getPGOStats() { return PGOStats; } 497 llvm::IndexedInstrProfReader *getPGOReader() const { return PGOReader.get(); } 498 499 llvm::Constant *getStaticLocalDeclAddress(const VarDecl *D) { 500 return StaticLocalDeclMap[D]; 501 } 502 void setStaticLocalDeclAddress(const VarDecl *D, 503 llvm::Constant *C) { 504 StaticLocalDeclMap[D] = C; 505 } 506 507 llvm::GlobalVariable *getStaticLocalDeclGuardAddress(const VarDecl *D) { 508 return StaticLocalDeclGuardMap[D]; 509 } 510 void setStaticLocalDeclGuardAddress(const VarDecl *D, 511 llvm::GlobalVariable *C) { 512 StaticLocalDeclGuardMap[D] = C; 513 } 514 515 llvm::Constant *getAtomicSetterHelperFnMap(QualType Ty) { 516 return AtomicSetterHelperFnMap[Ty]; 517 } 518 void setAtomicSetterHelperFnMap(QualType Ty, 519 llvm::Constant *Fn) { 520 AtomicSetterHelperFnMap[Ty] = Fn; 521 } 522 523 llvm::Constant *getAtomicGetterHelperFnMap(QualType Ty) { 524 return AtomicGetterHelperFnMap[Ty]; 525 } 526 void setAtomicGetterHelperFnMap(QualType Ty, 527 llvm::Constant *Fn) { 528 AtomicGetterHelperFnMap[Ty] = Fn; 529 } 530 531 llvm::Constant *getTypeDescriptor(QualType Ty) { 532 return TypeDescriptorMap[Ty]; 533 } 534 void setTypeDescriptor(QualType Ty, llvm::Constant *C) { 535 TypeDescriptorMap[Ty] = C; 536 } 537 538 CGDebugInfo *getModuleDebugInfo() { return DebugInfo; } 539 540 llvm::MDNode *getNoObjCARCExceptionsMetadata() { 541 if (!NoObjCARCExceptionsMetadata) 542 NoObjCARCExceptionsMetadata = 543 llvm::MDNode::get(getLLVMContext(), 544 SmallVector<llvm::Value*,1>()); 545 return NoObjCARCExceptionsMetadata; 546 } 547 548 ASTContext &getContext() const { return Context; } 549 const LangOptions &getLangOpts() const { return LangOpts; } 550 const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; } 551 llvm::Module &getModule() const { return TheModule; } 552 DiagnosticsEngine &getDiags() const { return Diags; } 553 const llvm::DataLayout &getDataLayout() const { return TheDataLayout; } 554 const TargetInfo &getTarget() const { return Target; } 555 CGCXXABI &getCXXABI() const { return *ABI; } 556 llvm::LLVMContext &getLLVMContext() { return VMContext; } 557 558 bool shouldUseTBAA() const { return TBAA != 0; } 559 560 const TargetCodeGenInfo &getTargetCodeGenInfo(); 561 562 CodeGenTypes &getTypes() { return Types; } 563 564 CodeGenVTables &getVTables() { return VTables; } 565 566 ItaniumVTableContext &getItaniumVTableContext() { 567 return VTables.getItaniumVTableContext(); 568 } 569 570 MicrosoftVTableContext &getMicrosoftVTableContext() { 571 return VTables.getMicrosoftVTableContext(); 572 } 573 574 llvm::MDNode *getTBAAInfo(QualType QTy); 575 llvm::MDNode *getTBAAInfoForVTablePtr(); 576 llvm::MDNode *getTBAAStructInfo(QualType QTy); 577 /// Return the MDNode in the type DAG for the given struct type. 578 llvm::MDNode *getTBAAStructTypeInfo(QualType QTy); 579 /// Return the path-aware tag for given base type, access node and offset. 580 llvm::MDNode *getTBAAStructTagInfo(QualType BaseTy, llvm::MDNode *AccessN, 581 uint64_t O); 582 583 bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor); 584 585 bool isPaddedAtomicType(QualType type); 586 bool isPaddedAtomicType(const AtomicType *type); 587 588 /// Decorate the instruction with a TBAA tag. For scalar TBAA, the tag 589 /// is the same as the type. For struct-path aware TBAA, the tag 590 /// is different from the type: base type, access type and offset. 591 /// When ConvertTypeToTag is true, we create a tag based on the scalar type. 592 void DecorateInstruction(llvm::Instruction *Inst, 593 llvm::MDNode *TBAAInfo, 594 bool ConvertTypeToTag = true); 595 596 /// getSize - Emit the given number of characters as a value of type size_t. 597 llvm::ConstantInt *getSize(CharUnits numChars); 598 599 /// setGlobalVisibility - Set the visibility for the given LLVM 600 /// GlobalValue. 601 void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const; 602 603 /// setTLSMode - Set the TLS mode for the given LLVM GlobalVariable 604 /// for the thread-local variable declaration D. 605 void setTLSMode(llvm::GlobalVariable *GV, const VarDecl &D) const; 606 607 static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V) { 608 switch (V) { 609 case DefaultVisibility: return llvm::GlobalValue::DefaultVisibility; 610 case HiddenVisibility: return llvm::GlobalValue::HiddenVisibility; 611 case ProtectedVisibility: return llvm::GlobalValue::ProtectedVisibility; 612 } 613 llvm_unreachable("unknown visibility!"); 614 } 615 616 llvm::Constant *GetAddrOfGlobal(GlobalDecl GD) { 617 if (isa<CXXConstructorDecl>(GD.getDecl())) 618 return GetAddrOfCXXConstructor(cast<CXXConstructorDecl>(GD.getDecl()), 619 GD.getCtorType()); 620 else if (isa<CXXDestructorDecl>(GD.getDecl())) 621 return GetAddrOfCXXDestructor(cast<CXXDestructorDecl>(GD.getDecl()), 622 GD.getDtorType()); 623 else if (isa<FunctionDecl>(GD.getDecl())) 624 return GetAddrOfFunction(GD); 625 else 626 return GetAddrOfGlobalVar(cast<VarDecl>(GD.getDecl())); 627 } 628 629 /// CreateOrReplaceCXXRuntimeVariable - Will return a global variable of the 630 /// given type. If a variable with a different type already exists then a new 631 /// variable with the right type will be created and all uses of the old 632 /// variable will be replaced with a bitcast to the new variable. 633 llvm::GlobalVariable * 634 CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty, 635 llvm::GlobalValue::LinkageTypes Linkage); 636 637 /// GetGlobalVarAddressSpace - Return the address space of the underlying 638 /// global variable for D, as determined by its declaration. Normally this 639 /// is the same as the address space of D's type, but in CUDA, address spaces 640 /// are associated with declarations, not types. 641 unsigned GetGlobalVarAddressSpace(const VarDecl *D, unsigned AddrSpace); 642 643 /// GetAddrOfGlobalVar - Return the llvm::Constant for the address of the 644 /// given global variable. If Ty is non-null and if the global doesn't exist, 645 /// then it will be greated with the specified type instead of whatever the 646 /// normal requested type would be. 647 llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D, 648 llvm::Type *Ty = 0); 649 650 651 /// GetAddrOfFunction - Return the address of the given function. If Ty is 652 /// non-null, then this function will use the specified type if it has to 653 /// create it. 654 llvm::Constant *GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty = 0, 655 bool ForVTable = false, 656 bool DontDefer = false); 657 658 /// GetAddrOfRTTIDescriptor - Get the address of the RTTI descriptor 659 /// for the given type. 660 llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false); 661 662 /// GetAddrOfUuidDescriptor - Get the address of a uuid descriptor . 663 llvm::Constant *GetAddrOfUuidDescriptor(const CXXUuidofExpr* E); 664 665 /// GetAddrOfThunk - Get the address of the thunk for the given global decl. 666 llvm::Constant *GetAddrOfThunk(GlobalDecl GD, const ThunkInfo &Thunk); 667 668 /// GetWeakRefReference - Get a reference to the target of VD. 669 llvm::Constant *GetWeakRefReference(const ValueDecl *VD); 670 671 /// GetNonVirtualBaseClassOffset - Returns the offset from a derived class to 672 /// a class. Returns null if the offset is 0. 673 llvm::Constant * 674 GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl, 675 CastExpr::path_const_iterator PathBegin, 676 CastExpr::path_const_iterator PathEnd); 677 678 /// A pair of helper functions for a __block variable. 679 class ByrefHelpers : public llvm::FoldingSetNode { 680 public: 681 llvm::Constant *CopyHelper; 682 llvm::Constant *DisposeHelper; 683 684 /// The alignment of the field. This is important because 685 /// different offsets to the field within the byref struct need to 686 /// have different helper functions. 687 CharUnits Alignment; 688 689 ByrefHelpers(CharUnits alignment) : Alignment(alignment) {} 690 virtual ~ByrefHelpers(); 691 692 void Profile(llvm::FoldingSetNodeID &id) const { 693 id.AddInteger(Alignment.getQuantity()); 694 profileImpl(id); 695 } 696 virtual void profileImpl(llvm::FoldingSetNodeID &id) const = 0; 697 698 virtual bool needsCopy() const { return true; } 699 virtual void emitCopy(CodeGenFunction &CGF, 700 llvm::Value *dest, llvm::Value *src) = 0; 701 702 virtual bool needsDispose() const { return true; } 703 virtual void emitDispose(CodeGenFunction &CGF, llvm::Value *field) = 0; 704 }; 705 706 llvm::FoldingSet<ByrefHelpers> ByrefHelpersCache; 707 708 /// getUniqueBlockCount - Fetches the global unique block count. 709 int getUniqueBlockCount() { return ++Block.GlobalUniqueCount; } 710 711 /// getBlockDescriptorType - Fetches the type of a generic block 712 /// descriptor. 713 llvm::Type *getBlockDescriptorType(); 714 715 /// getGenericBlockLiteralType - The type of a generic block literal. 716 llvm::Type *getGenericBlockLiteralType(); 717 718 /// GetAddrOfGlobalBlock - Gets the address of a block which 719 /// requires no captures. 720 llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, const char *); 721 722 /// GetAddrOfConstantCFString - Return a pointer to a constant CFString object 723 /// for the given string. 724 llvm::Constant *GetAddrOfConstantCFString(const StringLiteral *Literal); 725 726 /// GetAddrOfConstantString - Return a pointer to a constant NSString object 727 /// for the given string. Or a user defined String object as defined via 728 /// -fconstant-string-class=class_name option. 729 llvm::Constant *GetAddrOfConstantString(const StringLiteral *Literal); 730 731 /// GetConstantArrayFromStringLiteral - Return a constant array for the given 732 /// string. 733 llvm::Constant *GetConstantArrayFromStringLiteral(const StringLiteral *E); 734 735 /// GetAddrOfConstantStringFromLiteral - Return a pointer to a constant array 736 /// for the given string literal. 737 llvm::Constant *GetAddrOfConstantStringFromLiteral(const StringLiteral *S); 738 739 /// GetAddrOfConstantStringFromObjCEncode - Return a pointer to a constant 740 /// array for the given ObjCEncodeExpr node. 741 llvm::Constant *GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *); 742 743 /// GetAddrOfConstantString - Returns a pointer to a character array 744 /// containing the literal. This contents are exactly that of the given 745 /// string, i.e. it will not be null terminated automatically; see 746 /// GetAddrOfConstantCString. Note that whether the result is actually a 747 /// pointer to an LLVM constant depends on Feature.WriteableStrings. 748 /// 749 /// The result has pointer to array type. 750 /// 751 /// \param GlobalName If provided, the name to use for the global 752 /// (if one is created). 753 llvm::Constant *GetAddrOfConstantString(StringRef Str, 754 const char *GlobalName=0, 755 unsigned Alignment=0); 756 757 /// GetAddrOfConstantCString - Returns a pointer to a character array 758 /// containing the literal and a terminating '\0' character. The result has 759 /// pointer to array type. 760 /// 761 /// \param GlobalName If provided, the name to use for the global (if one is 762 /// created). 763 llvm::Constant *GetAddrOfConstantCString(const std::string &str, 764 const char *GlobalName=0, 765 unsigned Alignment=0); 766 767 /// GetAddrOfConstantCompoundLiteral - Returns a pointer to a constant global 768 /// variable for the given file-scope compound literal expression. 769 llvm::Constant *GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr*E); 770 771 /// \brief Returns a pointer to a global variable representing a temporary 772 /// with static or thread storage duration. 773 llvm::Constant *GetAddrOfGlobalTemporary(const MaterializeTemporaryExpr *E, 774 const Expr *Inner); 775 776 /// \brief Retrieve the record type that describes the state of an 777 /// Objective-C fast enumeration loop (for..in). 778 QualType getObjCFastEnumerationStateType(); 779 780 /// GetAddrOfCXXConstructor - Return the address of the constructor of the 781 /// given type. 782 llvm::GlobalValue *GetAddrOfCXXConstructor(const CXXConstructorDecl *ctor, 783 CXXCtorType ctorType, 784 const CGFunctionInfo *fnInfo = 0, 785 bool DontDefer = false); 786 787 /// GetAddrOfCXXDestructor - Return the address of the constructor of the 788 /// given type. 789 llvm::GlobalValue *GetAddrOfCXXDestructor(const CXXDestructorDecl *dtor, 790 CXXDtorType dtorType, 791 const CGFunctionInfo *fnInfo = 0, 792 llvm::FunctionType *fnType = 0, 793 bool DontDefer = false); 794 795 /// getBuiltinLibFunction - Given a builtin id for a function like 796 /// "__builtin_fabsf", return a Function* for "fabsf". 797 llvm::Value *getBuiltinLibFunction(const FunctionDecl *FD, 798 unsigned BuiltinID); 799 800 llvm::Function *getIntrinsic(unsigned IID, ArrayRef<llvm::Type*> Tys = None); 801 802 /// EmitTopLevelDecl - Emit code for a single top level declaration. 803 void EmitTopLevelDecl(Decl *D); 804 805 /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this 806 // variable has been instantiated. 807 void HandleCXXStaticMemberVarInstantiation(VarDecl *VD); 808 809 /// \brief If the declaration has internal linkage but is inside an 810 /// extern "C" linkage specification, prepare to emit an alias for it 811 /// to the expected name. 812 template<typename SomeDecl> 813 void MaybeHandleStaticInExternC(const SomeDecl *D, llvm::GlobalValue *GV); 814 815 /// Add a global to a list to be added to the llvm.used metadata. 816 void addUsedGlobal(llvm::GlobalValue *GV); 817 818 /// Add a global to a list to be added to the llvm.compiler.used metadata. 819 void addCompilerUsedGlobal(llvm::GlobalValue *GV); 820 821 /// AddCXXDtorEntry - Add a destructor and object to add to the C++ global 822 /// destructor function. 823 void AddCXXDtorEntry(llvm::Constant *DtorFn, llvm::Constant *Object) { 824 CXXGlobalDtors.push_back(std::make_pair(DtorFn, Object)); 825 } 826 827 /// CreateRuntimeFunction - Create a new runtime function with the specified 828 /// type and name. 829 llvm::Constant *CreateRuntimeFunction(llvm::FunctionType *Ty, 830 StringRef Name, 831 llvm::AttributeSet ExtraAttrs = 832 llvm::AttributeSet()); 833 /// CreateRuntimeVariable - Create a new runtime global variable with the 834 /// specified type and name. 835 llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty, 836 StringRef Name); 837 838 ///@name Custom Blocks Runtime Interfaces 839 ///@{ 840 841 llvm::Constant *getNSConcreteGlobalBlock(); 842 llvm::Constant *getNSConcreteStackBlock(); 843 llvm::Constant *getBlockObjectAssign(); 844 llvm::Constant *getBlockObjectDispose(); 845 846 ///@} 847 848 llvm::Constant *getLLVMLifetimeStartFn(); 849 llvm::Constant *getLLVMLifetimeEndFn(); 850 851 // UpdateCompleteType - Make sure that this type is translated. 852 void UpdateCompletedType(const TagDecl *TD); 853 854 llvm::Constant *getMemberPointerConstant(const UnaryOperator *e); 855 856 /// EmitConstantInit - Try to emit the initializer for the given declaration 857 /// as a constant; returns 0 if the expression cannot be emitted as a 858 /// constant. 859 llvm::Constant *EmitConstantInit(const VarDecl &D, CodeGenFunction *CGF = 0); 860 861 /// EmitConstantExpr - Try to emit the given expression as a 862 /// constant; returns 0 if the expression cannot be emitted as a 863 /// constant. 864 llvm::Constant *EmitConstantExpr(const Expr *E, QualType DestType, 865 CodeGenFunction *CGF = 0); 866 867 /// EmitConstantValue - Emit the given constant value as a constant, in the 868 /// type's scalar representation. 869 llvm::Constant *EmitConstantValue(const APValue &Value, QualType DestType, 870 CodeGenFunction *CGF = 0); 871 872 /// EmitConstantValueForMemory - Emit the given constant value as a constant, 873 /// in the type's memory representation. 874 llvm::Constant *EmitConstantValueForMemory(const APValue &Value, 875 QualType DestType, 876 CodeGenFunction *CGF = 0); 877 878 /// EmitNullConstant - Return the result of value-initializing the given 879 /// type, i.e. a null expression of the given type. This is usually, 880 /// but not always, an LLVM null constant. 881 llvm::Constant *EmitNullConstant(QualType T); 882 883 /// EmitNullConstantForBase - Return a null constant appropriate for 884 /// zero-initializing a base class with the given type. This is usually, 885 /// but not always, an LLVM null constant. 886 llvm::Constant *EmitNullConstantForBase(const CXXRecordDecl *Record); 887 888 /// Error - Emit a general error that something can't be done. 889 void Error(SourceLocation loc, StringRef error); 890 891 /// ErrorUnsupported - Print out an error that codegen doesn't support the 892 /// specified stmt yet. 893 void ErrorUnsupported(const Stmt *S, const char *Type); 894 895 /// ErrorUnsupported - Print out an error that codegen doesn't support the 896 /// specified decl yet. 897 void ErrorUnsupported(const Decl *D, const char *Type); 898 899 /// SetInternalFunctionAttributes - Set the attributes on the LLVM 900 /// function for the given decl and function info. This applies 901 /// attributes necessary for handling the ABI as well as user 902 /// specified attributes like section. 903 void SetInternalFunctionAttributes(const Decl *D, llvm::Function *F, 904 const CGFunctionInfo &FI); 905 906 /// SetLLVMFunctionAttributes - Set the LLVM function attributes 907 /// (sext, zext, etc). 908 void SetLLVMFunctionAttributes(const Decl *D, 909 const CGFunctionInfo &Info, 910 llvm::Function *F); 911 912 /// SetLLVMFunctionAttributesForDefinition - Set the LLVM function attributes 913 /// which only apply to a function definintion. 914 void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F); 915 916 /// ReturnTypeUsesSRet - Return true iff the given type uses 'sret' when used 917 /// as a return type. 918 bool ReturnTypeUsesSRet(const CGFunctionInfo &FI); 919 920 /// ReturnSlotInterferesWithArgs - Return true iff the given type uses an 921 /// argument slot when 'sret' is used as a return type. 922 bool ReturnSlotInterferesWithArgs(const CGFunctionInfo &FI); 923 924 /// ReturnTypeUsesFPRet - Return true iff the given type uses 'fpret' when 925 /// used as a return type. 926 bool ReturnTypeUsesFPRet(QualType ResultType); 927 928 /// ReturnTypeUsesFP2Ret - Return true iff the given type uses 'fp2ret' when 929 /// used as a return type. 930 bool ReturnTypeUsesFP2Ret(QualType ResultType); 931 932 /// ConstructAttributeList - Get the LLVM attributes and calling convention to 933 /// use for a particular function type. 934 /// 935 /// \param Info - The function type information. 936 /// \param TargetDecl - The decl these attributes are being constructed 937 /// for. If supplied the attributes applied to this decl may contribute to the 938 /// function attributes and calling convention. 939 /// \param PAL [out] - On return, the attribute list to use. 940 /// \param CallingConv [out] - On return, the LLVM calling convention to use. 941 void ConstructAttributeList(const CGFunctionInfo &Info, 942 const Decl *TargetDecl, 943 AttributeListType &PAL, 944 unsigned &CallingConv, 945 bool AttrOnCallSite); 946 947 StringRef getMangledName(GlobalDecl GD); 948 void getBlockMangledName(GlobalDecl GD, MangleBuffer &Buffer, 949 const BlockDecl *BD); 950 951 void EmitTentativeDefinition(const VarDecl *D); 952 953 void EmitVTable(CXXRecordDecl *Class, bool DefinitionRequired); 954 955 /// EmitFundamentalRTTIDescriptors - Emit the RTTI descriptors for the 956 /// builtin types. 957 void EmitFundamentalRTTIDescriptors(); 958 959 /// \brief Appends Opts to the "Linker Options" metadata value. 960 void AppendLinkerOptions(StringRef Opts); 961 962 /// \brief Appends a detect mismatch command to the linker options. 963 void AddDetectMismatch(StringRef Name, StringRef Value); 964 965 /// \brief Appends a dependent lib to the "Linker Options" metadata value. 966 void AddDependentLib(StringRef Lib); 967 968 llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD); 969 970 void setFunctionLinkage(GlobalDecl GD, llvm::GlobalValue *V) { 971 V->setLinkage(getFunctionLinkage(GD)); 972 } 973 974 /// getVTableLinkage - Return the appropriate linkage for the vtable, VTT, 975 /// and type information of the given class. 976 llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD); 977 978 /// GetTargetTypeStoreSize - Return the store size, in character units, of 979 /// the given LLVM type. 980 CharUnits GetTargetTypeStoreSize(llvm::Type *Ty) const; 981 982 /// getLLVMLinkageforDeclarator - Returns LLVM linkage for a declarator. 983 llvm::GlobalValue::LinkageTypes 984 getLLVMLinkageforDeclarator(const DeclaratorDecl *D, GVALinkage Linkage, 985 bool IsConstantVariable, 986 bool UseThunkForDtorVariant); 987 988 /// getLLVMLinkageVarDefinition - Returns LLVM linkage for a declarator. 989 llvm::GlobalValue::LinkageTypes 990 getLLVMLinkageVarDefinition(const VarDecl *VD, bool IsConstant); 991 992 /// Emit all the global annotations. 993 void EmitGlobalAnnotations(); 994 995 /// Emit an annotation string. 996 llvm::Constant *EmitAnnotationString(StringRef Str); 997 998 /// Emit the annotation's translation unit. 999 llvm::Constant *EmitAnnotationUnit(SourceLocation Loc); 1000 1001 /// Emit the annotation line number. 1002 llvm::Constant *EmitAnnotationLineNo(SourceLocation L); 1003 1004 /// EmitAnnotateAttr - Generate the llvm::ConstantStruct which contains the 1005 /// annotation information for a given GlobalValue. The annotation struct is 1006 /// {i8 *, i8 *, i8 *, i32}. The first field is a constant expression, the 1007 /// GlobalValue being annotated. The second field is the constant string 1008 /// created from the AnnotateAttr's annotation. The third field is a constant 1009 /// string containing the name of the translation unit. The fourth field is 1010 /// the line number in the file of the annotated value declaration. 1011 llvm::Constant *EmitAnnotateAttr(llvm::GlobalValue *GV, 1012 const AnnotateAttr *AA, 1013 SourceLocation L); 1014 1015 /// Add global annotations that are set on D, for the global GV. Those 1016 /// annotations are emitted during finalization of the LLVM code. 1017 void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV); 1018 1019 const llvm::SpecialCaseList &getSanitizerBlacklist() const { 1020 return *SanitizerBlacklist; 1021 } 1022 1023 const SanitizerOptions &getSanOpts() const { return SanOpts; } 1024 1025 void addDeferredVTable(const CXXRecordDecl *RD) { 1026 DeferredVTables.push_back(RD); 1027 } 1028 1029 /// EmitGlobal - Emit code for a singal global function or var decl. Forward 1030 /// declarations are emitted lazily. 1031 void EmitGlobal(GlobalDecl D); 1032 1033 private: 1034 llvm::GlobalValue *GetGlobalValue(StringRef Ref); 1035 1036 llvm::Constant * 1037 GetOrCreateLLVMFunction(StringRef MangledName, llvm::Type *Ty, GlobalDecl D, 1038 bool ForVTable, bool DontDefer = false, 1039 llvm::AttributeSet ExtraAttrs = llvm::AttributeSet()); 1040 1041 llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName, 1042 llvm::PointerType *PTy, 1043 const VarDecl *D, 1044 bool UnnamedAddr = false); 1045 1046 /// SetCommonAttributes - Set attributes which are common to any 1047 /// form of a global definition (alias, Objective-C method, 1048 /// function, global variable). 1049 /// 1050 /// NOTE: This should only be called for definitions. 1051 void SetCommonAttributes(const Decl *D, llvm::GlobalValue *GV); 1052 1053 /// SetFunctionDefinitionAttributes - Set attributes for a global definition. 1054 void SetFunctionDefinitionAttributes(const FunctionDecl *D, 1055 llvm::GlobalValue *GV); 1056 1057 /// SetFunctionAttributes - Set function attributes for a function 1058 /// declaration. 1059 void SetFunctionAttributes(GlobalDecl GD, 1060 llvm::Function *F, 1061 bool IsIncompleteFunction); 1062 1063 void EmitGlobalDefinition(GlobalDecl D, llvm::GlobalValue *GV = 0); 1064 1065 void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV); 1066 void EmitGlobalVarDefinition(const VarDecl *D); 1067 void EmitAliasDefinition(GlobalDecl GD); 1068 void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D); 1069 void EmitObjCIvarInitializations(ObjCImplementationDecl *D); 1070 1071 // C++ related functions. 1072 1073 bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target, 1074 bool InEveryTU); 1075 bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D); 1076 1077 void EmitNamespace(const NamespaceDecl *D); 1078 void EmitLinkageSpec(const LinkageSpecDecl *D); 1079 void CompleteDIClassType(const CXXMethodDecl* D); 1080 1081 /// EmitCXXConstructor - Emit a single constructor with the given type from 1082 /// a C++ constructor Decl. 1083 void EmitCXXConstructor(const CXXConstructorDecl *D, CXXCtorType Type); 1084 1085 /// EmitCXXDestructor - Emit a single destructor with the given type from 1086 /// a C++ destructor Decl. 1087 void EmitCXXDestructor(const CXXDestructorDecl *D, CXXDtorType Type); 1088 1089 /// \brief Emit the function that initializes C++ thread_local variables. 1090 void EmitCXXThreadLocalInitFunc(); 1091 1092 /// EmitCXXGlobalInitFunc - Emit the function that initializes C++ globals. 1093 void EmitCXXGlobalInitFunc(); 1094 1095 /// EmitCXXGlobalDtorFunc - Emit the function that destroys C++ globals. 1096 void EmitCXXGlobalDtorFunc(); 1097 1098 /// EmitCXXGlobalVarDeclInitFunc - Emit the function that initializes the 1099 /// specified global (if PerformInit is true) and registers its destructor. 1100 void EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, 1101 llvm::GlobalVariable *Addr, 1102 bool PerformInit); 1103 1104 // FIXME: Hardcoding priority here is gross. 1105 void AddGlobalCtor(llvm::Function *Ctor, int Priority=65535); 1106 void AddGlobalDtor(llvm::Function *Dtor, int Priority=65535); 1107 1108 /// EmitCtorList - Generates a global array of functions and priorities using 1109 /// the given list and name. This array will have appending linkage and is 1110 /// suitable for use as a LLVM constructor or destructor array. 1111 void EmitCtorList(const CtorList &Fns, const char *GlobalName); 1112 1113 /// EmitFundamentalRTTIDescriptor - Emit the RTTI descriptors for the 1114 /// given type. 1115 void EmitFundamentalRTTIDescriptor(QualType Type); 1116 1117 /// EmitDeferred - Emit any needed decls for which code generation 1118 /// was deferred. 1119 void EmitDeferred(); 1120 1121 /// Call replaceAllUsesWith on all pairs in Replacements. 1122 void applyReplacements(); 1123 1124 void checkAliases(); 1125 1126 /// EmitDeferredVTables - Emit any vtables which we deferred and 1127 /// still have a use for. 1128 void EmitDeferredVTables(); 1129 1130 /// Emit the llvm.used and llvm.compiler.used metadata. 1131 void emitLLVMUsed(); 1132 1133 /// \brief Emit the link options introduced by imported modules. 1134 void EmitModuleLinkOptions(); 1135 1136 /// \brief Emit aliases for internal-linkage declarations inside "C" language 1137 /// linkage specifications, giving them the "expected" name where possible. 1138 void EmitStaticExternCAliases(); 1139 1140 void EmitDeclMetadata(); 1141 1142 /// \brief Emit the Clang version as llvm.ident metadata. 1143 void EmitVersionIdentMetadata(); 1144 1145 /// EmitCoverageFile - Emit the llvm.gcov metadata used to tell LLVM where 1146 /// to emit the .gcno and .gcda files in a way that persists in .bc files. 1147 void EmitCoverageFile(); 1148 1149 /// Emits the initializer for a uuidof string. 1150 llvm::Constant *EmitUuidofInitializer(StringRef uuidstr, QualType IIDType); 1151 1152 /// MayDeferGeneration - Determine if the given decl can be emitted 1153 /// lazily; this is only relevant for definitions. The given decl 1154 /// must be either a function or var decl. 1155 bool MayDeferGeneration(const ValueDecl *D); 1156 1157 /// SimplifyPersonality - Check whether we can use a "simpler", more 1158 /// core exceptions personality function. 1159 void SimplifyPersonality(); 1160 }; 1161 } // end namespace CodeGen 1162 } // end namespace clang 1163 1164 #endif 1165