clang  6.0.0svn
Functions | Variables
CodeGenModule.cpp File Reference
#include "CodeGenModule.h"
#include "CGBlocks.h"
#include "CGCUDARuntime.h"
#include "CGCXXABI.h"
#include "CGCall.h"
#include "CGDebugInfo.h"
#include "CGObjCRuntime.h"
#include "CGOpenCLRuntime.h"
#include "CGOpenMPRuntime.h"
#include "CGOpenMPRuntimeNVPTX.h"
#include "CodeGenFunction.h"
#include "CodeGenPGO.h"
#include "ConstantEmitter.h"
#include "CoverageMappingGen.h"
#include "TargetInfo.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Mangle.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/Module.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Version.h"
#include "clang/CodeGen/ConstantInitBuilder.h"
#include "clang/Frontend/CodeGenOptions.h"
#include "clang/Sema/SemaDiagnostic.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/ProfileData/InstrProfReader.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MD5.h"
Include dependency graph for CodeGenModule.cpp:

Go to the source code of this file.


static llvm::cl::opt< boolLimitedCoverage ("limited-coverage-experimental", llvm::cl::ZeroOrMore, llvm::cl::desc("Emit limited coverage mapping information (experimental)"), llvm::cl::init(false))
static CGCXXABIcreateCXXABI (CodeGenModule &CGM)
static const llvm::GlobalObject * getAliasedGlobal (const llvm::GlobalIndirectSymbol &GIS)
static llvm::GlobalVariable::ThreadLocalMode GetLLVMTLSModel (StringRef S)
static llvm::GlobalVariable::ThreadLocalMode GetLLVMTLSModel (CodeGenOptions::TLSModel M)
static bool hasUnwindExceptions (const LangOptions &LangOpts)
 Determines whether the language options require us to model unwind exceptions. More...
static void setLinkageAndVisibilityForGV (llvm::GlobalValue *GV, const NamedDecl *ND)
static void emitUsed (CodeGenModule &CGM, StringRef Name, std::vector< llvm::WeakTrackingVH > &List)
static void addLinkOptionsPostorder (CodeGenModule &CGM, Module *Mod, SmallVectorImpl< llvm::MDNode *> &Metadata, llvm::SmallPtrSet< Module *, 16 > &Visited)
 Add link options implied by the given module, including modules it depends on, using a postorder walk. More...
static bool HasNonDllImportDtor (QualType T)
static void ReplaceUsesOfNonProtoTypeWithRealFunction (llvm::GlobalValue *Old, llvm::Function *NewFn)
 ReplaceUsesOfNonProtoTypeWithRealFunction - This function is called when we implement a function with no prototype, e.g. More...
static const FunctionDeclGetRuntimeFunctionDecl (ASTContext &C, StringRef Name)
static bool shouldBeInCOMDAT (CodeGenModule &CGM, const Decl &D)
static bool isVarDeclStrongDefinition (const ASTContext &Context, CodeGenModule &CGM, const VarDecl *D, bool NoCommon)
static void replaceUsesOfNonProtoConstant (llvm::Constant *old, llvm::Function *newFn)
 Replace the uses of a function that was declared with a non-proto type. More...
static llvm::StringMapEntry< llvm::GlobalVariable * > & GetConstantCFStringEntry (llvm::StringMap< llvm::GlobalVariable *> &Map, const StringLiteral *Literal, bool TargetIsLSB, bool &IsUTF16, unsigned &StringLength)
static llvm::GlobalVariable * GenerateStringLiteral (llvm::Constant *C, llvm::GlobalValue::LinkageTypes LT, CodeGenModule &CGM, StringRef GlobalName, CharUnits Alignment)
static bool needsDestructMethod (ObjCImplementationDecl *impl)
static bool AllTrivialInitializers (CodeGenModule &CGM, ObjCImplementationDecl *D)
static llvm::Constant * GetPointerConstant (llvm::LLVMContext &Context, const void *Ptr)
 Turns the given pointer into a constant. More...
static void EmitGlobalDeclMetadata (CodeGenModule &CGM, llvm::NamedMDNode *&GlobalMetadata, GlobalDecl D, llvm::GlobalValue *Addr)


static const char AnnotationSection [] = "llvm.metadata"

Function Documentation

◆ addLinkOptionsPostorder()

static void addLinkOptionsPostorder ( CodeGenModule CGM,
Module Mod,
SmallVectorImpl< llvm::MDNode *> &  Metadata,
llvm::SmallPtrSet< Module *, 16 > &  Visited 

Add link options implied by the given module, including modules it depends on, using a postorder walk.

Definition at line 1298 of file CodeGenModule.cpp.

References clang::Module::Parent.

◆ AllTrivialInitializers()

static bool AllTrivialInitializers ( CodeGenModule CGM,
ObjCImplementationDecl D 

Definition at line 3899 of file CodeGenModule.cpp.

References clang::ObjCImplementationDecl::init_begin().

◆ createCXXABI()

static CGCXXABI* createCXXABI ( CodeGenModule CGM)

◆ EmitGlobalDeclMetadata()

static void EmitGlobalDeclMetadata ( CodeGenModule CGM,
llvm::NamedMDNode *&  GlobalMetadata,
GlobalDecl  D,
llvm::GlobalValue *  Addr 

◆ emitUsed()

static void emitUsed ( CodeGenModule CGM,
StringRef  Name,
std::vector< llvm::WeakTrackingVH > &  List 

Definition at line 1246 of file CodeGenModule.cpp.

◆ GenerateStringLiteral()

static llvm::GlobalVariable* GenerateStringLiteral ( llvm::Constant *  C,
llvm::GlobalValue::LinkageTypes  LT,
CodeGenModule CGM,
StringRef  GlobalName,
CharUnits  Alignment 

◆ getAliasedGlobal()

static const llvm::GlobalObject* getAliasedGlobal ( const llvm::GlobalIndirectSymbol &  GIS)

◆ GetConstantCFStringEntry()

static llvm::StringMapEntry<llvm::GlobalVariable *>& GetConstantCFStringEntry ( llvm::StringMap< llvm::GlobalVariable *> &  Map,
const StringLiteral Literal,
bool  TargetIsLSB,
bool IsUTF16,
unsigned &  StringLength 

◆ GetLLVMTLSModel() [1/2]

static llvm::GlobalVariable::ThreadLocalMode GetLLVMTLSModel ( StringRef  S)

Definition at line 676 of file CodeGenModule.cpp.

Referenced by clang::CodeGen::CodeGenModule::setTLSMode().

◆ GetLLVMTLSModel() [2/2]

static llvm::GlobalVariable::ThreadLocalMode GetLLVMTLSModel ( CodeGenOptions::TLSModel  M)

◆ GetPointerConstant()

static llvm::Constant* GetPointerConstant ( llvm::LLVMContext &  Context,
const void *  Ptr 

Turns the given pointer into a constant.

Definition at line 4326 of file CodeGenModule.cpp.

References clang::CodeGen::Type.

Referenced by EmitGlobalDeclMetadata().

◆ GetRuntimeFunctionDecl()

static const FunctionDecl* GetRuntimeFunctionDecl ( ASTContext C,
StringRef  Name 

Definition at line 2231 of file CodeGenModule.cpp.

◆ HasNonDllImportDtor()

static bool HasNonDllImportDtor ( QualType  T)

◆ hasUnwindExceptions()

static bool hasUnwindExceptions ( const LangOptions LangOpts)

Determines whether the language options require us to model unwind exceptions.

We treat -fexceptions as mandating this except under the fragile ObjC ABI with only ObjC exceptions enabled. This means, for example, that C with -fexceptions enables this.

Definition at line 913 of file CodeGenModule.cpp.

References clang::ObjCRuntime::hasUnwindExceptions(), and clang::LangOptions::ObjCRuntime.

Referenced by clang::CodeGen::CodeGenModule::SetLLVMFunctionAttributesForDefinition().

◆ isVarDeclStrongDefinition()

static bool isVarDeclStrongDefinition ( const ASTContext Context,
CodeGenModule CGM,
const VarDecl D,
bool  NoCommon 

◆ LimitedCoverage()

static llvm::cl::opt<bool> LimitedCoverage ( "limited-coverage-experimental"  ,
llvm::cl::ZeroOrMore  ,
llvm::cl::desc("Emit limited coverage mapping information (experimental)")  ,

◆ needsDestructMethod()

static bool needsDestructMethod ( ObjCImplementationDecl impl)

◆ replaceUsesOfNonProtoConstant()

static void replaceUsesOfNonProtoConstant ( llvm::Constant *  old,
llvm::Function *  newFn 

Replace the uses of a function that was declared with a non-proto type.

We want to silently drop extra arguments from call sites

Definition at line 3097 of file CodeGenModule.cpp.

References clang::Create(), and clang::CodeGen::Type.

Referenced by ReplaceUsesOfNonProtoTypeWithRealFunction().

◆ ReplaceUsesOfNonProtoTypeWithRealFunction()

static void ReplaceUsesOfNonProtoTypeWithRealFunction ( llvm::GlobalValue *  Old,
llvm::Function *  NewFn 

ReplaceUsesOfNonProtoTypeWithRealFunction - This function is called when we implement a function with no prototype, e.g.

"int foo() {}". If there are existing call uses of the old function in the module, this adjusts them to call the new function directly.

This is not just a cleanup: the always_inline pass requires direct calls to functions to be able to inline them. If there is a bitcast in the way, it won't inline them. Instcombine normally deletes these calls, but it isn't run at -O0.

Definition at line 3203 of file CodeGenModule.cpp.

References replaceUsesOfNonProtoConstant().

◆ setLinkageAndVisibilityForGV()

static void setLinkageAndVisibilityForGV ( llvm::GlobalValue *  GV,
const NamedDecl ND 

◆ shouldBeInCOMDAT()

static bool shouldBeInCOMDAT ( CodeGenModule CGM,
const Decl D 

Variable Documentation

◆ AnnotationSection

const char AnnotationSection[] = "llvm.metadata"

Definition at line 68 of file CodeGenModule.cpp.