r202185 - Debug info: Generate debug info for variadic functions.

Adrian Prantl aprantl at apple.com
Tue Feb 25 15:49:18 PST 2014


Should be all done in r202207 + r202208.

thanks,
Adrian

PS: where you able to look at one or the other piece of my DW_OP_piece patches?

On Feb 25, 2014, at 14:11, Eric Christopher <echristo at gmail.com> wrote:

>> @@ -765,6 +765,8 @@ llvm::DIType CGDebugInfo::CreateType(con
>>   else if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(Ty)) {
>>     for (unsigned i = 0, e = FPT->getNumParams(); i != e; ++i)
>>       EltTys.push_back(getOrCreateType(FPT->getParamType(i), Unit));
>> +    if (FPT->isVariadic())
>> +      EltTys.push_back(DBuilder.createUnspecifiedParameter());
> 
> Comment and you can probably remove the FIXME above yes?
> 
>>   }
>> 
>>   llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(EltTys);
>> @@ -2437,6 +2439,20 @@ llvm::DICompositeType CGDebugInfo::getOr
>>     llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(Elts);
>>     return DBuilder.createSubroutineType(F, EltTypeArray);
>>   }
>> +
>> +  // Variadic function.
> 
> Full sentences for comments please. This additional code looks weird,
> what's going on here? i.e. why are only arguments/types for variadic
> functions being handled here? :)
> 
>> +  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
>> +    if (FD->isVariadic()) {
>> +      SmallVector<llvm::Value *, 16> EltTys;
>> +      EltTys.push_back(getOrCreateType(FD->getReturnType(), F));
>> +      if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FnType))
>> +        for (unsigned i = 0, e = FPT->getNumParams(); i != e; ++i)
>> +          EltTys.push_back(getOrCreateType(FPT->getParamType(i), F));
>> +      EltTys.push_back(DBuilder.createUnspecifiedParameter());
>> +      llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(EltTys);
>> +      return DBuilder.createSubroutineType(F, EltTypeArray);
>> +    }
>> +
>>   return llvm::DICompositeType(getOrCreateType(FnType, F));
>> }
>> 
>> 
>> Added: cfe/trunk/test/CodeGenCXX/debug-info-varargs.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-varargs.cpp?rev=202185&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/CodeGenCXX/debug-info-varargs.cpp (added)
>> +++ cfe/trunk/test/CodeGenCXX/debug-info-varargs.cpp Tue Feb 25 13:38:11 2014
>> @@ -0,0 +1,24 @@
>> +// RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck %s
>> +
> 
> CHECK-DAG seems a bit overkill here?
> 
>> +struct A
>> +{
>> +  // CHECK-DAG: ", i32 [[@LINE+1]], metadata ![[ATY:[0-9]+]]{{.*}}[ DW_TAG_subprogram ]{{.*}}[a]
>> +  void a(int c, ...) {}
>> +  // CHECK-DAG: ![[ATY]] ={{.*}} metadata ![[AARGS:[0-9]+]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
>> +  // CHECK-DAG: ![[AARGS]] = {{.*}} metadata ![[UNSPEC:[0-9]+]]}
>> +  // CHECK-DAG: ![[UNSPEC]] = metadata !{i32 786456}
> 
> You should add something to the IR pretty printer for
> DW_TAG_unspecified_parameters and put it on the check line to make it
> a bit more obvious what you're checking here and below.
> 
> -eric
> 
>> +};
>> +
>> +  // CHECK-DAG: ", i32 [[@LINE+1]], metadata ![[BTY:[0-9]+]]{{.*}}[ DW_TAG_subprogram ]{{.*}}[b]
>> +void b(int c, ...) {
>> +  // CHECK-DAG: ![[BTY]] ={{.*}} metadata ![[BARGS:[0-9]+]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
>> +  // CHECK-DAG: ![[BARGS]] = {{.*}} metadata ![[UNSPEC:[0-9]+]]}
>> +
>> +  A a;
>> +
>> +  // CHECK-DAG: metadata ![[PST:[0-9]+]], i32 0, i32 0} ; [ DW_TAG_auto_variable ] [fptr] [line [[@LINE+1]]]
>> +  void (*fptr)(int, ...) = b;
>> +  // CHECK-DAG: ![[PST]] ={{.*}} metadata ![[ST:[0-9]+]]} ; [ DW_TAG_pointer_type ]
>> +  // CHECK-DAG: ![[ST]] ={{.*}} metadata ![[ARGS:[0-9]+]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
>> +  // CHECK-DAG: ![[ARGS]] = {{.*}} metadata ![[UNSPEC]]}
>> +}
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list