diff options
Diffstat (limited to 'lib/CodeGen/CodeGenModule.h')
-rw-r--r-- | lib/CodeGen/CodeGenModule.h | 99 |
1 files changed, 79 insertions, 20 deletions
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index 1167c87..5b2153e 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -14,20 +14,24 @@ #ifndef CLANG_CODEGEN_CODEGENMODULE_H #define CLANG_CODEGEN_CODEGENMODULE_H -#include "clang/Basic/ABI.h" -#include "clang/Basic/LangOptions.h" +#include "CGVTables.h" +#include "CodeGenTypes.h" #include "clang/AST/Attr.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/GlobalDecl.h" #include "clang/AST/Mangle.h" -#include "CGVTables.h" -#include "CodeGenTypes.h" -#include "llvm/Module.h" +#include "clang/Basic/ABI.h" +#include "clang/Basic/LangOptions.h" +#include "clang/Basic/Module.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/IR/CallingConv.h" +#include "llvm/IR/Module.h" #include "llvm/Support/ValueHandle.h" +#include "llvm/Transforms/Utils/BlackList.h" namespace llvm { class Module; @@ -43,6 +47,7 @@ namespace llvm { namespace clang { class TargetCodeGenInfo; class ASTContext; + class AtomicType; class FunctionDecl; class IdentifierInfo; class ObjCMethodDecl; @@ -62,10 +67,12 @@ namespace clang { class VarDecl; class LangOptions; class CodeGenOptions; + class TargetOptions; class DiagnosticsEngine; class AnnotateAttr; class CXXDestructorDecl; class MangleBuffer; + class Module; namespace CodeGen { @@ -140,6 +147,11 @@ namespace CodeGen { unsigned char PointerSizeInBytes; unsigned char SizeSizeInBytes; // sizeof(size_t) }; + + llvm::CallingConv::ID RuntimeCC; + llvm::CallingConv::ID getRuntimeCC() const { + return RuntimeCC; + } }; struct RREntrypoints { @@ -205,8 +217,11 @@ struct ARCEntrypoints { /// A void(void) inline asm to use to mark that the return value of /// a call will be immediately retain. llvm::InlineAsm *retainAutoreleasedReturnValueMarker; + + /// void clang.arc.use(...); + llvm::Constant *clang_arc_use; }; - + /// CodeGenModule - This class organizes the cross-function state that is used /// while generating LLVM code. class CodeGenModule : public CodeGenTypeCache { @@ -218,6 +233,7 @@ class CodeGenModule : public CodeGenTypeCache { ASTContext &Context; const LangOptions &LangOpts; const CodeGenOptions &CodeGenOpts; + const TargetOptions &TargetOpts; llvm::Module &TheModule; const llvm::DataLayout &TheDataLayout; mutable const TargetCodeGenInfo *TheTargetCodeGenInfo; @@ -254,6 +270,9 @@ class CodeGenModule : public CodeGenTypeCache { /// is done. std::vector<GlobalDecl> DeferredDeclsToEmit; + /// DeferredVTables - A queue of (optional) vtables to consider emitting. + std::vector<const CXXRecordDecl*> DeferredVTables; + /// LLVMUsed - List of global values which are required to be /// present in the object file; bitcast to i8*. This is used for /// forcing visibility of symbols which may otherwise be optimized @@ -313,6 +332,9 @@ class CodeGenModule : public CodeGenTypeCache { /// run on termination. std::vector<std::pair<llvm::WeakVH,llvm::Constant*> > CXXGlobalDtors; + /// \brief The complete set of modules that has been imported. + llvm::SetVector<clang::Module *> ImportedModules; + /// @name Cache for Objective-C runtime types /// @{ @@ -358,14 +380,24 @@ class CodeGenModule : public CodeGenTypeCache { struct { int GlobalUniqueCount; } Block; - + + /// void @llvm.lifetime.start(i64 %size, i8* nocapture <ptr>) + llvm::Constant *LifetimeStartFn; + + /// void @llvm.lifetime.end(i64 %size, i8* nocapture <ptr>) + llvm::Constant *LifetimeEndFn; + GlobalDecl initializedGlobalDecl; + llvm::BlackList SanitizerBlacklist; + + const SanitizerOptions &SanOpts; + /// @} public: CodeGenModule(ASTContext &C, const CodeGenOptions &CodeGenOpts, - llvm::Module &M, const llvm::DataLayout &TD, - DiagnosticsEngine &Diags); + const TargetOptions &TargetOpts, llvm::Module &M, + const llvm::DataLayout &TD, DiagnosticsEngine &Diags); ~CodeGenModule(); @@ -469,9 +501,17 @@ public: llvm::MDNode *getTBAAInfo(QualType QTy); llvm::MDNode *getTBAAInfoForVTablePtr(); llvm::MDNode *getTBAAStructInfo(QualType QTy); + /// Return the MDNode in the type DAG for the given struct type. + llvm::MDNode *getTBAAStructTypeInfo(QualType QTy); + /// Return the path-aware tag for given base type, access node and offset. + llvm::MDNode *getTBAAStructTagInfo(QualType BaseTy, llvm::MDNode *AccessN, + uint64_t O); bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor); + bool isPaddedAtomicType(QualType type); + bool isPaddedAtomicType(const AtomicType *type); + static void DecorateInstruction(llvm::Instruction *Inst, llvm::MDNode *TBAAInfo); @@ -711,8 +751,8 @@ public: /// type and name. llvm::Constant *CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, - llvm::Attributes ExtraAttrs = - llvm::Attributes()); + llvm::AttributeSet ExtraAttrs = + llvm::AttributeSet()); /// CreateRuntimeVariable - Create a new runtime global variable with the /// specified type and name. llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty, @@ -728,6 +768,9 @@ public: ///@} + llvm::Constant *getLLVMLifetimeStartFn(); + llvm::Constant *getLLVMLifetimeEndFn(); + // UpdateCompleteType - Make sure that this type is translated. void UpdateCompletedType(const TagDecl *TD); @@ -823,7 +866,8 @@ public: void ConstructAttributeList(const CGFunctionInfo &Info, const Decl *TargetDecl, AttributeListType &PAL, - unsigned &CallingConv); + unsigned &CallingConv, + bool AttrOnCallSite); StringRef getMangledName(GlobalDecl GD); void getBlockMangledName(GlobalDecl GD, MangleBuffer &Buffer, @@ -854,13 +898,11 @@ public: GetLLVMLinkageVarDefinition(const VarDecl *D, llvm::GlobalVariable *GV); - std::vector<const CXXRecordDecl*> DeferredVTables; - /// Emit all the global annotations. void EmitGlobalAnnotations(); /// Emit an annotation string. - llvm::Constant *EmitAnnotationString(llvm::StringRef Str); + llvm::Constant *EmitAnnotationString(StringRef Str); /// Emit the annotation's translation unit. llvm::Constant *EmitAnnotationUnit(SourceLocation Loc); @@ -883,6 +925,16 @@ public: /// annotations are emitted during finalization of the LLVM code. void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV); + const llvm::BlackList &getSanitizerBlacklist() const { + return SanitizerBlacklist; + } + + const SanitizerOptions &getSanOpts() const { return SanOpts; } + + void addDeferredVTable(const CXXRecordDecl *RD) { + DeferredVTables.push_back(RD); + } + private: llvm::GlobalValue *GetGlobalValue(StringRef Ref); @@ -890,8 +942,8 @@ private: llvm::Type *Ty, GlobalDecl D, bool ForVTable, - llvm::Attributes ExtraAttrs = - llvm::Attributes()); + llvm::AttributeSet ExtraAttrs = + llvm::AttributeSet()); llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName, llvm::PointerType *PTy, const VarDecl *D, @@ -983,11 +1035,18 @@ private: /// EmitDeferred - Emit any needed decls for which code generation /// was deferred. - void EmitDeferred(void); + void EmitDeferred(); + + /// EmitDeferredVTables - Emit any vtables which we deferred and + /// still have a use for. + void EmitDeferredVTables(); /// EmitLLVMUsed - Emit the llvm.used metadata used to force /// references to global which may otherwise be optimized out. - void EmitLLVMUsed(void); + void EmitLLVMUsed(); + + /// \brief Emit the link options introduced by imported modules. + void EmitModuleLinkOptions(); void EmitDeclMetadata(); |