[llvm-commits] [llvm-gcc-4.2] r83493 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Devang Patel dpatel at apple.com
Wed Oct 7 15:06:30 PDT 2009


Author: dpatel
Date: Wed Oct  7 17:06:29 2009
New Revision: 83493

URL: http://llvm.org/viewvc/llvm-project?rev=83493&view=rev
Log:
Attach debug location info to allocas created for temporaries.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=83493&r1=83492&r2=83493&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Oct  7 17:06:29 2009
@@ -301,6 +301,9 @@
       // Create an alloca for the ResultDecl.
       Value *Tmp = TheTreeToLLVM->CreateTemporary(AI->getType());
       Builder.CreateStore(AI, Tmp);
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+      Builder.SetDebugLocation(cast<llvm::Instruction>(Tmp));
+#endif
 
       SET_DECL_LLVM(ResultDecl, Tmp);
       if (TheDebugInfo) {
@@ -599,6 +602,9 @@
       Tmp->setName(std::string(Name)+"_addr");
       SET_DECL_LLVM(Args, Tmp);
       if (TheDebugInfo) {
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+        Builder.SetDebugLocation(cast<llvm::Instruction>(Tmp));
+#endif
         TheDebugInfo->EmitDeclare(Args, dwarf::DW_TAG_arg_variable,
                                   Name, TREE_TYPE(Args), Tmp,
                                   Builder.GetInsertBlock());
@@ -694,10 +700,6 @@
       }
     }
   }
-  if (TheDebugInfo) {
-    TheDebugInfo->EmitStopPoint(Fn, Builder.GetInsertBlock(), Builder);
-    TheDebugInfo->EmitFunctionEnd(Builder.GetInsertBlock(), true);
-  }
   if (RetVals.empty())
     Builder.CreateRetVoid();
   else if (!Fn->getReturnType()->isAggregateType()) {
@@ -723,6 +725,11 @@
       SI->setSuccessor(0, SI->getSuccessor(1));
   }
 
+  if (TheDebugInfo) {
+    TheDebugInfo->EmitStopPoint(Fn, Builder.GetInsertBlock(), Builder);
+    TheDebugInfo->EmitFunctionEnd(Builder.GetInsertBlock(), true);
+  }
+
   // Remove any cached LLVM values that are local to this function.  Such values
   // may be deleted when the optimizers run, so would be dangerous to keep.
   eraseLocalLLVMValues();
@@ -1200,6 +1207,11 @@
 /// CreateTempLoc - Like CreateTemporary, but returns a MemRef.
 MemRef TreeToLLVM::CreateTempLoc(const Type *Ty) {
   AllocaInst *AI = CreateTemporary(Ty);
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+  if (TheDebugInfo)
+    Builder.SetDebugLocation(AI);
+#endif
+
   // MemRefs do not allow alignment 0.
   if (!AI->getAlignment())
     AI->setAlignment(TD.getPrefTypeAlignment(Ty));
@@ -1699,6 +1711,12 @@
 
   // Create a temporary for the value to be switched on.
   IndirectGotoValue = CreateTemporary(TD.getIntPtrType(Context));
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+  if (TheDebugInfo) {
+    TheDebugInfo->EmitStopPoint(Fn, Builder.GetInsertBlock(), Builder);
+    Builder.SetDebugLocation(cast<llvm::Instruction>(IndirectGotoValue));
+  }
+#endif
 
   // Create the block, emit a load, and emit the switch in the block.
   IndirectGotoBlock = BasicBlock::Create(Context, "indirectgoto");
@@ -2491,6 +2509,10 @@
         // A value.  Store to a temporary, and return the temporary's address.
         // Any future access to this argument will reuse the same address.
         Loc = TheTreeToLLVM->CreateTemporary(TheValue->getType());
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+        if (TheDebugInfo)
+          Builder.SetDebugLocation(cast<llvm::Instruction>(Loc));
+#endif
         Builder.CreateStore(TheValue, Loc);
       }
       return Loc;
@@ -2864,6 +2886,10 @@
 
   // Create a new temporary and set the VAR_DECL to use it as the llvm location.
   Value *NewTmp = CreateTemporary(FirstVal->getType());
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+  if (TheDebugInfo)
+    Builder.SetDebugLocation(cast<llvm::Instruction>(NewTmp));
+#endif
   SET_DECL_LLVM(Var, NewTmp);
 
   // Store the already existing initial value into the alloca.  If the value
@@ -6165,6 +6191,12 @@
     // Emit it as a value, then store it to a temporary slot.
     Value *V2 = Emit(Arg2T, 0);
     Arg2 = CreateTemporary(V2->getType());
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+  if (TheDebugInfo) {
+    TheDebugInfo->EmitStopPoint(Fn, Builder.GetInsertBlock(), Builder);
+    Builder.SetDebugLocation(cast<llvm::Instruction>(Arg2));
+  }
+#endif
     Builder.CreateStore(V2, Arg2);
   } else {
     // If the target has aggregate valists, then the second argument
@@ -6890,6 +6922,12 @@
   } else {
     // If the input is a scalar, emit to a temporary.
     Value *Dest = CreateTemporary(ConvertType(TREE_TYPE(Op)));
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+    if (TheDebugInfo) {
+      TheDebugInfo->EmitStopPoint(Fn, Builder.GetInsertBlock(), Builder);
+      Builder.SetDebugLocation(cast<llvm::Instruction>(Dest));
+    }
+#endif
     Builder.CreateStore(Emit(Op, 0), Dest);
     // The type is the type of the expression.
     Dest = BitCastToType(Dest,





More information about the llvm-commits mailing list