clang
10.0.0git
|
#include "CGBlocks.h"
#include "CGCXXABI.h"
#include "CGCleanup.h"
#include "CGDebugInfo.h"
#include "CGOpenCLRuntime.h"
#include "CGOpenMPRuntime.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "ConstantEmitter.h"
#include "PatternInit.h"
#include "TargetInfo.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclOpenMP.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/CodeGen/CGFunctionInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Type.h"
Go to the source code of this file.
Enumerations | |
enum | IsPattern { IsPattern::No, IsPattern::Yes } |
Functions | |
static std::string | getStaticDeclName (CodeGenModule &CGM, const VarDecl &D) |
static void | EmitAutoVarWithLifetime (CodeGenFunction &CGF, const VarDecl &var, Address addr, Qualifiers::ObjCLifetime lifetime) |
EmitAutoVarWithLifetime - Does the setup required for an automatic variable with lifetime. More... | |
static bool | isAccessedBy (const VarDecl &var, const Stmt *s) |
static bool | isAccessedBy (const ValueDecl *decl, const Expr *e) |
static bool | tryEmitARCCopyWeakInit (CodeGenFunction &CGF, const LValue &destLV, const Expr *init) |
static void | drillIntoBlockVariable (CodeGenFunction &CGF, LValue &lvalue, const VarDecl *var) |
static bool | canEmitInitWithFewStoresAfterBZero (llvm::Constant *Init, unsigned &NumStores) |
Decide whether we can emit the non-zero parts of the specified initializer with equal or fewer than NumStores scalar stores. More... | |
static void | emitStoresForInitAfterBZero (CodeGenModule &CGM, llvm::Constant *Init, Address Loc, bool isVolatile, CGBuilderTy &Builder) |
For inits that canEmitInitWithFewStoresAfterBZero returned true for, emit the scalar stores that would be required. More... | |
static bool | shouldUseBZeroPlusStoresToInitialize (llvm::Constant *Init, uint64_t GlobalSize) |
Decide whether we should use bzero plus some stores to initialize a local variable instead of using a memcpy from a constant global. More... | |
static llvm::Value * | shouldUseMemSetToInitialize (llvm::Constant *Init, uint64_t GlobalSize, const llvm::DataLayout &DL) |
Decide whether we should use memset to initialize a local variable instead of using a memcpy from a constant global. More... | |
static bool | shouldSplitConstantStore (CodeGenModule &CGM, uint64_t GlobalByteSize) |
Decide whether we want to split a constant structure or array store into a sequence of its fields' stores. More... | |
static llvm::Constant * | patternOrZeroFor (CodeGenModule &CGM, IsPattern isPattern, llvm::Type *Ty) |
Generate a constant filled with either a pattern or zeroes. More... | |
static llvm::Constant * | constWithPadding (CodeGenModule &CGM, IsPattern isPattern, llvm::Constant *constant) |
Replace all padding bytes in a given constant with either a pattern byte or 0x00. More... | |
static llvm::Constant * | constStructWithPadding (CodeGenModule &CGM, IsPattern isPattern, llvm::StructType *STy, llvm::Constant *constant) |
Helper function for constWithPadding() to deal with padding in structures. More... | |
static Address | createUnnamedGlobalForMemcpyFrom (CodeGenModule &CGM, const VarDecl &D, CGBuilderTy &Builder, llvm::Constant *Constant, CharUnits Align) |
static void | emitStoresForConstant (CodeGenModule &CGM, const VarDecl &D, Address Loc, bool isVolatile, CGBuilderTy &Builder, llvm::Constant *constant) |
static void | emitStoresForZeroInit (CodeGenModule &CGM, const VarDecl &D, Address Loc, bool isVolatile, CGBuilderTy &Builder) |
static void | emitStoresForPatternInit (CodeGenModule &CGM, const VarDecl &D, Address Loc, bool isVolatile, CGBuilderTy &Builder) |
static bool | containsUndef (llvm::Constant *constant) |
static llvm::Constant * | replaceUndef (CodeGenModule &CGM, IsPattern isPattern, llvm::Constant *constant) |
static bool | isCapturedBy (const VarDecl &Var, const Expr *E) |
Determines whether the given __block variable is potentially captured by the given expression. More... | |
static bool | isCapturedBy (const VarDecl &Var, const Stmt *S) |
Determines whether the given __block variable is potentially captured by the given statement. More... | |
static void | emitPartialArrayDestroy (CodeGenFunction &CGF, llvm::Value *begin, llvm::Value *end, QualType type, CharUnits elementAlign, CodeGenFunction::Destroyer *destroyer) |
Perform partial array destruction as if in an EH cleanup. More... | |
|
strong |
Enumerator | |
---|---|
No | |
Yes |
Definition at line 989 of file CGDecl.cpp.
|
static |
Decide whether we can emit the non-zero parts of the specified initializer with equal or fewer than NumStores scalar stores.
Definition at line 863 of file CGDecl.cpp.
Referenced by shouldUseBZeroPlusStoresToInitialize().
|
static |
Helper function for constWithPadding() to deal with padding in structures.
Definition at line 1004 of file CGDecl.cpp.
References constWithPadding(), clang::CodeGen::CodeGenModule::getDataLayout(), clang::CodeGen::CodeGenModule::getLLVMContext(), clang::CodeGen::CodeGenTypeCache::Int8Ty, patternOrZeroFor(), and clang::CodeGen::Type.
Referenced by constWithPadding().
|
static |
Replace all padding bytes in a given constant with either a pattern byte or 0x00.
Definition at line 1044 of file CGDecl.cpp.
References constStructWithPadding(), and clang::CodeGen::Type.
Referenced by constStructWithPadding(), clang::CodeGen::CodeGenFunction::EmitAutoVarInit(), emitStoresForPatternInit(), emitStoresForZeroInit(), clang::CodeGen::CodeGenFunction::isTrivialInitializer(), and patternOrZeroFor().
|
static |
Definition at line 1245 of file CGDecl.cpp.
Referenced by replaceUndef().
|
static |
Definition at line 1131 of file CGDecl.cpp.
References clang::CodeGen::CGBuilderTy::CreateBitCast(), clang::CodeGen::CodeGenModule::createUnnamedGlobalFrom(), clang::CodeGen::Address::getAddressSpace(), clang::CodeGen::CodeGenModule::getLLVMContext(), clang::CodeGen::Address::getType(), and clang::CodeGen::Type.
Referenced by emitStoresForConstant(), and clang::CodeGen::CodeGenFunction::isTrivialInitializer().
|
static |
Definition at line 716 of file CGDecl.cpp.
References clang::CodeGen::CodeGenFunction::emitBlockByrefAddress(), clang::CodeGen::LValue::getAddress(), and clang::CodeGen::LValue::setAddress().
Referenced by clang::CodeGen::CodeGenFunction::EmitAutoVarInit(), clang::CodeGen::CodeGenFunction::EmitExprAsInit(), and clang::CodeGen::CodeGenFunction::EmitScalarInit().
|
static |
EmitAutoVarWithLifetime - Does the setup required for an automatic variable with lifetime.
Definition at line 598 of file CGDecl.cpp.
References clang::CodeGen::CodeGenFunction::destroyARCStrongImprecise, clang::CodeGen::CodeGenFunction::destroyARCStrongPrecise, clang::CodeGen::CodeGenFunction::destroyARCWeak, clang::CodeGen::EHCleanup, clang::CodeGen::CodeGenFunction::getARCCleanupKind(), clang::ValueDecl::getType(), clang::Decl::hasAttr(), clang::CodeGen::NormalAndEHCleanup, clang::Qualifiers::OCL_Autoreleasing, clang::Qualifiers::OCL_ExplicitNone, clang::Qualifiers::OCL_None, clang::Qualifiers::OCL_Strong, clang::Qualifiers::OCL_Weak, and clang::CodeGen::CodeGenFunction::pushDestroy().
Referenced by clang::CodeGen::CodeGenFunction::EmitParmDecl().
|
static |
Perform partial array destruction as if in an EH cleanup.
Unlike emitArrayDestroy, the element type here may still be an array type.
Definition at line 2195 of file CGDecl.cpp.
References clang::ast_matchers::arrayType, clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CGBuilderTy::CreateLoad(), clang::CodeGen::CodeGenFunction::emitArrayDestroy(), clang::ASTContext::getAsArrayType(), clang::CodeGen::CodeGenFunction::getContext(), and clang::CodeGen::CodeGenTypeCache::SizeTy.
|
static |
Definition at line 1144 of file CGDecl.cpp.
References clang::CodeGen::CGBuilderTy::CreateBitCast(), clang::CodeGen::CGBuilderTy::CreateConstArrayGEP(), clang::CodeGen::CGBuilderTy::CreateMemCpy(), clang::CodeGen::CGBuilderTy::CreateMemSet(), clang::CodeGen::CGBuilderTy::CreateStore(), clang::CodeGen::CGBuilderTy::CreateStructGEP(), createUnnamedGlobalForMemcpyFrom(), emitStoresForInitAfterBZero(), clang::CodeGen::Address::getAddressSpace(), clang::CodeGen::Address::getAlignment(), clang::CodeGen::CodeGenModule::getDataLayout(), clang::CodeGen::Address::getElementType(), getValue(), clang::CodeGen::CodeGenTypeCache::Int8Ty, clang::CodeGen::CodeGenTypeCache::IntPtrTy, shouldSplitConstantStore(), shouldUseBZeroPlusStoresToInitialize(), and shouldUseMemSetToInitialize().
Referenced by clang::CodeGen::CodeGenFunction::EmitAutoVarInit(), emitStoresForPatternInit(), and emitStoresForZeroInit().
|
static |
For inits that canEmitInitWithFewStoresAfterBZero returned true for, emit the scalar stores that would be required.
Definition at line 901 of file CGDecl.cpp.
References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CGBuilderTy::CreateConstInBoundsGEP2_32(), and clang::CodeGen::CGBuilderTy::CreateStore().
Referenced by emitStoresForConstant().
|
static |
Definition at line 1235 of file CGDecl.cpp.
References constWithPadding(), emitStoresForConstant(), clang::CodeGen::Address::getElementType(), clang::CodeGen::initializationPatternFor(), clang::CodeGen::Type, and Yes.
Referenced by clang::CodeGen::CodeGenFunction::isTrivialInitializer().
|
static |
Definition at line 1226 of file CGDecl.cpp.
References constWithPadding(), emitStoresForConstant(), clang::CodeGen::Address::getElementType(), No, and clang::CodeGen::Type.
Referenced by clang::CodeGen::CodeGenFunction::isTrivialInitializer().
|
static |
Definition at line 198 of file CGDecl.cpp.
References clang::CodeGen::CodeGenModule::getBlockMangledName(), clang::Decl::getDeclContext(), clang::CodeGen::CodeGenModule::getLangOpts(), clang::CodeGen::CodeGenModule::getMangledName(), clang::NamedDecl::getNameAsString(), and clang::NamedDecl::isExternallyVisible().
Definition at line 634 of file CGDecl.cpp.
References clang::BlockDecl::captures(), and clang::Stmt::children().
Referenced by clang::CodeGen::CodeGenFunction::EmitScalarInit(), and isAccessedBy().
Definition at line 659 of file CGDecl.cpp.
References clang::ast_matchers::decl, and isAccessedBy().
Determines whether the given __block variable is potentially captured by the given expression.
Definition at line 1601 of file CGDecl.cpp.
References clang::CompoundStmt::body(), clang::BlockDecl::captures(), clang::Stmt::children(), and clang::Expr::IgnoreParenCasts().
Referenced by clang::CodeGen::CodeGenFunction::EmitAutoVarInit().
Determines whether the given __block variable is potentially captured by the given statement.
Definition at line 1590 of file CGDecl.cpp.
|
static |
Generate a constant filled with either a pattern or zeroes.
Definition at line 992 of file CGDecl.cpp.
References clang::CodeGen::CodeGenFunction::CGM, constWithPadding(), clang::CodeGen::initializationPatternFor(), and Yes.
Referenced by constStructWithPadding(), and replaceUndef().
|
static |
Definition at line 1256 of file CGDecl.cpp.
References containsUndef(), and patternOrZeroFor().
Referenced by clang::CodeGen::CodeGenFunction::EmitAutoVarInit().
|
static |
Decide whether we want to split a constant structure or array store into a sequence of its fields' stores.
This may cost us code size and compilation speed, but plays better with store optimizations.
Definition at line 978 of file CGDecl.cpp.
References clang::CodeGen::CodeGenModule::getCodeGenOpts().
Referenced by emitStoresForConstant().
|
static |
Decide whether we should use bzero plus some stores to initialize a local variable instead of using a memcpy from a constant global.
It is beneficial to use bzero if the global is all zeros, or mostly zeros and large.
Definition at line 945 of file CGDecl.cpp.
References canEmitInitWithFewStoresAfterBZero().
Referenced by emitStoresForConstant().
|
static |
Decide whether we should use memset to initialize a local variable instead of using a memcpy from a constant global.
Assumes we've already decided to not user bzero. FIXME We could be more clever, as we are for bzero above, and generate memset followed by stores. It's unclear that's worth the effort.
Definition at line 966 of file CGDecl.cpp.
Referenced by emitStoresForConstant().
|
static |
Definition at line 666 of file CGDecl.cpp.
References clang::CodeGen::CodeGenFunction::Builder, clang::ast_matchers::castExpr, clang::CodeGen::CGBuilderTy::CreateElementBitCast(), clang::CodeGen::CodeGenFunction::EmitARCCopyWeak(), clang::CodeGen::CodeGenFunction::EmitARCMoveWeak(), clang::CodeGen::CodeGenFunction::EmitLValue(), clang::CodeGen::LValue::getAddress(), clang::CodeGen::Address::getElementType(), clang::QualType::getObjCLifetime(), clang::Expr::getType(), clang::Expr::getValueKind(), clang::Expr::IgnoreParens(), clang::Qualifiers::OCL_Weak, clang::VK_LValue, and clang::VK_XValue.
Referenced by clang::CodeGen::CodeGenFunction::EmitScalarInit().