Encode argument numbering in debug info so that code generator can emit them in order.

This fixes few blocks.exp regressions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126960 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2011-03-03 20:13:15 +00:00
Родитель 203548ba4b
Коммит 093ac461b3
5 изменённых файлов: 27 добавлений и 20 удалений

Просмотреть файл

@ -856,9 +856,10 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
assert(FI.arg_size() == Args.size() &&
"Mismatch between function signature & arguments.");
unsigned ArgNo = 1;
CGFunctionInfo::const_arg_iterator info_it = FI.arg_begin();
for (FunctionArgList::const_iterator i = Args.begin(), e = Args.end();
i != e; ++i, ++info_it) {
for (FunctionArgList::const_iterator i = Args.begin(), e = Args.end();
i != e; ++i, ++info_it, ++ArgNo) {
const VarDecl *Arg = i->first;
QualType Ty = info_it->type;
const ABIArgInfo &ArgI = info_it->info;
@ -898,7 +899,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
V = EmitScalarConversion(V, Ty, Arg->getType());
}
}
EmitParmDecl(*Arg, V);
EmitParmDecl(*Arg, V, ArgNo);
break;
}
@ -919,7 +920,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
// "void a(x) short x; {..."
V = EmitScalarConversion(V, Ty, Arg->getType());
}
EmitParmDecl(*Arg, V);
EmitParmDecl(*Arg, V, ArgNo);
break;
}
@ -974,7 +975,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
V = EmitScalarConversion(V, Ty, Arg->getType());
}
}
EmitParmDecl(*Arg, V);
EmitParmDecl(*Arg, V, ArgNo);
continue; // Skip ++AI increment, already done.
}
@ -985,7 +986,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
llvm::Value *Temp = CreateMemTemp(Ty, Arg->getName() + ".addr");
llvm::Function::arg_iterator End =
ExpandTypeFromArgs(Ty, MakeAddrLValue(Temp, Ty), AI);
EmitParmDecl(*Arg, Temp);
EmitParmDecl(*Arg, Temp, ArgNo);
// Name the arguments used in expansion and increment AI.
unsigned Index = 0;
@ -997,9 +998,10 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
case ABIArgInfo::Ignore:
// Initialize the local variable appropriately.
if (hasAggregateLLVMType(Ty))
EmitParmDecl(*Arg, CreateMemTemp(Ty));
EmitParmDecl(*Arg, CreateMemTemp(Ty), ArgNo);
else
EmitParmDecl(*Arg, llvm::UndefValue::get(ConvertType(Arg->getType())));
EmitParmDecl(*Arg, llvm::UndefValue::get(ConvertType(Arg->getType())),
ArgNo);
// Skip increment, no matching LLVM parameter.
continue;

Просмотреть файл

@ -1750,7 +1750,8 @@ llvm::DIType CGDebugInfo::EmitTypeForVarWithBlocksAttr(const ValueDecl *VD,
/// EmitDeclare - Emit local variable declaration debug info.
void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag,
llvm::Value *Storage, CGBuilderTy &Builder) {
llvm::Value *Storage,
unsigned ArgNo, CGBuilderTy &Builder) {
assert(!RegionStack.empty() && "Region stack mismatch, stack empty!");
llvm::DIFile Unit = getOrCreateFile(VD->getLocation());
@ -1810,7 +1811,7 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag,
DBuilder.createComplexVariable(Tag,
llvm::DIDescriptor(RegionStack.back()),
VD->getName(), Unit, Line, Ty,
addr.data(), addr.size());
addr.data(), addr.size(), ArgNo);
// Insert an llvm.dbg.declare into the current block.
llvm::Instruction *Call =
@ -1823,7 +1824,7 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag,
llvm::DIVariable D =
DBuilder.createLocalVariable(Tag, llvm::DIDescriptor(Scope),
Name, Unit, Line, Ty,
CGM.getLangOptions().Optimize, Flags);
CGM.getLangOptions().Optimize, Flags, ArgNo);
// Insert an llvm.dbg.declare into the current block.
llvm::Instruction *Call =
@ -1853,7 +1854,8 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag,
llvm::DIVariable D =
DBuilder.createLocalVariable(Tag, llvm::DIDescriptor(Scope),
FieldName, Unit, Line, FieldTy,
CGM.getLangOptions().Optimize, Flags);
CGM.getLangOptions().Optimize, Flags,
ArgNo);
// Insert an llvm.dbg.declare into the current block.
llvm::Instruction *Call =
@ -1927,7 +1929,7 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag,
void CGDebugInfo::EmitDeclareOfAutoVariable(const VarDecl *VD,
llvm::Value *Storage,
CGBuilderTy &Builder) {
EmitDeclare(VD, llvm::dwarf::DW_TAG_auto_variable, Storage, Builder);
EmitDeclare(VD, llvm::dwarf::DW_TAG_auto_variable, Storage, 0, Builder);
}
void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
@ -1940,8 +1942,9 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
/// EmitDeclareOfArgVariable - Emit call to llvm.dbg.declare for an argument
/// variable declaration.
void CGDebugInfo::EmitDeclareOfArgVariable(const VarDecl *VD, llvm::Value *AI,
unsigned ArgNo,
CGBuilderTy &Builder) {
EmitDeclare(VD, llvm::dwarf::DW_TAG_arg_variable, AI, Builder);
EmitDeclare(VD, llvm::dwarf::DW_TAG_arg_variable, AI, ArgNo, Builder);
}
namespace {
@ -2090,7 +2093,8 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
DBuilder.createLocalVariable(llvm::dwarf::DW_TAG_arg_variable,
llvm::DIDescriptor(scope),
name, tunit, line, type,
CGM.getLangOptions().Optimize, flags);
CGM.getLangOptions().Optimize, flags,
cast<llvm::Argument>(addr)->getArgNo() + 1);
// Insert an llvm.dbg.value into the current block.
llvm::Instruction *declare =

Просмотреть файл

@ -181,7 +181,7 @@ public:
/// EmitDeclareOfArgVariable - Emit call to llvm.dbg.declare for an argument
/// variable declaration.
void EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI,
CGBuilderTy &Builder);
unsigned ArgNo, CGBuilderTy &Builder);
/// EmitDeclareOfBlockLiteralArgVariable - Emit call to
/// llvm.dbg.declare for the block-literal argument to a block
@ -204,7 +204,7 @@ public:
private:
/// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration.
void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI,
CGBuilderTy &Builder);
unsigned ArgNo, CGBuilderTy &Builder);
/// EmitDeclare - Emit call to llvm.dbg.declare for a variable
/// declaration from an enclosing block.

Просмотреть файл

@ -1000,7 +1000,8 @@ void CodeGenFunction::EmitAutoVarCleanups(const AutoVarEmission &emission) {
/// Emit an alloca (or GlobalValue depending on target)
/// for the specified parameter and set up LocalDeclMap.
void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) {
void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg,
unsigned ArgNo) {
// FIXME: Why isn't ImplicitParamDecl a ParmVarDecl?
assert((isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D)) &&
"Invalid argument to EmitParmDecl");
@ -1046,6 +1047,6 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) {
// Emit debug info for param declaration.
if (CGDebugInfo *DI = getDebugInfo()) {
DI->setLocation(D.getLocation());
DI->EmitDeclareOfArgVariable(&D, DeclPtr, Builder);
DI->EmitDeclareOfArgVariable(&D, DeclPtr, ArgNo, Builder);
}
}

Просмотреть файл

@ -1609,7 +1609,7 @@ public:
llvm::GlobalValue::LinkageTypes Linkage);
/// EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
void EmitParmDecl(const VarDecl &D, llvm::Value *Arg);
void EmitParmDecl(const VarDecl &D, llvm::Value *Arg, unsigned ArgNo);
/// protectFromPeepholes - Protect a value that we're intending to
/// store to the side, but which will probably be used later, from