[llvm] r181632 - PR14492: Debug Info: Support for values of non-integer non-type template parameters.

Pete Cooper peter_cooper at apple.com
Fri May 10 15:12:51 PDT 2013


Hey David

This commit is breaking the buildbot.  Can you please take a look?

http://lab.llvm.org:8013/builders/clang-x86_64-darwin11-nobootstrap-RAincremental/builds/1573

Thanks,
Pete
On May 10, 2013, at 2:52 PM, David Blaikie <dblaikie at gmail.com> wrote:

> Author: dblaikie
> Date: Fri May 10 16:52:07 2013
> New Revision: 181632
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=181632&view=rev
> Log:
> PR14492: Debug Info: Support for values of non-integer non-type template parameters.
> 
> This is only tested for global variables at the moment (& includes tests
> for the unnamed parameter case, since apparently this entire function
> was completely untested previously)
> 
> Added:
>    llvm/trunk/test/DebugInfo/template.ll
> Modified:
>    llvm/trunk/include/llvm/DIBuilder.h
>    llvm/trunk/include/llvm/DebugInfo.h
>    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
>    llvm/trunk/lib/IR/DIBuilder.cpp
>    llvm/trunk/lib/IR/DebugInfo.cpp
> 
> Modified: llvm/trunk/include/llvm/DIBuilder.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DIBuilder.h?rev=181632&r1=181631&r2=181632&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DIBuilder.h (original)
> +++ llvm/trunk/include/llvm/DIBuilder.h Fri May 10 16:52:07 2013
> @@ -332,10 +332,9 @@ namespace llvm {
>     /// @param LineNo       Line number.
>     /// @param ColumnNo     Column Number.
>     DITemplateValueParameter
> -    createTemplateValueParameter(DIDescriptor Scope, StringRef Name, DIType Ty,
> -                                 uint64_t Value,
> -                                 MDNode *File = 0, unsigned LineNo = 0,
> -                                 unsigned ColumnNo = 0);
> +    createTemplateValueParameter(DIDescriptor Scope, StringRef Name,
> +                                 DIType Ty, Value *Val, MDNode *File = 0,
> +                                 unsigned LineNo = 0, unsigned ColumnNo = 0);
> 
>     /// createArrayType - Create debugging information entry for an array.
>     /// @param Size         Array size.
> 
> Modified: llvm/trunk/include/llvm/DebugInfo.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo.h?rev=181632&r1=181631&r2=181632&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo.h Fri May 10 16:52:07 2013
> @@ -401,7 +401,7 @@ namespace llvm {
>     DIScope getContext() const       { return getFieldAs<DIScope>(1); }
>     StringRef getName() const        { return getStringField(2); }
>     DIType getType() const           { return getFieldAs<DIType>(3); }
> -    uint64_t getValue() const         { return getUInt64Field(4); }
> +    Value *getValue() const;
>     StringRef getFilename() const    {
>       return getFieldAs<DIFile>(5).getFilename();
>     }
> 
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=181632&r1=181631&r2=181632&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Fri May 10 16:52:07 2013
> @@ -588,6 +588,9 @@ static bool isTypeSigned(DIType Ty, int
> /// addConstantValue - Add constant value entry in variable DIE.
> bool CompileUnit::addConstantValue(DIE *Die, const MachineOperand &MO,
>                                    DIType Ty) {
> +  // FIXME: This is a bit conservative/simple - it emits negative values at
> +  // their maximum bit width which is a bit unfortunate (& doesn't prefer
> +  // udata/sdata over dataN as suggested by the DWARF spec)
>   assert(MO.isImm() && "Invalid machine operand!");
>   DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
>   int SizeInBits = -1;
> @@ -1095,8 +1098,21 @@ CompileUnit::getOrCreateTemplateValuePar
>   addType(ParamDIE, TPV.getType());
>   if (!TPV.getName().empty())
>     addString(ParamDIE, dwarf::DW_AT_name, TPV.getName());
> -  addUInt(ParamDIE, dwarf::DW_AT_const_value, dwarf::DW_FORM_udata,
> -          TPV.getValue());
> +  if (Value *Val = TPV.getValue()) {
> +    if (ConstantInt *CI = dyn_cast<ConstantInt>(Val))
> +      addConstantValue(ParamDIE, CI, TPV.getType().isUnsignedDIType());
> +    else if (GlobalValue *GV = dyn_cast<GlobalValue>(Val)) {
> +      // For declaration non-type template parameters (such as global values and
> +      // functions)
> +      DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
> +      addOpAddress(Block, Asm->Mang->getSymbol(GV));
> +      // Emit DW_OP_stack_value to use the address as the immediate value of the
> +      // parameter, rather than a pointer to it.
> +      addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
> +      addBlock(ParamDIE, dwarf::DW_AT_location, 0, Block);
> +    }
> +  }
> +
>   return ParamDIE;
> }
> 
> 
> Modified: llvm/trunk/lib/IR/DIBuilder.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=181632&r1=181631&r2=181632&view=diff
> ==============================================================================
> --- llvm/trunk/lib/IR/DIBuilder.cpp (original)
> +++ llvm/trunk/lib/IR/DIBuilder.cpp Fri May 10 16:52:07 2013
> @@ -502,7 +502,7 @@ DIBuilder::createTemplateTypeParameter(D
> /// value parameter.
> DITemplateValueParameter
> DIBuilder::createTemplateValueParameter(DIDescriptor Context, StringRef Name,
> -                                        DIType Ty, uint64_t Val,
> +                                        DIType Ty, Value *Val,
>                                         MDNode *File, unsigned LineNo,
>                                         unsigned ColumnNo) {
>   Value *Elts[] = {
> @@ -510,7 +510,7 @@ DIBuilder::createTemplateValueParameter(
>     getNonCompileUnitScope(Context),
>     MDString::get(VMContext, Name),
>     Ty,
> -    ConstantInt::get(Type::getInt64Ty(VMContext), Val),
> +    Val,
>     File,
>     ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
>     ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo)
> 
> Modified: llvm/trunk/lib/IR/DebugInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=181632&r1=181631&r2=181632&view=diff
> ==============================================================================
> --- llvm/trunk/lib/IR/DebugInfo.cpp (original)
> +++ llvm/trunk/lib/IR/DebugInfo.cpp Fri May 10 16:52:07 2013
> @@ -695,6 +695,10 @@ DIArray DISubprogram::getVariables() con
>   return DIArray();
> }
> 
> +Value *DITemplateValueParameter::getValue() const {
> +  return getField(DbgNode, 4);
> +}
> +
> void DIScope::setFilename(StringRef Name, LLVMContext &Context) {
>   if (!DbgNode)
>     return;
> 
> Added: llvm/trunk/test/DebugInfo/template.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/template.ll?rev=181632&view=auto
> ==============================================================================
> --- llvm/trunk/test/DebugInfo/template.ll (added)
> +++ llvm/trunk/test/DebugInfo/template.ll Fri May 10 16:52:07 2013
> @@ -0,0 +1,84 @@
> +; REQUIRES: object-emission
> +
> +; RUN: llc -O0 -filetype=obj < %s > %t
> +; RUN: llvm-dwarfdump %t | FileCheck %s
> +
> +; IR generated with `clang++ -g -emit-llvm -S` from the following code:
> +; template<int, int* x>  func() { }
> +; int glbl = func<3, &glbl>();
> +
> +; CHECK: [[INT:0x[0-9a-f]*]]:{{ *}}DW_TAG_base_type
> +; CHECK-NEXT: DW_AT_name{{.*}} = "int"
> +
> +; CHECK: DW_AT_name{{.*}}"func<3, &glbl>"
> +; CHECK-NOT: NULL
> +; CHECK: DW_TAG_template_value_parameter
> +; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]}
> +; CHECK-NEXT: DW_AT_name{{.*}}= "x"
> +
> +; This could be made shorter by encoding it as _sdata rather than data4, or
> +; even as data1. DWARF strongly urges implementations to prefer 
> +; _sdata/_udata rather than dataN
> +
> +; CHECK-NEXT: DW_AT_const_value [DW_FORM_data4]{{.*}}(0x00000003)
> +
> +; CHECK: DW_TAG_template_value_parameter
> +; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INTPTR:0x[0-9a-f]*]]}
> +
> +; The address of the global 'glbl', followed by DW_OP_stack_value (9f), to use
> +; the value immediately, rather than indirecting through the address.
> +
> +; CHECK-NEXT: DW_AT_location [DW_FORM_block1]{{ *}}(<0x0a> 03 00 00 00 00 00 00 00 00 9f )
> +
> +; CHECK: [[INTPTR]]:{{ *}}DW_TAG_pointer_type
> +; CHECK-NEXT: DW_AT_type{{.*}} => {[[INT]]}
> +
> + at glbl = global i32 0, align 4
> + at llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }]
> +
> +define internal void @__cxx_global_var_init() section ".text.startup" {
> +entry:
> +  %call = call i32 @_Z4funcILi3EXadL_Z4glblEEEiv(), !dbg !20
> +  store i32 %call, i32* @glbl, align 4, !dbg !20
> +  ret void, !dbg !20
> +}
> +
> +; Function Attrs: nounwind uwtable
> +define linkonce_odr i32 @_Z4funcILi3EXadL_Z4glblEEEiv() #0 {
> +entry:
> +  ret i32 3, !dbg !21
> +}
> +
> +define internal void @_GLOBAL__I_a() section ".text.startup" {
> +entry:
> +  call void @__cxx_global_var_init(), !dbg !22
> +  ret void, !dbg !22
> +}
> +
> +attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
> +
> +!llvm.dbg.cu = !{!0}
> +
> +!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !18, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/usr/local/google/home/blaikie/dev/scratch/templ.cpp] [DW_LANG_C_plus_plus]
> +!1 = metadata !{metadata !"templ.cpp", metadata !"/usr/local/google/home/blaikie/dev/scratch"}
> +!2 = metadata !{i32 0}
> +!3 = metadata !{metadata !4, metadata !8, metadata !16}
> +!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"__cxx_global_var_init", metadata !"__cxx_global_var_init", metadata !"", i32 2, metadata !6, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, void ()* @__cxx_global_var_init, null, null, metadata !2, i32 2} ; [ DW_TAG_subprogram ] [line 2] [local] [def] [__cxx_global_var_init]
> +!5 = metadata !{i32 786473, metadata !1}          ; [ DW_TAG_file_type ] [/usr/local/google/home/blaikie/dev/scratch/templ.cpp]
> +!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
> +!7 = metadata !{null}
> +!8 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"func<3, &glbl>", metadata !"func<3, &glbl>", metadata !"_Z4funcILi3EXadL_Z4glblEEEiv", i32 1, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @_Z4funcILi3EXadL_Z4glblEEEiv, metadata !12, null, metadata !2, i32 1} ; [ DW_TAG_subprogram ] [line 1] [def] [func<3, &glbl>]
> +!9 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !10, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
> +!10 = metadata !{metadata !11}
> +!11 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
> +!12 = metadata !{metadata !13, metadata !14}
> +!13 = metadata !{i32 786480, null, metadata !"x", metadata !11, i32 3, null, i32 0, i32 0} ; [ DW_TAG_template_value_parameter ]
> +!14 = metadata !{i32 786480, null, metadata !"", metadata !15, i32* @glbl, null, i32 0, i32 0} ; [ DW_TAG_template_value_parameter ]
> +!15 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !11} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int]
> +!16 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"_GLOBAL__I_a", metadata !"_GLOBAL__I_a", metadata !"", i32 1, metadata !17, i1 true, i1 true, i32 0, i32 0, null, i32 64, i1 false, void ()* @_GLOBAL__I_a, null, null, metadata !2, i32 1} ; [ DW_TAG_subprogram ] [line 1] [local] [def] [_GLOBAL__I_a]
> +!17 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !2, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
> +!18 = metadata !{metadata !19}
> +!19 = metadata !{i32 786484, i32 0, null, metadata !"glbl", metadata !"glbl", metadata !"", metadata !5, i32 2, metadata !11, i32 0, i32 1, i32* @glbl, null} ; [ DW_TAG_variable ] [glbl] [line 2] [def]
> +!20 = metadata !{i32 2, i32 0, metadata !4, null}
> +!21 = metadata !{i32 1, i32 0, metadata !8, null}
> +!22 = metadata !{i32 1, i32 0, metadata !16, null}
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130510/9333f8e1/attachment.html>


More information about the llvm-commits mailing list