]> granicus.if.org Git - clang/commitdiff
fix CreateTempAlloca to not set a name on the alloca for temporaries
authorChris Lattner <sabre@nondot.org>
Sun, 22 Mar 2009 00:24:14 +0000 (00:24 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 22 Mar 2009 00:24:14 +0000 (00:24 +0000)
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%

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67459 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDecl.cpp
lib/CodeGen/CGExpr.cpp
lib/CodeGen/CodeGenFunction.cpp

index 8a4febeecfb3d8649140295f194df29f0cbaf0b8..49ac20a9bcde9c46a85b97e40d6640e299724cbb 100644 (file)
@@ -232,8 +232,9 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
       const llvm::Type *LTy = ConvertTypeForMem(Ty);
       if (isByRef)
         LTy = BuildByRefType(Ty, getContext().getDeclAlignInBytes(&D));
-      llvm::AllocaInst *Alloc = 
-        CreateTempAlloca(LTy, D.getNameAsString().c_str());
+      llvm::AllocaInst *Alloc = CreateTempAlloca(LTy);
+      Alloc->setName(D.getNameAsString().c_str());
+      
       if (isByRef)
         Alloc->setAlignment(std::max(getContext().getDeclAlignInBytes(&D),
                                      getContext().getTypeAlign(getContext().VoidPtrTy) / 8));
@@ -429,7 +430,8 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) {
       // TODO: Alignment
       std::string Name = D.getNameAsString();
       Name += ".addr";
-      DeclPtr = CreateTempAlloca(LTy, Name.c_str());
+      DeclPtr = CreateTempAlloca(LTy);
+      DeclPtr->setName(Name.c_str());
       
       // Store the initial value into the alloca.
       EmitStoreOfScalar(Arg, DeclPtr, Ty.isVolatileQualified());
index d34b0f5ea38bf114a4cdd9c43c60f3997b7485a3..45cd6a70a5de0f54dc23190456812f746977815a 100644 (file)
@@ -29,7 +29,8 @@ using namespace CodeGen;
 /// block.
 llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(const llvm::Type *Ty,
                                                     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);
 }
 
index 441c9fcdbf6ebc3448ce6d05320878aeb2d4c341..1d9f0f844eb77bea2b08dff4aaec3faa3b495478 100644 (file)
@@ -163,9 +163,11 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy,
   // later.  Don't create this with the builder, because we don't want it
   // folded.
   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);
-
+  if (Builder.isNamePreserving())
+    AllocaInsertPt->setName("allocapt");
+  
   ReturnBlock = createBasicBlock("return");
   ReturnValue = 0;
   if (!RetTy->isVoidType())