forked from OSchip/llvm-project
fix CreateTempAlloca to not set a name on the alloca for temporaries
in release-assert builds. For automatic variables, explicitly set a name with setName that does not make a temporary std::string. This speeds up -emit-llvm-only -disable-free on PR3810 by 4.6% llvm-svn: 67459
This commit is contained in:
parent
adda37fb62
commit
47640221da
|
@ -232,8 +232,9 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
|
||||||
const llvm::Type *LTy = ConvertTypeForMem(Ty);
|
const llvm::Type *LTy = ConvertTypeForMem(Ty);
|
||||||
if (isByRef)
|
if (isByRef)
|
||||||
LTy = BuildByRefType(Ty, getContext().getDeclAlignInBytes(&D));
|
LTy = BuildByRefType(Ty, getContext().getDeclAlignInBytes(&D));
|
||||||
llvm::AllocaInst *Alloc =
|
llvm::AllocaInst *Alloc = CreateTempAlloca(LTy);
|
||||||
CreateTempAlloca(LTy, D.getNameAsString().c_str());
|
Alloc->setName(D.getNameAsString().c_str());
|
||||||
|
|
||||||
if (isByRef)
|
if (isByRef)
|
||||||
Alloc->setAlignment(std::max(getContext().getDeclAlignInBytes(&D),
|
Alloc->setAlignment(std::max(getContext().getDeclAlignInBytes(&D),
|
||||||
getContext().getTypeAlign(getContext().VoidPtrTy) / 8));
|
getContext().getTypeAlign(getContext().VoidPtrTy) / 8));
|
||||||
|
@ -429,7 +430,8 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) {
|
||||||
// TODO: Alignment
|
// TODO: Alignment
|
||||||
std::string Name = D.getNameAsString();
|
std::string Name = D.getNameAsString();
|
||||||
Name += ".addr";
|
Name += ".addr";
|
||||||
DeclPtr = CreateTempAlloca(LTy, Name.c_str());
|
DeclPtr = CreateTempAlloca(LTy);
|
||||||
|
DeclPtr->setName(Name.c_str());
|
||||||
|
|
||||||
// Store the initial value into the alloca.
|
// Store the initial value into the alloca.
|
||||||
EmitStoreOfScalar(Arg, DeclPtr, Ty.isVolatileQualified());
|
EmitStoreOfScalar(Arg, DeclPtr, Ty.isVolatileQualified());
|
||||||
|
|
|
@ -29,7 +29,8 @@ using namespace CodeGen;
|
||||||
/// block.
|
/// block.
|
||||||
llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(const llvm::Type *Ty,
|
llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(const llvm::Type *Ty,
|
||||||
const char *Name) {
|
const char *Name) {
|
||||||
// FIXME: Should not pass name if names are disabled in IRBuilder.
|
if (!Builder.isNamePreserving())
|
||||||
|
Name = "";
|
||||||
return new llvm::AllocaInst(Ty, 0, Name, AllocaInsertPt);
|
return new llvm::AllocaInst(Ty, 0, Name, AllocaInsertPt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,8 +163,10 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy,
|
||||||
// later. Don't create this with the builder, because we don't want it
|
// later. Don't create this with the builder, because we don't want it
|
||||||
// folded.
|
// folded.
|
||||||
llvm::Value *Undef = llvm::UndefValue::get(llvm::Type::Int32Ty);
|
llvm::Value *Undef = llvm::UndefValue::get(llvm::Type::Int32Ty);
|
||||||
AllocaInsertPt = new llvm::BitCastInst(Undef, llvm::Type::Int32Ty, "allocapt",
|
AllocaInsertPt = new llvm::BitCastInst(Undef, llvm::Type::Int32Ty, "",
|
||||||
EntryBB);
|
EntryBB);
|
||||||
|
if (Builder.isNamePreserving())
|
||||||
|
AllocaInsertPt->setName("allocapt");
|
||||||
|
|
||||||
ReturnBlock = createBasicBlock("return");
|
ReturnBlock = createBasicBlock("return");
|
||||||
ReturnValue = 0;
|
ReturnValue = 0;
|
||||||
|
|
Loading…
Reference in New Issue