[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.
awpandey updated this revision to Diff 235998. awpandey added a comment. Herald added a subscriber: hiraditya. @dblaikie Thanks a lot for the suggestions. I have made the changes such that this will become consistent with your suggestions. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70524/new/ https://reviews.llvm.org/D70524 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h clang/test/CodeGenCXX/debug-info-auto-return.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp === --- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1165,6 +1165,14 @@ DIE *DeclDie = nullptr; StringRef DeclLinkageName; if (auto *SPDecl = SP->getDeclaration()) { +DITypeRefArray DeclArgs, DefinitionArgs; +DeclArgs = SPDecl->getType()->getTypeArray(); +DefinitionArgs = SP->getType()->getTypeArray(); + +if (DeclArgs.size() && DefinitionArgs.size()) + if (DeclArgs[0] != DefinitionArgs[0]) +addType(SPDie, DefinitionArgs[0]); + DeclDie = getDIE(SPDecl); assert(DeclDie && "This DIE should've already been constructed when the " "definition DIE was created in " Index: clang/test/CodeGenCXX/debug-info-auto-return.cpp === --- /dev/null +++ clang/test/CodeGenCXX/debug-info-auto-return.cpp @@ -0,0 +1,22 @@ +// Test for debug info for C++11 auto return member functions +// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -triple x86_64-linux-gnu %s -o - \ +// RUN: -O0 -disable-llvm-passes \ +// RUN: -debug-info-kind=standalone \ +// RUN: | FileCheck %s + +// CHECK: !DISubprogram(name: "findMax",{{.*}}, type: ![[t:[0-9]+]],{{.*}} + +// CHECK: ![[t:[0-9]+]] = !DISubroutineType(types: ![[t1:[0-9]+]]) +// CHECK-NEXT: ![[t1:[0-9]+]] = !{![[t2:[0-9]+]], {{.*}} +// CHECK-NEXT: ![[t2:[0-9]+]] = !DIBasicType(name: "double", {{.*}}) + +// CHECK: ![[t:[0-9]+]] = !DISubroutineType(types: ![[t1:[0-9]+]]) +// CHECK-NEXT: ![[t1:[0-9]+]] = !{![[t2:[0-9]+]], {{.*}} +// CHECK-NEXT: ![[t2:[0-9]+]] = !DIBasicType(tag: DW_TAG_unspecified_type, name: "auto") +struct myClass { + auto findMax(); +}; + +auto myClass::findMax() { + return 0.0; +} Index: clang/lib/CodeGen/CGDebugInfo.h === --- clang/lib/CodeGen/CGDebugInfo.h +++ clang/lib/CodeGen/CGDebugInfo.h @@ -165,6 +165,7 @@ /// ivars and property accessors. llvm::DIType *CreateType(const BuiltinType *Ty); llvm::DIType *CreateType(const ComplexType *Ty); + llvm::DIType *CreateType(const AutoType *Ty); llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg); llvm::DIType *CreateType(const TypedefType *Ty, llvm::DIFile *Fg); llvm::DIType *CreateType(const TemplateSpecializationType *Ty, @@ -214,10 +215,10 @@ /// not updated to include implicit \c this pointer. Use this routine /// to get a method type which includes \c this pointer. llvm::DISubroutineType *getOrCreateMethodType(const CXXMethodDecl *Method, -llvm::DIFile *F); +llvm::DIFile *F, bool decl); llvm::DISubroutineType * getOrCreateInstanceMethodType(QualType ThisPtr, const FunctionProtoType *Func, -llvm::DIFile *Unit); +llvm::DIFile *Unit, bool decl); llvm::DISubroutineType * getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile *F); /// \return debug info descriptor for vtable. Index: clang/lib/CodeGen/CGDebugInfo.cpp === --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -810,6 +810,10 @@ return DBuilder.createBasicType(BTName, Size, Encoding); } +llvm::DIType *CGDebugInfo::CreateType(const AutoType *Ty) { + return DBuilder.createUnspecifiedType("auto"); +} + llvm::DIType *CGDebugInfo::CreateType(const ComplexType *Ty) { // Bit size and offset of the type. llvm::dwarf::TypeKind Encoding = llvm::dwarf::DW_ATE_complex_float; @@ -1457,16 +1461,18 @@ llvm::DISubroutineType * CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method, - llvm::DIFile *Unit) { + llvm::DIFile *Unit, bool decl) { const FunctionProtoType *Func = Method->getType()->getAs(); if (Method->isStatic()) return cast_or_null( getOrCreateType(QualType(Func, 0), Unit)); - return getOrCreateInstanceMethodType(Method->getThisType(), Func, Unit); + return getOrCreateInstanceMethodType(Method->getThisType(), Func, Unit, decl); } -llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType( -QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile *Unit) { +llvm::DISu
[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.
awpandey updated this revision to Diff 237264. awpandey added a comment. @dblaikie I have added an LLVM test case and I will commit it like a different patch. I have also updated the clang test case. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70524/new/ https://reviews.llvm.org/D70524 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h clang/test/CodeGenCXX/debug-info-auto-return.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/test/DebugInfo/X86/debug-info-auto-return.ll Index: llvm/test/DebugInfo/X86/debug-info-auto-return.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-auto-return.ll @@ -0,0 +1,70 @@ +; RUN: llc %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; CHECK: .debug_info contents: + +; CHECK: DW_TAG_subprogram +; CHECK-NEXT: DW_AT_linkage_name [DW_FORM_strx1](indexed {{.*}} string = "_ZN7myClass7findMaxEv") +; CHECK: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} "auto") +; CHECK-NEXT: DW_AT_declaration [DW_FORM_flag_present] (true) + +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} "double") +; CHECK: DW_AT_specification [DW_FORM_ref4] (cu + {{.*}} "_ZN7myClass7findMaxEv") + +; C++ source to regenerate: +; struct myClass { +;auto findMax(); +; }; +; +; auto myClass::findMax() { +;return 0.0; +; } + +; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c + +; ModuleID = '/dir/test.cpp' +source_filename = "/dir/test.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%struct.myClass = type { i8 } +; Function Attrs: noinline nounwind optnone uwtable +define dso_local double @_ZN7myClass7findMaxEv(%struct.myClass* %this) #0 align 2 !dbg !7 { +entry: + %this.addr = alloca %struct.myClass*, align 8 + store %struct.myClass* %this, %struct.myClass** %this.addr, align 8 + call void @llvm.dbg.declare(metadata %struct.myClass** %this.addr, metadata !17, metadata !DIExpression()), !dbg !19 + %this1 = load %struct.myClass*, %struct.myClass** %this.addr, align 8 + ret double 0.00e+00, !dbg !20 +} +; Function Attrs: nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +attributes #0 = { noinline nounwind optnone uwtable } +attributes #1 = { nounwind readnone speculatable willreturn } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) +!1 = !DIFile(filename: "/dir/test.cpp", directory: "/dir/", checksumkind: CSK_MD5, checksum: "4bed8955bd441e3129c12f557ed53962") +!2 = !{} +!3 = !{i32 7, !"Dwarf Version", i32 5} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{!"clang version 10.0.0"} +!7 = distinct !DISubprogram(name: "findMax", linkageName: "_ZN7myClass7findMaxEv", scope: !8, file: !1, line: 20, type: !9, scopeLine: 20, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !13, retainedNodes: !2) +!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "myClass", file: !1, line: 16, size: 8, flags: DIFlagTypePassByValue, elements: !2, identifier: "_ZTS7myClass") +!9 = !DISubroutineType(types: !10) +!10 = !{!11, !12} +!11 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float) +!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) +!13 = !DISubprogram(name: "findMax", linkageName: "_ZN7myClass7findMaxEv", scope: !8, file: !1, line: 17, type: !14, scopeLine: 17, flags: DIFlagPrototyped, spFlags: 0) +!14 = !DISubroutineType(types: !15) +!15 = !{!16, !12} +!16 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "auto") +!17 = !DILocalVariable(name: "this", arg: 1, scope: !7, type: !18, flags: DIFlagArtificial | DIFlagObjectPointer) +!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64) +!19 = !DILocation(line: 0, scope: !7) +!20 = !DILocation(line: 21, column: 3, scope: !7) Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp === --- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1165,6 +1165,14 @@ DIE *DeclDie = nullptr; StringRef DeclLinkageName; if (auto *SPDecl = SP->getDeclaration()) { +DITypeRefArray DeclArgs, DefinationArgs; +DeclArgs = SPDecl->getType()->getTypeArray(); +DefinationArgs = SP->getType()->getTypeArray(); + +if (DeclArgs.size() && DefinationArgs.size()) + if (DeclArgs[0] != DefinationArgs[0]) +addType(SPDie, DefinationArgs[0]); + DeclDie = getDIE(SPDecl); assert(DeclDie
[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates
awpandey updated this revision to Diff 245875. awpandey marked 7 inline comments as done. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73462/new/ https://reviews.llvm.org/D73462 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-template-parameter.cpp llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/test/Assembler/DITemplateParameter.ll llvm/test/Bitcode/DITemplateParameter-5.0.ll llvm/test/Bitcode/DITemplateParameter-5.0.ll.bc llvm/test/DebugInfo/X86/debug-info-template-parameter.ll llvm/unittests/IR/MetadataTest.cpp Index: llvm/unittests/IR/MetadataTest.cpp === --- llvm/unittests/IR/MetadataTest.cpp +++ llvm/unittests/IR/MetadataTest.cpp @@ -2076,17 +2076,19 @@ TEST_F(DITemplateTypeParameterTest, get) { StringRef Name = "template"; DIType *Type = getBasicType("basic"); + bool defaulted = false; - auto *N = DITemplateTypeParameter::get(Context, Name, Type); + auto *N = DITemplateTypeParameter::get(Context, Name, Type, defaulted); EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); - EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type)); + EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type, defaulted)); - EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type)); - EXPECT_NE(N, -DITemplateTypeParameter::get(Context, Name, getBasicType("other"))); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type, defaulted)); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name, +getBasicType("other"), defaulted)); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name, Type, true)); TempDITemplateTypeParameter Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); @@ -2100,22 +2102,26 @@ DIType *Type = getBasicType("basic"); Metadata *Value = getConstantAsMetadata(); - auto *N = DITemplateValueParameter::get(Context, Tag, Name, Type, Value); + auto *N = + DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value); EXPECT_EQ(Tag, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); EXPECT_EQ(Value, N->getValue()); - EXPECT_EQ(N, DITemplateValueParameter::get(Context, Tag, Name, Type, Value)); + EXPECT_EQ( + N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value)); EXPECT_NE(N, DITemplateValueParameter::get( Context, dwarf::DW_TAG_GNU_template_template_param, Name, - Type, Value)); - EXPECT_NE(N, -DITemplateValueParameter::get(Context, Tag, "other", Type, Value)); - EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, - getBasicType("other"), Value)); - EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, + Type, false, Value)); + EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, "other", Type, false, + Value)); + EXPECT_NE(N, DITemplateValueParameter::get( + Context, Tag, Name, getBasicType("other"), false, Value)); + EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, getConstantAsMetadata())); + EXPECT_NE( + N, DITemplateValueParameter::get(Context, Tag, Name, Type, true, Value)); TempDITemplateValueParameter Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); Index: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-template-parameter.ll @@ -0,0 +1,90 @@ +; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;template +;class foo { +;}; +; +;int main() { +; foo f1; +; foo<> f2; +; return 0; +;} + +; $ clang++ -O0 -gdwarf-5 -S -gdwarf-5 test.cpp + +; CHECK: .debug_abbrev contents: +; CHECK: DW_AT_default_value DW_FORM_flag_present + +; CHECK: debug_info contents: + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK-NOT: DW_AT_default_value +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "i" +; CHECK-NOT: DW_AT_default_value + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "char" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK_NEXT: DW_AT_default_value {{.*}} true
[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates
awpandey updated this revision to Diff 247546. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73462/new/ https://reviews.llvm.org/D73462 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-template-parameter.cpp llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/test/Assembler/DITemplateParameter.ll llvm/test/Bitcode/DITemplateParameter-5.0.ll llvm/test/Bitcode/DITemplateParameter-5.0.ll.bc llvm/test/DebugInfo/X86/debug-info-template-parameter.ll llvm/unittests/IR/MetadataTest.cpp Index: llvm/unittests/IR/MetadataTest.cpp === --- llvm/unittests/IR/MetadataTest.cpp +++ llvm/unittests/IR/MetadataTest.cpp @@ -2076,17 +2076,19 @@ TEST_F(DITemplateTypeParameterTest, get) { StringRef Name = "template"; DIType *Type = getBasicType("basic"); + bool defaulted = false; - auto *N = DITemplateTypeParameter::get(Context, Name, Type); + auto *N = DITemplateTypeParameter::get(Context, Name, Type, defaulted); EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); - EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type)); + EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type, defaulted)); - EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type)); - EXPECT_NE(N, -DITemplateTypeParameter::get(Context, Name, getBasicType("other"))); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type, defaulted)); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name, +getBasicType("other"), defaulted)); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name, Type, true)); TempDITemplateTypeParameter Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); @@ -2098,24 +2100,31 @@ unsigned Tag = dwarf::DW_TAG_template_value_parameter; StringRef Name = "template"; DIType *Type = getBasicType("basic"); + bool defaulted = false; Metadata *Value = getConstantAsMetadata(); - auto *N = DITemplateValueParameter::get(Context, Tag, Name, Type, Value); + auto *N = + DITemplateValueParameter::get(Context, Tag, Name, Type, defaulted, Value); EXPECT_EQ(Tag, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); EXPECT_EQ(Value, N->getValue()); - EXPECT_EQ(N, DITemplateValueParameter::get(Context, Tag, Name, Type, Value)); + EXPECT_EQ(N, DITemplateValueParameter::get(Context, Tag, Name, Type, + defaulted, Value)); EXPECT_NE(N, DITemplateValueParameter::get( Context, dwarf::DW_TAG_GNU_template_template_param, Name, - Type, Value)); - EXPECT_NE(N, -DITemplateValueParameter::get(Context, Tag, "other", Type, Value)); + Type, defaulted, Value)); + EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, "other", Type, + defaulted, Value)); EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, - getBasicType("other"), Value)); - EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, - getConstantAsMetadata())); + getBasicType("other"), defaulted, + Value)); + EXPECT_NE(N, +DITemplateValueParameter::get(Context, Tag, Name, Type, defaulted, + getConstantAsMetadata())); + EXPECT_NE( + N, DITemplateValueParameter::get(Context, Tag, Name, Type, true, Value)); TempDITemplateValueParameter Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); Index: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-template-parameter.ll @@ -0,0 +1,90 @@ +; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;template +;class foo { +;}; +; +;int main() { +; foo f1; +; foo<> f2; +; return 0; +;} + +; $ clang++ -O0 -gdwarf-5 -S -gdwarf-5 test.cpp + +; CHECK: .debug_abbrev contents: +; CHECK: DW_AT_default_value DW_FORM_flag_present + +; CHECK: debug_info contents: + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK-NOT: DW_AT_default_value +; CHECK: DW_AT_type {{.*}} "int" +
[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5
awpandey created this revision. awpandey added reviewers: aprantl, dblaikie, jini.susan.george, SouraVX, alok. awpandey added a project: debug-info. Herald added subscribers: llvm-commits, cfe-commits, ormris, hiraditya. Herald added projects: clang, LLVM. This patch, adds support for DW_AT_alignment[DWARF5], to be emitted with typdef. When explicit alignment is specified. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D70111 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-template-align.cpp llvm/include/llvm/IR/DIBuilder.h llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/DIBuilder.cpp llvm/test/DebugInfo/X86/debug-info-template-align.ll Index: llvm/test/DebugInfo/X86/debug-info-template-align.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-template-align.ll @@ -0,0 +1,64 @@ +; RUN: llc < %s -filetype=obj -o %t +; RUN: llvm-dwarfdump -v %t | FileCheck %s + +; C++ source to regenerate: + +;typedef char __attribute__((__aligned__(64))) alchar; + +;int main(){ +;alchar newChar; +;} +; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c + +; CHECK: .debug_abbrev contents: + +; CHECK: [5] DW_TAG_typedef DW_CHILDREN_no +; CHECK: DW_AT_alignment DW_FORM_udata + +; CHECK: .debug_info contents: + +;CHECK: DW_TAG_typedef [5] +;CHECK: DW_AT_name {{.*}} "alchar" +;CHECK-NEXT: DW_AT_alignment [DW_FORM_udata] (64) + + +; ModuleID = '/home/awpandey/tools/llvm/tools/clang/test/CodeGenCXX/debug-info-template-align.cpp' +source_filename = "/home/awpandey/tools/llvm/tools/clang/test/CodeGenCXX/debug-info-template-align.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Function Attrs: noinline norecurse nounwind optnone uwtable +define dso_local i32 @main() #0 !dbg !7 { +entry: + %newChar = alloca i8, align 64 + call void @llvm.dbg.declare(metadata i8* %newChar, metadata !12, metadata !DIExpression()), !dbg !15 + ret i32 0, !dbg !16 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +attributes #0 = { noinline norecurse nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone speculatable willreturn } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0 (ssh://awpan...@idcvgits02.amd.com:29418/perfcompiler/er/llvm/cpu/clang 8b3533f5560dd219a0e6d346be2190623822bada) (llvm/cpu/llvm 61a342a7f3320d5517ba0bd012edc7cc908b36b7)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) +!1 = !DIFile(filename: "/home/awpandey/tools/llvm/tools/clang/test/CodeGenCXX/debug-info-template-align.cpp", directory: "/home/awpandey/tools/llvm/test/DebugInfo", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 5} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{!"clang version 10.0.0 (ssh://awpan...@idcvgits02.amd.com:29418/perfcompiler/er/llvm/cpu/clang 8b3533f5560dd219a0e6d346be2190623822bada) (llvm/cpu/llvm 61a342a7f3320d5517ba0bd012edc7cc908b36b7)"} +!7 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 12, type: !9, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) +!8 = !DIFile(filename: "tools/clang/test/CodeGenCXX/debug-info-template-align.cpp", directory: "/home/awpandey/tools/llvm", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab") +!9 = !DISubroutineType(types: !10) +!10 = !{!11} +!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!12 = !DILocalVariable(name: "newChar", scope: !7, file: !8, line: 13, type: !13) +!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "alchar", file: !8, line: 10, baseType: !14, align: 512) +!14 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!15 = !DILocation(line: 13, column: 10, scope: !7) +!16 = !DILocation(line: 14, column: 1, scope: !7) Index: llvm/lib/IR/DIBuilder.cpp === --- llvm/lib/IR/DIBuilder.cpp +++ llvm/lib/IR/DIBuilder.cpp @@ -305,10 +305,11 @@ DIDerivedType *DIBuilder::createTypedef(DIType *Ty, StringRef Name,
[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5
awpandey updated this revision to Diff 228852. awpandey added a comment. Revised and address comments of @djtodoro CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70111/new/ https://reviews.llvm.org/D70111 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-template-align.cpp llvm/include/llvm/IR/DIBuilder.h llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/DIBuilder.cpp llvm/test/DebugInfo/X86/debug-info-template-align.ll Index: llvm/test/DebugInfo/X86/debug-info-template-align.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-template-align.ll @@ -0,0 +1,64 @@ +; RUN: llc < %s -filetype=obj -o %t +; RUN: llvm-dwarfdump -v %t | FileCheck %s + +; C++ source to regenerate: + +;typedef char __attribute__((__aligned__(64))) alchar; + +;int main(){ +;alchar newChar; +;} +; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c + +; CHECK: .debug_abbrev contents: + +; CHECK: [5] DW_TAG_typedef DW_CHILDREN_no +; CHECK: DW_AT_alignment DW_FORM_udata + +; CHECK: .debug_info contents: + +;CHECK: DW_TAG_typedef [5] +;CHECK: DW_AT_name {{.*}} "alchar" +;CHECK-NEXT: DW_AT_alignment [DW_FORM_udata] (64) + + +; ModuleID = '/dir/test.cpp' +source_filename = "/dir/test.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Function Attrs: noinline norecurse nounwind optnone uwtable +define dso_local i32 @main() #0 !dbg !7 { +entry: + %newChar = alloca i8, align 64 + call void @llvm.dbg.declare(metadata i8* %newChar, metadata !12, metadata !DIExpression()), !dbg !15 + ret i32 0, !dbg !16 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +attributes #0 = { noinline norecurse nounwind optnone uwtable } +attributes #1 = { nounwind readnone speculatable willreturn } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) +!1 = !DIFile(filename: "/dir/test.cpp", directory: "/home/awpandey/tools/llvm/test/DebugInfo", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 5} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{!"clang version 10.0.0 "} +!7 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 12, type: !9, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) +!8 = !DIFile(filename: "test.cpp", directory: "/dir", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab") +!9 = !DISubroutineType(types: !10) +!10 = !{!11} +!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!12 = !DILocalVariable(name: "newChar", scope: !7, file: !8, line: 13, type: !13) +!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "alchar", file: !8, line: 10, baseType: !14, align: 512) +!14 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!15 = !DILocation(line: 13, column: 10, scope: !7) +!16 = !DILocation(line: 14, column: 1, scope: !7) Index: llvm/lib/IR/DIBuilder.cpp === --- llvm/lib/IR/DIBuilder.cpp +++ llvm/lib/IR/DIBuilder.cpp @@ -305,10 +305,11 @@ DIDerivedType *DIBuilder::createTypedef(DIType *Ty, StringRef Name, DIFile *File, unsigned LineNo, -DIScope *Context) { +DIScope *Context, +uint32_t AlignInBits) { return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File, -LineNo, getNonCompileUnitScope(Context), Ty, 0, 0, -0, None, DINode::FlagZero); +LineNo, getNonCompileUnitScope(Context), Ty, 0, +AlignInBits, 0, None, DINode::FlagZero); } DIDerivedType *DIBuilder::createFriend(DIType *Ty, DIType *FriendTy) { Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp === --- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -800,6 +800,15 @@ if (!Name.empty()) addString(Buffer, dwarf::DW_AT_name, Name); + // If alignment is specified for a typedef , create and insert DW_AT_alignment + // attribute in DW_TAG_typedef DIE. + if (Tag == dwarf::DW_TAG_typedef && DD->getDwarfVersion() >= 5) { +uint32_t AlignInBytes = DTy->getAlignInBytes(); +if (AlignInBytes > 0) + addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata, +
[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5
awpandey marked 8 inline comments as done. awpandey added a comment. Thank you @djtodoro for reviewing this. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70111/new/ https://reviews.llvm.org/D70111 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5
awpandey updated this revision to Diff 229013. awpandey marked 3 inline comments as done. awpandey added a comment. Herald added a reviewer: deadalnix. @aprantl Thanks for the suggestion. Based on your suggestion I have done the following changes 1. I have added alignment value as a check in the test case 2. I have added C-Binding changes. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70111/new/ https://reviews.llvm.org/D70111 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-template-align.cpp llvm/include/llvm-c/DebugInfo.h llvm/include/llvm/IR/DIBuilder.h llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfo.cpp llvm/test/DebugInfo/X86/debug-info-template-align.ll llvm/tools/llvm-c-test/debuginfo.c Index: llvm/tools/llvm-c-test/debuginfo.c === --- llvm/tools/llvm-c-test/debuginfo.c +++ llvm/tools/llvm-c-test/debuginfo.c @@ -69,7 +69,7 @@ LLVMMetadataRef Int64Ty = LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0, LLVMDIFlagZero); LLVMMetadataRef Int64TypeDef = -LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File); + LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File, 0); LLVMMetadataRef GlobalVarValueExpr = LLVMDIBuilderCreateConstantValueExpression(DIB, 0); Index: llvm/test/DebugInfo/X86/debug-info-template-align.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-template-align.ll @@ -0,0 +1,63 @@ +; RUN: llc %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;typedef char __attribute__((__aligned__(64))) alchar; + +;int main(){ +;alchar newChar; +;} +; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c + +; CHECK: .debug_abbrev contents: + +; CHECK: [5] DW_TAG_typedef DW_CHILDREN_no +; CHECK: DW_AT_alignment DW_FORM_udata + +; CHECK: .debug_info contents: + +;CHECK: DW_TAG_typedef [5] +;CHECK: DW_AT_name {{.*}} "alchar" +;CHECK-NEXT: DW_AT_alignment [DW_FORM_udata] (64) + + +; ModuleID = '/dir/test.cpp' +source_filename = "/dir/test.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Function Attrs: noinline norecurse nounwind optnone uwtable +define dso_local i32 @main() #0 !dbg !7 { +entry: + %newChar = alloca i8, align 64 + call void @llvm.dbg.declare(metadata i8* %newChar, metadata !12, metadata !DIExpression()), !dbg !15 + ret i32 0, !dbg !16 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +attributes #0 = { noinline norecurse nounwind optnone uwtable } +attributes #1 = { nounwind readnone speculatable willreturn } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) +!1 = !DIFile(filename: "/dir/test.cpp", directory: "/home/awpandey/tools/llvm/test/DebugInfo", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 5} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{!"clang version 10.0.0 "} +!7 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 12, type: !9, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) +!8 = !DIFile(filename: "test.cpp", directory: "/dir", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab") +!9 = !DISubroutineType(types: !10) +!10 = !{!11} +!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!12 = !DILocalVariable(name: "newChar", scope: !7, file: !8, line: 13, type: !13) +!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "alchar", file: !8, line: 10, baseType: !14, align: 512) +!14 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!15 = !DILocation(line: 13, column: 10, scope: !7) +!16 = !DILocation(line: 14, column: 1, scope: !7) Index: llvm/lib/IR/DebugInfo.cpp === --- llvm/lib/IR/DebugInfo.cpp +++ llvm/lib/IR/DebugInfo.cpp @@ -1108,11 +1108,10 @@ LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, - LLVMMetadataRef Scope) { + LLVMMetadataRef Scope, uint32_t AlignInBits) { return wrap(unwrap(Builder)->createTypedef( - unwrapDI(Type), {Name, NameLen}, - unwrapDI(File), LineNo, -
[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5
awpandey added inline comments. Comment at: clang/test/CodeGenCXX/debug-info-template-align.cpp:8 + +// CHECK: DIDerivedType(tag: DW_TAG_typedef, {{.*}}, align: + aprantl wrote: > Do we need to hardcode the target here? Could we check for the specific align > value? Sorry, I could not get your first comment > Do we need to hardcode the target here? I have incorporated your rest of the suggestions. Comment at: llvm/include/llvm/IR/DIBuilder.h:243 + unsigned LineNo, DIScope *Context, + uint32_t AlignInBits = 0); aprantl wrote: > This should be `Optional` AlignInBits. Even better perhaps > `llvm::Align` but perhaps that's too restrictive. Yes @aprantl this should be of `Optional` type but changing this will require change in the `DIDerivedType::get` macro and this macro is used by many other functions. Please correct me if I am wrong. ?? Current functionality of the `createTypeDef` is like the default value of the `alignInBits` will be `0`. Consider below comment in `DIBuilder.cpp`. Comment at: llvm/lib/IR/DIBuilder.cpp:309 -DIScope *Context) { +DIScope *Context, +uint32_t AlignInBits) { return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File, -LineNo, getNonCompileUnitScope(Context), Ty, 0, 0, Consider the 9th argument here ``` return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File,LineNo, getNonCompileUnitScope(Context), Ty, 0, 0, --Hard coded alignment for the typedef field in existing API. 0, None, DINode::FlagZero); } ``` That is why rather than changing the entire API by using `Option` I used `uint_32` CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70111/new/ https://reviews.llvm.org/D70111 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5
awpandey updated this revision to Diff 229544. awpandey added a comment. Thanks for your suggestion @aprantl. I have revised the data type based on your suggestion. Please inform me if any other changes are required. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70111/new/ https://reviews.llvm.org/D70111 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-template-align.cpp llvm/include/llvm-c/DebugInfo.h llvm/include/llvm/IR/DIBuilder.h llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfo.cpp llvm/test/DebugInfo/X86/debug-info-template-align.ll llvm/tools/llvm-c-test/debuginfo.c Index: llvm/tools/llvm-c-test/debuginfo.c === --- llvm/tools/llvm-c-test/debuginfo.c +++ llvm/tools/llvm-c-test/debuginfo.c @@ -69,7 +69,7 @@ LLVMMetadataRef Int64Ty = LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0, LLVMDIFlagZero); LLVMMetadataRef Int64TypeDef = -LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File); + LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File, 0); LLVMMetadataRef GlobalVarValueExpr = LLVMDIBuilderCreateConstantValueExpression(DIB, 0); Index: llvm/test/DebugInfo/X86/debug-info-template-align.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-template-align.ll @@ -0,0 +1,63 @@ +; RUN: llc %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;typedef char __attribute__((__aligned__(64))) alchar; + +;int main(){ +;alchar newChar; +;} +; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c + +; CHECK: .debug_abbrev contents: + +; CHECK: [5] DW_TAG_typedef DW_CHILDREN_no +; CHECK: DW_AT_alignment DW_FORM_udata + +; CHECK: .debug_info contents: + +;CHECK: DW_TAG_typedef [5] +;CHECK: DW_AT_name {{.*}} "alchar" +;CHECK-NEXT: DW_AT_alignment [DW_FORM_udata] (64) + + +; ModuleID = '/dir/test.cpp' +source_filename = "/dir/test.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Function Attrs: noinline norecurse nounwind optnone uwtable +define dso_local i32 @main() #0 !dbg !7 { +entry: + %newChar = alloca i8, align 64 + call void @llvm.dbg.declare(metadata i8* %newChar, metadata !12, metadata !DIExpression()), !dbg !15 + ret i32 0, !dbg !16 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +attributes #0 = { noinline norecurse nounwind optnone uwtable } +attributes #1 = { nounwind readnone speculatable willreturn } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) +!1 = !DIFile(filename: "/dir/test.cpp", directory: "/home/awpandey/tools/llvm/test/DebugInfo", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 5} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{!"clang version 10.0.0 "} +!7 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 12, type: !9, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) +!8 = !DIFile(filename: "test.cpp", directory: "/dir", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab") +!9 = !DISubroutineType(types: !10) +!10 = !{!11} +!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!12 = !DILocalVariable(name: "newChar", scope: !7, file: !8, line: 13, type: !13) +!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "alchar", file: !8, line: 10, baseType: !14, align: 512) +!14 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!15 = !DILocation(line: 13, column: 10, scope: !7) +!16 = !DILocation(line: 14, column: 1, scope: !7) Index: llvm/lib/IR/DebugInfo.cpp === --- llvm/lib/IR/DebugInfo.cpp +++ llvm/lib/IR/DebugInfo.cpp @@ -1108,11 +1108,10 @@ LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, - LLVMMetadataRef Scope) { + LLVMMetadataRef Scope, uint32_t AlignInBits) { return wrap(unwrap(Builder)->createTypedef( - unwrapDI(Type), {Name, NameLen}, - unwrapDI(File), LineNo, - unwrapDI(Scope))); + unwrapDI(Type), {Name, NameLen}, unwrapDI(File), LineNo, + unwrapDI(Scope), AlignInBits)); }
[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5
awpandey added a comment. Hi @aprantl. I had made the changes and my team member will commit this. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70111/new/ https://reviews.llvm.org/D70111 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5
awpandey added a comment. Hi @aprantl. Can we drop C binding for this feature ? What will be the impact of this. As noted by @sammccall this does not conform / break LLVM-C ABI? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70111/new/ https://reviews.llvm.org/D70111 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.
awpandey created this revision. awpandey added reviewers: jini.susan.george, SouraVX, alok, aprantl, dblaikie. awpandey added projects: clang, LLVM, debug-info. Herald added subscribers: llvm-commits, cfe-commits, ormris. This patch will provide support for auto return type for the C++ member functions. Before this return type of the member function is deduced and store in the DIE. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D70524 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h clang/test/CodeGenCXX/debug-info-auto-return.cpp llvm/test/DebugInfo/X86/debug-info-auto-return.ll Index: llvm/test/DebugInfo/X86/debug-info-auto-return.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-auto-return.ll @@ -0,0 +1,171 @@ +;RUN: llc %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;class myClass { +;int low, high; +; +; public: +; myClass(int a, int b) { +;low = a; +;high = b; +; } +;auto findMax(); +;}; +; +;auto myClass::findMax() { +;if (low > high) +;return 1; +; else +;return 1; +;} +;int main() { +;myClass f(3, 5); +; return 0; +;} + +; CHECK: .debug_info contents: + +; CHECK: DW_TAG_subprogram [7] * +; CHECK-NEXT: DW_AT_linkage_name [DW_FORM_strx1](indexed (0007) string = "_ZN7myClass7findMaxEv") +; CHECK: DW_AT_type [DW_FORM_ref4] {{.*}} "auto" +; CHECK-NEXT: DW_AT_declaration {{.*}} (true) + +; CHECK: DW_TAG_unspecified_type +; CHECK-NEXT: DW_AT_name [DW_FORM_strx1] {{.*}} "auto" + +; ModuleID = 'debug-info-auto-return.cpp' +source_filename = "debug-info-auto-return.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%class.myClass = type { i32, i32 } + +$_ZN7myClassC2Eii = comdat any + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @_ZN7myClass7findMaxEv(%class.myClass* %this) #0 align 2 !dbg !7 { +entry: + %retval = alloca i32, align 4 + %this.addr = alloca %class.myClass*, align 8 + store %class.myClass* %this, %class.myClass** %this.addr, align 8 + call void @llvm.dbg.declare(metadata %class.myClass** %this.addr, metadata !22, metadata !DIExpression()), !dbg !24 + %this1 = load %class.myClass*, %class.myClass** %this.addr, align 8 + %low = getelementptr inbounds %class.myClass, %class.myClass* %this1, i32 0, i32 0, !dbg !25 + %0 = load i32, i32* %low, align 4, !dbg !25 + %high = getelementptr inbounds %class.myClass, %class.myClass* %this1, i32 0, i32 1, !dbg !27 + %1 = load i32, i32* %high, align 4, !dbg !27 + %cmp = icmp sgt i32 %0, %1, !dbg !28 + br i1 %cmp, label %if.then, label %if.else, !dbg !29 + +if.then: ; preds = %entry + store i32 1, i32* %retval, align 4, !dbg !30 + br label %return, !dbg !30 + +if.else: ; preds = %entry + store i32 1, i32* %retval, align 4, !dbg !31 + br label %return, !dbg !31 + +return: ; preds = %if.else, %if.then + %2 = load i32, i32* %retval, align 4, !dbg !32 + ret i32 %2, !dbg !32 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +; Function Attrs: noinline norecurse optnone uwtable +define dso_local i32 @main() #2 !dbg !33 { +entry: + %retval = alloca i32, align 4 + %f = alloca %class.myClass, align 4 + store i32 0, i32* %retval, align 4 + call void @llvm.dbg.declare(metadata %class.myClass* %f, metadata !36, metadata !DIExpression()), !dbg !37 + call void @_ZN7myClassC2Eii(%class.myClass* %f, i32 3, i32 5), !dbg !37 + ret i32 0, !dbg !38 +} + +; Function Attrs: noinline nounwind optnone uwtable +define linkonce_odr dso_local void @_ZN7myClassC2Eii(%class.myClass* %this, i32 %a, i32 %b) unnamed_addr #0 comdat align 2 !dbg !39 { +entry: + %this.addr = alloca %class.myClass*, align 8 + %a.addr = alloca i32, align 4 + %b.addr = alloca i32, align 4 + store %class.myClass* %this, %class.myClass** %this.addr, align 8 + call void @llvm.dbg.declare(metadata %class.myClass** %this.addr, metadata !40, metadata !DIExpression()), !dbg !41 + store i32 %a, i32* %a.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !42, metadata !DIExpression()), !dbg !43 + store i32 %b, i32* %b.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !44, metadata !DIExpression()), !dbg !45 + %this1 = load %class.myClass*, %class.myClass** %this.addr, align 8 + %0 = load i32, i32* %a.addr, align 4, !dbg !46 + %low = getelementptr inbounds %class.myClass, %class.myClass* %this1, i32 0, i32 0, !dbg !48 + store i32 %0, i32* %low, align 4, !dbg !49 + %1 = load i32, i32* %b.addr, align 4, !dbg !50 + %high = getelemen
[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5
awpandey added a comment. I am considering this - Will commit this without C bindings - will give separate patch for C bindings and release notes (if necessary). - will give another patch for Go bindings and release notes (if necessary). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70111/new/ https://reviews.llvm.org/D70111 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.
awpandey updated this revision to Diff 230601. awpandey marked 3 inline comments as done. awpandey added a comment. This revision includes 1. Added check for return type it is attached to the exact node we're expecting it to. 2. Removed unnecessary strings and checks. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70524/new/ https://reviews.llvm.org/D70524 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h clang/test/CodeGenCXX/debug-info-auto-return.cpp llvm/test/DebugInfo/X86/debug-info-auto-return.ll Index: llvm/test/DebugInfo/X86/debug-info-auto-return.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-auto-return.ll @@ -0,0 +1,171 @@ +;RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;class myClass { +;int low, high; +; +; public: +; myClass(int a, int b) { +;low = a; +;high = b; +; } +;auto findMax(); +;}; +; +;auto myClass::findMax() { +;if (low > high) +;return 1; +; else +;return 1; +;} +;int main() { +;myClass f(3, 5); +; return 0; +;} + +; CHECK: .debug_info contents: + +; CHECK: DW_TAG_subprogram [7] * +; CHECK-NEXT: DW_AT_linkage_name [DW_FORM_strx1](indexed (0007) string = "_ZN7myClass7findMaxEv") +; CHECK: DW_AT_type [DW_FORM_ref4] {{.*}} "auto" +; CHECK-NEXT: DW_AT_declaration {{.*}} (true) + +; CHECK: DW_TAG_unspecified_type +; CHECK-NEXT: DW_AT_name [DW_FORM_strx1] {{.*}} "auto" + +; ModuleID = 'debug-info-auto-return.cpp' +source_filename = "debug-info-auto-return.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%class.myClass = type { i32, i32 } + +$_ZN7myClassC2Eii = comdat any + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @_ZN7myClass7findMaxEv(%class.myClass* %this) #0 align 2 !dbg !7 { +entry: + %retval = alloca i32, align 4 + %this.addr = alloca %class.myClass*, align 8 + store %class.myClass* %this, %class.myClass** %this.addr, align 8 + call void @llvm.dbg.declare(metadata %class.myClass** %this.addr, metadata !22, metadata !DIExpression()), !dbg !24 + %this1 = load %class.myClass*, %class.myClass** %this.addr, align 8 + %low = getelementptr inbounds %class.myClass, %class.myClass* %this1, i32 0, i32 0, !dbg !25 + %0 = load i32, i32* %low, align 4, !dbg !25 + %high = getelementptr inbounds %class.myClass, %class.myClass* %this1, i32 0, i32 1, !dbg !27 + %1 = load i32, i32* %high, align 4, !dbg !27 + %cmp = icmp sgt i32 %0, %1, !dbg !28 + br i1 %cmp, label %if.then, label %if.else, !dbg !29 + +if.then: ; preds = %entry + store i32 1, i32* %retval, align 4, !dbg !30 + br label %return, !dbg !30 + +if.else: ; preds = %entry + store i32 1, i32* %retval, align 4, !dbg !31 + br label %return, !dbg !31 + +return: ; preds = %if.else, %if.then + %2 = load i32, i32* %retval, align 4, !dbg !32 + ret i32 %2, !dbg !32 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +; Function Attrs: noinline norecurse optnone uwtable +define dso_local i32 @main() #2 !dbg !33 { +entry: + %retval = alloca i32, align 4 + %f = alloca %class.myClass, align 4 + store i32 0, i32* %retval, align 4 + call void @llvm.dbg.declare(metadata %class.myClass* %f, metadata !36, metadata !DIExpression()), !dbg !37 + call void @_ZN7myClassC2Eii(%class.myClass* %f, i32 3, i32 5), !dbg !37 + ret i32 0, !dbg !38 +} + +; Function Attrs: noinline nounwind optnone uwtable +define linkonce_odr dso_local void @_ZN7myClassC2Eii(%class.myClass* %this, i32 %a, i32 %b) unnamed_addr #0 comdat align 2 !dbg !39 { +entry: + %this.addr = alloca %class.myClass*, align 8 + %a.addr = alloca i32, align 4 + %b.addr = alloca i32, align 4 + store %class.myClass* %this, %class.myClass** %this.addr, align 8 + call void @llvm.dbg.declare(metadata %class.myClass** %this.addr, metadata !40, metadata !DIExpression()), !dbg !41 + store i32 %a, i32* %a.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !42, metadata !DIExpression()), !dbg !43 + store i32 %b, i32* %b.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !44, metadata !DIExpression()), !dbg !45 + %this1 = load %class.myClass*, %class.myClass** %this.addr, align 8 + %0 = load i32, i32* %a.addr, align 4, !dbg !46 + %low = getelementptr inbounds %class.myClass, %class.myClass* %this1, i32 0, i32 0, !dbg !48 + store i32 %0, i32* %low, align 4, !dbg !49 + %1 = load i32, i32* %b.addr, align 4, !dbg !50 + %high = getelementptr inbounds %class.myClass, %class.myClass* %this1, i32 0, i32 1, !dbg !51 + st
[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.
awpandey marked 2 inline comments as done. awpandey added a comment. Thanks @aprantl for your suggestions. I have revised by patch based on that. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70524/new/ https://reviews.llvm.org/D70524 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5
awpandey updated this revision to Diff 231004. awpandey added a comment. Thanks @dblaikie. I have updated go and C bindings. I have also added the release note for why these APIs are changing. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70111/new/ https://reviews.llvm.org/D70111 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-template-align.cpp llvm/bindings/go/llvm/dibuilder.go llvm/docs/ReleaseNotes.rst llvm/include/llvm-c/DebugInfo.h llvm/include/llvm/IR/DIBuilder.h llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfo.cpp llvm/test/DebugInfo/X86/debug-info-template-align.ll llvm/tools/llvm-c-test/debuginfo.c Index: llvm/tools/llvm-c-test/debuginfo.c === --- llvm/tools/llvm-c-test/debuginfo.c +++ llvm/tools/llvm-c-test/debuginfo.c @@ -69,7 +69,7 @@ LLVMMetadataRef Int64Ty = LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0, LLVMDIFlagZero); LLVMMetadataRef Int64TypeDef = -LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File); + LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File, 0); LLVMMetadataRef GlobalVarValueExpr = LLVMDIBuilderCreateConstantValueExpression(DIB, 0); Index: llvm/test/DebugInfo/X86/debug-info-template-align.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-template-align.ll @@ -0,0 +1,63 @@ +; RUN: llc %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;typedef char __attribute__((__aligned__(64))) alchar; + +;int main(){ +;alchar newChar; +;} +; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c + +; CHECK: .debug_abbrev contents: + +; CHECK: [5] DW_TAG_typedef DW_CHILDREN_no +; CHECK: DW_AT_alignment DW_FORM_udata + +; CHECK: .debug_info contents: + +;CHECK: DW_TAG_typedef [5] +;CHECK: DW_AT_name {{.*}} "alchar" +;CHECK-NEXT: DW_AT_alignment [DW_FORM_udata] (64) + + +; ModuleID = '/dir/test.cpp' +source_filename = "/dir/test.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Function Attrs: noinline norecurse nounwind optnone uwtable +define dso_local i32 @main() #0 !dbg !7 { +entry: + %newChar = alloca i8, align 64 + call void @llvm.dbg.declare(metadata i8* %newChar, metadata !12, metadata !DIExpression()), !dbg !15 + ret i32 0, !dbg !16 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +attributes #0 = { noinline norecurse nounwind optnone uwtable } +attributes #1 = { nounwind readnone speculatable willreturn } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) +!1 = !DIFile(filename: "/dir/test.cpp", directory: "/dir/", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 5} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{!"clang version 10.0.0 "} +!7 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 12, type: !9, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) +!8 = !DIFile(filename: "test.cpp", directory: "/dir", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab") +!9 = !DISubroutineType(types: !10) +!10 = !{!11} +!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!12 = !DILocalVariable(name: "newChar", scope: !7, file: !8, line: 13, type: !13) +!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "alchar", file: !8, line: 10, baseType: !14, align: 512) +!14 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!15 = !DILocation(line: 13, column: 10, scope: !7) +!16 = !DILocation(line: 14, column: 1, scope: !7) Index: llvm/lib/IR/DebugInfo.cpp === --- llvm/lib/IR/DebugInfo.cpp +++ llvm/lib/IR/DebugInfo.cpp @@ -1108,11 +1108,10 @@ LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, - LLVMMetadataRef Scope) { + LLVMMetadataRef Scope, uint32_t AlignInBits) { return wrap(unwrap(Builder)->createTypedef( - unwrapDI(Type), {Name, NameLen}, - unwrapDI(File), LineNo, - unwrapDI(Scope))); + unwrapDI(Type), {Name, NameLen}, unwrapDI(File), LineNo, + unwrapDI(Scope), AlignInBits
[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.
awpandey updated this revision to Diff 231208. awpandey marked 5 inline comments as done. awpandey added a comment. Hi @aprantl and @dblaikie. Currently, there is no test case for the unspecified type, so I have added that in the regression test suite. Also, I have incorporated all of your suggestions. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70524/new/ https://reviews.llvm.org/D70524 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h clang/test/CodeGenCXX/debug-info-auto-return.cpp llvm/test/DebugInfo/X86/debug-info-auto-return.ll Index: llvm/test/DebugInfo/X86/debug-info-auto-return.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-auto-return.ll @@ -0,0 +1,171 @@ +;RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;class myClass { +;int low, high; +; +; public: +; myClass(int a, int b) { +;low = a; +;high = b; +; } +;auto findMax(); +;}; +; +;auto myClass::findMax() { +;if (low > high) +;return 1; +; else +;return 1; +;} +;int main() { +;myClass f(3, 5); +; return 0; +;} + +; CHECK: .debug_info contents: + +; CHECK: DW_TAG_subprogram [7] * +; CHECK-NEXT: DW_AT_linkage_name {{.*}} string = "_ZN7myClass7findMaxEv") +; CHECK: DW_AT_type [DW_FORM_ref4] {{.*}} "auto" +; CHECK-NEXT: DW_AT_declaration {{.*}} (true) + +; CHECK: DW_TAG_unspecified_type +; CHECK-NEXT: DW_AT_name [DW_FORM_strx1] {{.*}} "auto" + +; ModuleID = 'debug-info-auto-return.cpp' +source_filename = "debug-info-auto-return.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%class.myClass = type { i32, i32 } + +$_ZN7myClassC2Eii = comdat any + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @_ZN7myClass7findMaxEv(%class.myClass* %this) #0 align 2 !dbg !7 { +entry: + %retval = alloca i32, align 4 + %this.addr = alloca %class.myClass*, align 8 + store %class.myClass* %this, %class.myClass** %this.addr, align 8 + call void @llvm.dbg.declare(metadata %class.myClass** %this.addr, metadata !22, metadata !DIExpression()), !dbg !24 + %this1 = load %class.myClass*, %class.myClass** %this.addr, align 8 + %low = getelementptr inbounds %class.myClass, %class.myClass* %this1, i32 0, i32 0, !dbg !25 + %0 = load i32, i32* %low, align 4, !dbg !25 + %high = getelementptr inbounds %class.myClass, %class.myClass* %this1, i32 0, i32 1, !dbg !27 + %1 = load i32, i32* %high, align 4, !dbg !27 + %cmp = icmp sgt i32 %0, %1, !dbg !28 + br i1 %cmp, label %if.then, label %if.else, !dbg !29 + +if.then: ; preds = %entry + store i32 1, i32* %retval, align 4, !dbg !30 + br label %return, !dbg !30 + +if.else: ; preds = %entry + store i32 1, i32* %retval, align 4, !dbg !31 + br label %return, !dbg !31 + +return: ; preds = %if.else, %if.then + %2 = load i32, i32* %retval, align 4, !dbg !32 + ret i32 %2, !dbg !32 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +; Function Attrs: noinline norecurse optnone uwtable +define dso_local i32 @main() #2 !dbg !33 { +entry: + %retval = alloca i32, align 4 + %f = alloca %class.myClass, align 4 + store i32 0, i32* %retval, align 4 + call void @llvm.dbg.declare(metadata %class.myClass* %f, metadata !36, metadata !DIExpression()), !dbg !37 + call void @_ZN7myClassC2Eii(%class.myClass* %f, i32 3, i32 5), !dbg !37 + ret i32 0, !dbg !38 +} + +; Function Attrs: noinline nounwind optnone uwtable +define linkonce_odr dso_local void @_ZN7myClassC2Eii(%class.myClass* %this, i32 %a, i32 %b) unnamed_addr #0 comdat align 2 !dbg !39 { +entry: + %this.addr = alloca %class.myClass*, align 8 + %a.addr = alloca i32, align 4 + %b.addr = alloca i32, align 4 + store %class.myClass* %this, %class.myClass** %this.addr, align 8 + call void @llvm.dbg.declare(metadata %class.myClass** %this.addr, metadata !40, metadata !DIExpression()), !dbg !41 + store i32 %a, i32* %a.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !42, metadata !DIExpression()), !dbg !43 + store i32 %b, i32* %b.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !44, metadata !DIExpression()), !dbg !45 + %this1 = load %class.myClass*, %class.myClass** %this.addr, align 8 + %0 = load i32, i32* %a.addr, align 4, !dbg !46 + %low = getelementptr inbounds %class.myClass, %class.myClass* %this1, i32 0, i32 0, !dbg !48 + store i32 %0, i32* %low, align 4, !dbg !49 + %1 = load i32, i32* %b.addr, align 4, !dbg !50 + %high = getelementptr inbounds %class.myClass, %class.myClass* %this1, i32 0, i32 1, !dbg !51 +
[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.
awpandey updated this revision to Diff 232281. awpandey marked 5 inline comments as done. awpandey added a comment. Hi @aprantl, I used variable as shown by you for showing links between the node. @dblaikie I have shortened the test case based on your suggestions. There were no test case for checking `unspecified_type(auto)` that is why I am will to add this. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70524/new/ https://reviews.llvm.org/D70524 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h clang/test/CodeGenCXX/debug-info-auto-return.cpp llvm/test/DebugInfo/X86/debug-info-auto-return.ll Index: llvm/test/DebugInfo/X86/debug-info-auto-return.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-auto-return.ll @@ -0,0 +1,66 @@ +;RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;struct myClass { +; auto findMax(); +;}; + +;auto myClass::findMax() { +;} + +; CHECK: .debug_info contents: + +; CHECK: DW_TAG_subprogram [3] * +; CHECK-NEXT: DW_AT_linkage_name {{.*}} string = "_ZN7myClass7findMaxEv") +; CHECK: DW_AT_type [DW_FORM_ref4] {{.*}} "auto" +; CHECK-NEXT: DW_AT_declaration {{.*}} (true) + +; CHECK: DW_TAG_unspecified_type +; CHECK-NEXT: DW_AT_name [DW_FORM_strx1] {{.*}} "auto" + +; ModuleID = 'debug-info-auto-return.cpp' +source_filename = "debug-info-auto-return.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%struct.myClass = type { i8 } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @_ZN7myClass7findMaxEv(%struct.myClass* %this) #0 align 2 !dbg !7 { +entry: + %this.addr = alloca %struct.myClass*, align 8 + store %struct.myClass* %this, %struct.myClass** %this.addr, align 8 + call void @llvm.dbg.declare(metadata %struct.myClass** %this.addr, metadata !14, metadata !DIExpression()), !dbg !16 + %this1 = load %struct.myClass*, %struct.myClass** %this.addr, align 8 + ret void, !dbg !17 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone speculatable willreturn } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0 (https://github.com/llvm/llvm-project.git 31848e839e485b9a295a2aa86fc7bac3e8403a94)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) +!1 = !DIFile(filename: "debug-info-auto-return.cpp", directory: "/home/awpandey/tools/upstream/llvm-project/clang/test/CodeGenCXX", checksumkind: CSK_MD5, checksum: "00e6551e106a871d393b61752d94cc0c") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 5} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git 31848e839e485b9a295a2aa86fc7bac3e8403a94)"} +!7 = distinct !DISubprogram(name: "findMax", linkageName: "_ZN7myClass7findMaxEv", scope: !8, file: !1, line: 16, type: !9, scopeLine: 16, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !13, retainedNodes: !2) +!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "myClass", file: !1, line: 12, size: 8, flags: DIFlagTypePassByValue, elements: !2, identifier: "_ZTS7myClass") +!9 = !DISubroutineType(types: !10) +!10 = !{!11, !12} +!11 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "auto") +!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) +!13 = !DISubprogram(name: "findMax", linkageName: "_ZN7myClass7findMaxEv", scope: !8, file: !1, line: 13, type: !9, scopeLine: 13, flags: DIFlagPrototyped, spFlags: 0) +!14 = !DILocalVariable(name: "this", arg: 1, scope: !7, type: !15, flags: DIFlagArtificial | DIFlagObjectPointer) +!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64) +!16 = !DILocation(line: 0, scope: !7) +!17 = !DILocation(line: 17, column: 1, scope: !7) Index: clang/test/CodeGenCXX/debug-info-auto-return.cpp === --- /dev/null +++ clang/test/CodeGenCXX/debug-info-auto-return.cpp @@ -0,0 +1,18 @@ +// Test for debug info fo
[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.
awpandey marked an inline comment as done. awpandey added a comment. > It looks to me like there are a few tests for unspecified_type already: > > $ grep -r unspecified_type llvm/test > llvm/test/Assembler/debug-info.ll:; CHECK-NEXT: !7 = !DIBasicType(tag: > DW_TAG_unspecified_type, name: "decltype(nullptr)") > llvm/test/Assembler/debug-info.ll:!8 = !DIBasicType(tag: > DW_TAG_unspecified_type, name: "decltype(nullptr)") ... @dblaikie, are you suggesting me to modify some of these existing test cases to include `auto return` functionality as well. Comment at: clang/test/CodeGenCXX/debug-info-auto-return.cpp:9 + +// CHECK: ![[t:[0-9]+]] = !DISubroutineType(types: ![[t1:[0-9]+]]) +// CHECK-NEXT: ![[t1:[0-9]+]] = !{![[t2:[0-9]+]], {{.*}} @aprantl I have tried to use variable as shown by you for showing links between the associated nodes. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70524/new/ https://reviews.llvm.org/D70524 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.
awpandey updated this revision to Diff 233289. awpandey added a comment. @dblaikie . I have removed the redundant test case. What else should I do in this patch? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70524/new/ https://reviews.llvm.org/D70524 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h clang/test/CodeGenCXX/debug-info-auto-return.cpp Index: clang/test/CodeGenCXX/debug-info-auto-return.cpp === --- /dev/null +++ clang/test/CodeGenCXX/debug-info-auto-return.cpp @@ -0,0 +1,18 @@ +// Test for debug info for C++11 auto return member functions +// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -triple x86_64-linux-gnu %s -o - \ +// RUN: -O0 -disable-llvm-passes \ +// RUN: -debug-info-kind=standalone \ +// RUN: | FileCheck %s + +// CHECK: !DISubprogram(name: "findMax",{{.*}}, type: ![[t:[0-9]+]],{{.*}} + +// CHECK: ![[t:[0-9]+]] = !DISubroutineType(types: ![[t1:[0-9]+]]) +// CHECK-NEXT: ![[t1:[0-9]+]] = !{![[t2:[0-9]+]], {{.*}} +// CHECK-NEXT: ![[t2:[0-9]+]] = !DIBasicType(tag: DW_TAG_unspecified_type, name: "auto") + +struct myClass { + auto findMax(); +}; + +auto myClass::findMax() { +} Index: clang/lib/CodeGen/CGDebugInfo.h === --- clang/lib/CodeGen/CGDebugInfo.h +++ clang/lib/CodeGen/CGDebugInfo.h @@ -165,6 +165,7 @@ /// ivars and property accessors. llvm::DIType *CreateType(const BuiltinType *Ty); llvm::DIType *CreateType(const ComplexType *Ty); + llvm::DIType *CreateType(const AutoType *Ty); llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg); llvm::DIType *CreateType(const TypedefType *Ty, llvm::DIFile *Fg); llvm::DIType *CreateType(const TemplateSpecializationType *Ty, Index: clang/lib/CodeGen/CGDebugInfo.cpp === --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -810,6 +810,10 @@ return DBuilder.createBasicType(BTName, Size, Encoding); } +llvm::DIType *CGDebugInfo::CreateType(const AutoType *Ty) { + return DBuilder.createUnspecifiedType("auto"); +} + llvm::DIType *CGDebugInfo::CreateType(const ComplexType *Ty) { // Bit size and offset of the type. llvm::dwarf::TypeKind Encoding = llvm::dwarf::DW_ATE_complex_float; @@ -2860,7 +2864,8 @@ return DBuilder.createTempMacroFile(Parent, Line, FName); } -static QualType UnwrapTypeForDebugInfo(QualType T, const ASTContext &C) { +static QualType UnwrapTypeForDebugInfo(QualType T, const ASTContext &C, + int dwarfVersion) { Qualifiers Quals; do { Qualifiers InnerQuals = T.getLocalQualifiers(); @@ -2907,6 +2912,10 @@ T = cast(T)->getReplacementType(); break; case Type::Auto: + if (dwarfVersion >= 5) { +return C.getQualifiedType(T.getTypePtr(), Quals); + } + LLVM_FALLTHROUGH; case Type::DeducedTemplateSpecialization: { QualType DT = cast(T)->getDeducedType(); assert(!DT.isNull() && "Undeduced types shouldn't reach here."); @@ -2928,7 +2937,8 @@ llvm::DIType *CGDebugInfo::getTypeOrNull(QualType Ty) { // Unwrap the type as needed for debug information. - Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext()); + Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext(), + CGM.getCodeGenOpts().DwarfVersion); auto It = TypeCache.find(Ty.getAsOpaquePtr()); if (It != TypeCache.end()) { @@ -2969,7 +2979,8 @@ }); // Unwrap the type as needed for debug information. - Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext()); + Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext(), + CGM.getCodeGenOpts().DwarfVersion); if (auto *T = getTypeOrNull(Ty)) return T; @@ -3083,6 +3094,9 @@ return CreateType(cast(Ty), Unit); case Type::Auto: +if (CGM.getCodeGenOpts().DwarfVersion >= 5) + return CreateType(cast(Ty)); + case Type::Attributed: case Type::Adjusted: case Type::Decayed: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates
awpandey updated this revision to Diff 241984. awpandey marked 2 inline comments as done. awpandey added a comment. Thanks, @aprantl, and @dblaikie. I have added two new test cases as per your suggestions. I have to update // dityperefs-3.8.ll// and //dityperefs-3.8.ll.bc// because they are no longer compatible with this patch. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73462/new/ https://reviews.llvm.org/D73462 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-template-parameter.cpp llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/test/Assembler/DITemplateParameter.ll llvm/test/Bitcode/DITemplateParameter-5.0.ll llvm/test/Bitcode/DITemplateParameter-5.0.ll.bc llvm/test/Bitcode/dityperefs-3.8.ll llvm/test/Bitcode/dityperefs-3.8.ll.bc llvm/test/DebugInfo/X86/debug-info-template-parameter.ll llvm/unittests/IR/MetadataTest.cpp Index: llvm/unittests/IR/MetadataTest.cpp === --- llvm/unittests/IR/MetadataTest.cpp +++ llvm/unittests/IR/MetadataTest.cpp @@ -2077,16 +2077,16 @@ StringRef Name = "template"; DIType *Type = getBasicType("basic"); - auto *N = DITemplateTypeParameter::get(Context, Name, Type); + auto *N = DITemplateTypeParameter::get(Context, Name, Type, false); EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); - EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type)); + EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type, false)); - EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type)); - EXPECT_NE(N, -DITemplateTypeParameter::get(Context, Name, getBasicType("other"))); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type, false)); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name, +getBasicType("other"), false)); TempDITemplateTypeParameter Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); @@ -2100,21 +2100,23 @@ DIType *Type = getBasicType("basic"); Metadata *Value = getConstantAsMetadata(); - auto *N = DITemplateValueParameter::get(Context, Tag, Name, Type, Value); + auto *N = + DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value); EXPECT_EQ(Tag, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); EXPECT_EQ(Value, N->getValue()); - EXPECT_EQ(N, DITemplateValueParameter::get(Context, Tag, Name, Type, Value)); + EXPECT_EQ( + N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value)); EXPECT_NE(N, DITemplateValueParameter::get( Context, dwarf::DW_TAG_GNU_template_template_param, Name, - Type, Value)); - EXPECT_NE(N, -DITemplateValueParameter::get(Context, Tag, "other", Type, Value)); - EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, - getBasicType("other"), Value)); - EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, + Type, false, Value)); + EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, "other", Type, false, + Value)); + EXPECT_NE(N, DITemplateValueParameter::get( + Context, Tag, Name, getBasicType("other"), false, Value)); + EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, getConstantAsMetadata())); TempDITemplateValueParameter Temp = N->clone(); Index: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-template-parameter.ll @@ -0,0 +1,90 @@ +; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;template +;class foo { +;}; +; +;int main() { +; foo f1; +; foo<> f2; +; return 0; +;} + +; $ clang++ -O0 -gdwarf-5 -S -gdwarf-5 test.cpp + +; CHECK: .debug_abbrev contents: +; CHECK: DW_AT_default_value DW_FORM_flag_present + +; CHECK: debug_info contents: + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK-NOT: DW_AT_default_value +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "i" +; CHECK-NOT: DW_AT_default_value + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "char" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK_NEXT: DW_AT_default_value {{.*}}
[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates
awpandey updated this revision to Diff 242250. awpandey added a comment. Hi @dblaikie, I removed the condition and put false as the third argument of PrintBool. I have also removed the updated bitcode file. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73462/new/ https://reviews.llvm.org/D73462 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-template-parameter.cpp llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/test/Assembler/DITemplateParameter.ll llvm/test/Bitcode/DITemplateParameter-5.0.ll llvm/test/Bitcode/DITemplateParameter-5.0.ll.bc llvm/test/DebugInfo/X86/debug-info-template-parameter.ll llvm/unittests/IR/MetadataTest.cpp Index: llvm/unittests/IR/MetadataTest.cpp === --- llvm/unittests/IR/MetadataTest.cpp +++ llvm/unittests/IR/MetadataTest.cpp @@ -2077,16 +2077,16 @@ StringRef Name = "template"; DIType *Type = getBasicType("basic"); - auto *N = DITemplateTypeParameter::get(Context, Name, Type); + auto *N = DITemplateTypeParameter::get(Context, Name, Type, false); EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); - EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type)); + EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type, false)); - EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type)); - EXPECT_NE(N, -DITemplateTypeParameter::get(Context, Name, getBasicType("other"))); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type, false)); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name, +getBasicType("other"), false)); TempDITemplateTypeParameter Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); @@ -2100,21 +2100,23 @@ DIType *Type = getBasicType("basic"); Metadata *Value = getConstantAsMetadata(); - auto *N = DITemplateValueParameter::get(Context, Tag, Name, Type, Value); + auto *N = + DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value); EXPECT_EQ(Tag, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); EXPECT_EQ(Value, N->getValue()); - EXPECT_EQ(N, DITemplateValueParameter::get(Context, Tag, Name, Type, Value)); + EXPECT_EQ( + N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value)); EXPECT_NE(N, DITemplateValueParameter::get( Context, dwarf::DW_TAG_GNU_template_template_param, Name, - Type, Value)); - EXPECT_NE(N, -DITemplateValueParameter::get(Context, Tag, "other", Type, Value)); - EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, - getBasicType("other"), Value)); - EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, + Type, false, Value)); + EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, "other", Type, false, + Value)); + EXPECT_NE(N, DITemplateValueParameter::get( + Context, Tag, Name, getBasicType("other"), false, Value)); + EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, getConstantAsMetadata())); TempDITemplateValueParameter Temp = N->clone(); Index: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-template-parameter.ll @@ -0,0 +1,90 @@ +; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;template +;class foo { +;}; +; +;int main() { +; foo f1; +; foo<> f2; +; return 0; +;} + +; $ clang++ -O0 -gdwarf-5 -S -gdwarf-5 test.cpp + +; CHECK: .debug_abbrev contents: +; CHECK: DW_AT_default_value DW_FORM_flag_present + +; CHECK: debug_info contents: + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK-NOT: DW_AT_default_value +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "i" +; CHECK-NOT: DW_AT_default_value + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "char" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK_NEXT: DW_AT_default_value {{.*}} true +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "i" +; CHECK_NEXT: DW_AT_default_value {{.*}} true + +; ModuleID = '/dir/test.cpp' +source_filename = "test.cpp" +target datalayou
[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates
awpandey updated this revision to Diff 242514. awpandey marked 3 inline comments as done. awpandey added a comment. @dblaikie, I have updated the test cases. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73462/new/ https://reviews.llvm.org/D73462 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-template-parameter.cpp llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/test/Assembler/DITemplateParameter.ll llvm/test/Bitcode/DITemplateParameter-5.0.ll llvm/test/Bitcode/DITemplateParameter-5.0.ll.bc llvm/test/DebugInfo/X86/debug-info-template-parameter.ll llvm/unittests/IR/MetadataTest.cpp Index: llvm/unittests/IR/MetadataTest.cpp === --- llvm/unittests/IR/MetadataTest.cpp +++ llvm/unittests/IR/MetadataTest.cpp @@ -2077,16 +2077,16 @@ StringRef Name = "template"; DIType *Type = getBasicType("basic"); - auto *N = DITemplateTypeParameter::get(Context, Name, Type); + auto *N = DITemplateTypeParameter::get(Context, Name, Type, false); EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); - EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type)); + EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type, false)); - EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type)); - EXPECT_NE(N, -DITemplateTypeParameter::get(Context, Name, getBasicType("other"))); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type, false)); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name, +getBasicType("other"), false)); TempDITemplateTypeParameter Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); @@ -2100,21 +2100,23 @@ DIType *Type = getBasicType("basic"); Metadata *Value = getConstantAsMetadata(); - auto *N = DITemplateValueParameter::get(Context, Tag, Name, Type, Value); + auto *N = + DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value); EXPECT_EQ(Tag, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); EXPECT_EQ(Value, N->getValue()); - EXPECT_EQ(N, DITemplateValueParameter::get(Context, Tag, Name, Type, Value)); + EXPECT_EQ( + N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value)); EXPECT_NE(N, DITemplateValueParameter::get( Context, dwarf::DW_TAG_GNU_template_template_param, Name, - Type, Value)); - EXPECT_NE(N, -DITemplateValueParameter::get(Context, Tag, "other", Type, Value)); - EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, - getBasicType("other"), Value)); - EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, + Type, false, Value)); + EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, "other", Type, false, + Value)); + EXPECT_NE(N, DITemplateValueParameter::get( + Context, Tag, Name, getBasicType("other"), false, Value)); + EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, getConstantAsMetadata())); TempDITemplateValueParameter Temp = N->clone(); Index: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-template-parameter.ll @@ -0,0 +1,90 @@ +; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;template +;class foo { +;}; +; +;int main() { +; foo f1; +; foo<> f2; +; return 0; +;} + +; $ clang++ -O0 -gdwarf-5 -S -gdwarf-5 test.cpp + +; CHECK: .debug_abbrev contents: +; CHECK: DW_AT_default_value DW_FORM_flag_present + +; CHECK: debug_info contents: + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK-NOT: DW_AT_default_value +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "i" +; CHECK-NOT: DW_AT_default_value + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "char" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK_NEXT: DW_AT_default_value {{.*}} true +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "i" +; CHECK_NEXT: DW_AT_default_value {{.*}} true + +; ModuleID = '/dir/test.cpp' +source_filename = "test.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64
[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates
awpandey added a comment. Thanks @dblaikie for all of your suggestions. I will commit this in 3 patches after getting the green signal from @aprantl. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73462/new/ https://reviews.llvm.org/D73462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D73261: [dwarf5] Support DebugInfo for constexpr for C++ variables and functions
awpandey updated this revision to Diff 243509. awpandey added a comment. Herald added a subscriber: ormris. @probinson I have reimplemented the feature by using DIFlags. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73261/new/ https://reviews.llvm.org/D73261 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/constExpr.cpp llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoFlags.def llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfo.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/test/DebugInfo/X86/constExpr.ll Index: llvm/test/DebugInfo/X86/constExpr.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/constExpr.ll @@ -0,0 +1,118 @@ +; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; CHECK: .debug_info contents: + +; CHECK: DW_TAG_variable +; CHECK-NEXT: DW_AT_name {{.*}} "bar" +; CHECK: DW_AT_const_expr {{.*}} (true) + +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_const_expr {{.*}} (true) +; CHECK: DW_AT_linkage_name {{.*}} "_Z3funi" + + +; C++ source to regenerate: + +;constexpr int bar = 10; +; +;constexpr int fun(int x) { return x * 2; } +; +;int main(int argc, char **argv) { +; int foo = bar; +; constexpr int baz = 10; +; int constVal = fun(10); +; return 0; +;} + +; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c + +; ModuleID = '/dir/test.cpp' +source_filename = "/dir/test.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +$_Z3funi = comdat any +; Function Attrs: noinline norecurse optnone uwtable + +define dso_local i32 @main(i32 %argc, i8** %argv) #0 !dbg !13 { +entry: + %retval = alloca i32, align 4 + %argc.addr = alloca i32, align 4 + %argv.addr = alloca i8**, align 8 + %foo = alloca i32, align 4 + %baz = alloca i32, align 4 + %constVal = alloca i32, align 4 + store i32 0, i32* %retval, align 4 + store i32 %argc, i32* %argc.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %argc.addr, metadata !19, metadata !DIExpression()), !dbg !20 + store i8** %argv, i8*** %argv.addr, align 8 + call void @llvm.dbg.declare(metadata i8*** %argv.addr, metadata !21, metadata !DIExpression()), !dbg !22 + call void @llvm.dbg.declare(metadata i32* %foo, metadata !23, metadata !DIExpression()), !dbg !24 + store i32 10, i32* %foo, align 4, !dbg !24 + call void @llvm.dbg.declare(metadata i32* %baz, metadata !25, metadata !DIExpression()), !dbg !26 + store i32 10, i32* %baz, align 4, !dbg !26 + call void @llvm.dbg.declare(metadata i32* %constVal, metadata !27, metadata !DIExpression()), !dbg !28 + %call = call i32 @_Z3funi(i32 10), !dbg !29 + store i32 %call, i32* %constVal, align 4, !dbg !28 + ret i32 0, !dbg !30 +} +; Function Attrs: nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 +; Function Attrs: noinline nounwind optnone uwtable +define linkonce_odr dso_local i32 @_Z3funi(i32 %x) #2 comdat !dbg !31 { +entry: + %x.addr = alloca i32, align 4 + store i32 %x, i32* %x.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !34, metadata !DIExpression()), !dbg !35 + %0 = load i32, i32* %x.addr, align 4, !dbg !36 + %mul = mul nsw i32 %0, 2, !dbg !37 + ret i32 %mul, !dbg !38 +} + +attributes #0 = { noinline norecurse optnone uwtable } +attributes #1 = { nounwind readnone speculatable willreturn } +attributes #2 = { noinline nounwind optnone uwtable } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!9, !10, !11} +!llvm.ident = !{!12} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, splitDebugInlining: false, nameTableKind: None) +!1 = !DIFile(filename: "/dir/test.cpp", directory: "/dir/", checksumkind: CSK_MD5, checksum: "b973c468913ba52f145c9b21705fe0e0") +!2 = !{} +!3 = !{!4} +!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression(DW_OP_constu, 10, DW_OP_stack_value)) +!5 = distinct !DIGlobalVariable(name: "bar", scope: !0, file: !6, line: 13, type: !7, isLocal: true, isDefinition: true, flags: DIFlagConstExpr) +!6 = !DIFile(filename: "/dir/test.cpp", directory: "/dir", checksumkind: CSK_MD5, checksum: "b973c468913ba52f145c9b21705fe0e0") +!7 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8) +!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!9 = !{i32 7, !"Dwarf Version", i32 5} +!10 = !{i32 2, !"Debug Info Version", i32 3} +!11 = !{i32 1, !"wchar_size", i32 4} +!12 = !{!"clang version 11.0.0 "} +!13 = distinct !DISubprogram(name: "main", scope: !6, file: !6, line:
[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates
awpandey added a comment. Hi @aprantl , can you please inform me what extra changes should I make in this patch. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73462/new/ https://reviews.llvm.org/D73462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates
awpandey updated this revision to Diff 244571. awpandey marked 2 inline comments as done. awpandey added a comment. Hi @aprantl, I have added a test that two DITemplateTypeParameter only differ in the isDefault parameter are not equal. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73462/new/ https://reviews.llvm.org/D73462 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-template-parameter.cpp llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/test/Assembler/DITemplateParameter.ll llvm/test/Bitcode/DITemplateParameter-5.0.ll llvm/test/Bitcode/DITemplateParameter-5.0.ll.bc llvm/test/DebugInfo/X86/debug-info-template-parameter.ll llvm/unittests/IR/MetadataTest.cpp Index: llvm/unittests/IR/MetadataTest.cpp === --- llvm/unittests/IR/MetadataTest.cpp +++ llvm/unittests/IR/MetadataTest.cpp @@ -2077,16 +2077,17 @@ StringRef Name = "template"; DIType *Type = getBasicType("basic"); - auto *N = DITemplateTypeParameter::get(Context, Name, Type); + auto *N = DITemplateTypeParameter::get(Context, Name, Type, false); EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); - EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type)); + EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type, false)); - EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type)); - EXPECT_NE(N, -DITemplateTypeParameter::get(Context, Name, getBasicType("other"))); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type, false)); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name, +getBasicType("other"), false)); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name, Type, true)); TempDITemplateTypeParameter Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); @@ -2100,22 +2101,26 @@ DIType *Type = getBasicType("basic"); Metadata *Value = getConstantAsMetadata(); - auto *N = DITemplateValueParameter::get(Context, Tag, Name, Type, Value); + auto *N = + DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value); EXPECT_EQ(Tag, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); EXPECT_EQ(Value, N->getValue()); - EXPECT_EQ(N, DITemplateValueParameter::get(Context, Tag, Name, Type, Value)); + EXPECT_EQ( + N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value)); EXPECT_NE(N, DITemplateValueParameter::get( Context, dwarf::DW_TAG_GNU_template_template_param, Name, - Type, Value)); - EXPECT_NE(N, -DITemplateValueParameter::get(Context, Tag, "other", Type, Value)); - EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, - getBasicType("other"), Value)); - EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, + Type, false, Value)); + EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, "other", Type, false, + Value)); + EXPECT_NE(N, DITemplateValueParameter::get( + Context, Tag, Name, getBasicType("other"), false, Value)); + EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, getConstantAsMetadata())); + EXPECT_NE( + N, DITemplateValueParameter::get(Context, Tag, Name, Type, true, Value)); TempDITemplateValueParameter Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); Index: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-template-parameter.ll @@ -0,0 +1,90 @@ +; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;template +;class foo { +;}; +; +;int main() { +; foo f1; +; foo<> f2; +; return 0; +;} + +; $ clang++ -O0 -gdwarf-5 -S -gdwarf-5 test.cpp + +; CHECK: .debug_abbrev contents: +; CHECK: DW_AT_default_value DW_FORM_flag_present + +; CHECK: debug_info contents: + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK-NOT: DW_AT_default_value +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "i" +; CHECK-NOT: DW_AT_default_value + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "char" +; CHECK-NEXT: DW_AT_
[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates
awpandey added a comment. Hi @aprantl, I have included all of your suggestions. Can I merge this? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73462/new/ https://reviews.llvm.org/D73462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D73261: [dwarf5] Support DebugInfo for constexpr for C++ variables and functions
awpandey created this revision. awpandey added reviewers: dblaikie, aprantl, probinson, jini.susan.george. awpandey added projects: debug-info, LLVM, clang. Herald added subscribers: llvm-commits, cfe-commits, hiraditya. This patch adds //dw_at_const_expr// flag for the constant variable or functions in C++ Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D73261 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/constExpr.cpp clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfo.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/unittests/CodeGen/MachineInstrTest.cpp llvm/unittests/IR/IRBuilderTest.cpp llvm/unittests/IR/MetadataTest.cpp Index: llvm/unittests/IR/MetadataTest.cpp === --- llvm/unittests/IR/MetadataTest.cpp +++ llvm/unittests/IR/MetadataTest.cpp @@ -86,7 +86,7 @@ DISubprogram *getSubprogram() { return DISubprogram::getDistinct( Context, nullptr, "", "", nullptr, 0, nullptr, 0, nullptr, 0, 0, -DINode::FlagZero, DISubprogram::SPFlagZero, nullptr); +DINode::FlagZero, DISubprogram::SPFlagZero, false, nullptr); } DIFile *getFile() { return DIFile::getDistinct(Context, "file.c", "/path/to/dir"); @@ -927,12 +927,12 @@ { // Different function, same inlined-at. auto *F = getFile(); -auto *SP1 = DISubprogram::getDistinct(Context, F, "a", "a", F, 0, nullptr, - 0, nullptr, 0, 0, DINode::FlagZero, - DISubprogram::SPFlagZero, nullptr); -auto *SP2 = DISubprogram::getDistinct(Context, F, "b", "b", F, 0, nullptr, - 0, nullptr, 0, 0, DINode::FlagZero, - DISubprogram::SPFlagZero, nullptr); +auto *SP1 = DISubprogram::getDistinct( +Context, F, "a", "a", F, 0, nullptr, 0, nullptr, 0, 0, DINode::FlagZero, +DISubprogram::SPFlagZero, false, nullptr); +auto *SP2 = DISubprogram::getDistinct( +Context, F, "b", "b", F, 0, nullptr, 0, nullptr, 0, 0, DINode::FlagZero, +DISubprogram::SPFlagZero, false, nullptr); auto *I = DILocation::get(Context, 2, 7, N); auto *A = DILocation::get(Context, 1, 6, SP1, I); @@ -1168,7 +1168,7 @@ DIType *Type = getDerivedType(); DINode::DIFlags Flags = static_cast(7); auto *VlaExpr = DILocalVariable::get(Context, Scope, "vla_expr", File, 8, - Type, 2, Flags, 8); + Type, 2, Flags, 8, false); auto *N = DISubrange::get(Context, VlaExpr, 0); auto Count = N->getCount(); @@ -1822,7 +1822,7 @@ auto *N = DISubprogram::get( Context, Scope, Name, LinkageName, File, Line, Type, ScopeLine, - ContainingType, VirtualIndex, ThisAdjustment, Flags, SPFlags, Unit, + ContainingType, VirtualIndex, ThisAdjustment, Flags, SPFlags, false, Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes); EXPECT_EQ(dwarf::DW_TAG_subprogram, N->getTag()); @@ -1848,97 +1848,98 @@ EXPECT_EQ(ThrownTypes, N->getThrownTypes().get()); EXPECT_EQ(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line, Type, ScopeLine, ContainingType, VirtualIndex, - ThisAdjustment, Flags, SPFlags, Unit, + ThisAdjustment, Flags, SPFlags, false, Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes)); EXPECT_NE(N, DISubprogram::get(Context, getCompositeType(), Name, LinkageName, File, Line, Type, ScopeLine, ContainingType, VirtualIndex, ThisAdjustment, Flags, SPFlags, - Unit, TemplateParams, Declaration, + false, Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes)); EXPECT_NE(N, DISubprogram::get(Context, Scope, "other", LinkageName, File, Line, Type, ScopeLine, ContainingType, VirtualIndex, ThisAdjustment, Flags, SPFlags, - Unit, TemplateParams, Declaration, + false, Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes)); EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, "other", File, Line, Type, ScopeLine, ContainingType, VirtualIndex, -
[PATCH] D73261: [dwarf5] Support DebugInfo for constexpr for C++ variables and functions
awpandey updated this revision to Diff 240122. awpandey marked 29 inline comments as done. awpandey added a comment. Hi @probinson, I have changed the patch according to your comments. Is it necessary to use DIFlags? I am willing to do that but generally, it is not welcomed because we have a limited number of DIFlags and most of them are currently in use. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73261/new/ https://reviews.llvm.org/D73261 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/constExpr.cpp clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfo.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/test/DebugInfo/X86/constExpr.ll llvm/unittests/CodeGen/MachineInstrTest.cpp llvm/unittests/IR/IRBuilderTest.cpp llvm/unittests/IR/MetadataTest.cpp Index: llvm/unittests/IR/MetadataTest.cpp === --- llvm/unittests/IR/MetadataTest.cpp +++ llvm/unittests/IR/MetadataTest.cpp @@ -86,7 +86,7 @@ DISubprogram *getSubprogram() { return DISubprogram::getDistinct( Context, nullptr, "", "", nullptr, 0, nullptr, 0, nullptr, 0, 0, -DINode::FlagZero, DISubprogram::SPFlagZero, nullptr); +DINode::FlagZero, DISubprogram::SPFlagZero, false, nullptr); } DIFile *getFile() { return DIFile::getDistinct(Context, "file.c", "/path/to/dir"); @@ -927,12 +927,12 @@ { // Different function, same inlined-at. auto *F = getFile(); -auto *SP1 = DISubprogram::getDistinct(Context, F, "a", "a", F, 0, nullptr, - 0, nullptr, 0, 0, DINode::FlagZero, - DISubprogram::SPFlagZero, nullptr); -auto *SP2 = DISubprogram::getDistinct(Context, F, "b", "b", F, 0, nullptr, - 0, nullptr, 0, 0, DINode::FlagZero, - DISubprogram::SPFlagZero, nullptr); +auto *SP1 = DISubprogram::getDistinct( +Context, F, "a", "a", F, 0, nullptr, 0, nullptr, 0, 0, DINode::FlagZero, +DISubprogram::SPFlagZero, false, nullptr); +auto *SP2 = DISubprogram::getDistinct( +Context, F, "b", "b", F, 0, nullptr, 0, nullptr, 0, 0, DINode::FlagZero, +DISubprogram::SPFlagZero, false, nullptr); auto *I = DILocation::get(Context, 2, 7, N); auto *A = DILocation::get(Context, 1, 6, SP1, I); @@ -1168,7 +1168,7 @@ DIType *Type = getDerivedType(); DINode::DIFlags Flags = static_cast(7); auto *VlaExpr = DILocalVariable::get(Context, Scope, "vla_expr", File, 8, - Type, 2, Flags, 8); + Type, 2, Flags, 8, false); auto *N = DISubrange::get(Context, VlaExpr, 0); auto Count = N->getCount(); @@ -1822,7 +1822,7 @@ auto *N = DISubprogram::get( Context, Scope, Name, LinkageName, File, Line, Type, ScopeLine, - ContainingType, VirtualIndex, ThisAdjustment, Flags, SPFlags, Unit, + ContainingType, VirtualIndex, ThisAdjustment, Flags, SPFlags, false, Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes); EXPECT_EQ(dwarf::DW_TAG_subprogram, N->getTag()); @@ -1848,97 +1848,98 @@ EXPECT_EQ(ThrownTypes, N->getThrownTypes().get()); EXPECT_EQ(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line, Type, ScopeLine, ContainingType, VirtualIndex, - ThisAdjustment, Flags, SPFlags, Unit, + ThisAdjustment, Flags, SPFlags, false, Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes)); EXPECT_NE(N, DISubprogram::get(Context, getCompositeType(), Name, LinkageName, File, Line, Type, ScopeLine, ContainingType, VirtualIndex, ThisAdjustment, Flags, SPFlags, - Unit, TemplateParams, Declaration, + false, Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes)); EXPECT_NE(N, DISubprogram::get(Context, Scope, "other", LinkageName, File, Line, Type, ScopeLine, ContainingType, VirtualIndex, ThisAdjustment, Flags, SPFlags, - Unit, TemplateParams, Declaration, + false, Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes)); EXPECT_NE(N, DISubprogram::get(Context, Scope, Name
[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates
awpandey created this revision. awpandey added reviewers: probinson, aprantl, dblaikie. Herald added subscribers: llvm-commits, cfe-commits, hiraditya. Herald added projects: clang, LLVM. This patch provides support for //DW_AT_default_value// based on template parameter is default parameter or not. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D73462 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-template-parameter.cpp llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/test/DebugInfo/X86/debug-info-template-parameter.ll llvm/unittests/IR/MetadataTest.cpp Index: llvm/unittests/IR/MetadataTest.cpp === --- llvm/unittests/IR/MetadataTest.cpp +++ llvm/unittests/IR/MetadataTest.cpp @@ -2077,16 +2077,16 @@ StringRef Name = "template"; DIType *Type = getBasicType("basic"); - auto *N = DITemplateTypeParameter::get(Context, Name, Type); + auto *N = DITemplateTypeParameter::get(Context, Name, Type, false); EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); - EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type)); + EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type, false)); - EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type)); - EXPECT_NE(N, -DITemplateTypeParameter::get(Context, Name, getBasicType("other"))); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type, false)); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name, +getBasicType("other"), false)); TempDITemplateTypeParameter Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); Index: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-template-parameter.ll @@ -0,0 +1,106 @@ +; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;template +;class foo { +;}; +; +;int main() { +; foo f1; +; foo f2; +; foo<> f3; +; return 0; +;} + +; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c + +; CHECK: .debug_abbrev contents: +; CHECK: DW_AT_default_value DW_FORM_flag_present + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK-NOT: DW_AT_default_value +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "T1" +; CHECK-NEXT: DW_AT_default_value {{.*}} (true) + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "float" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK-NOT: DW_AT_default_value +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "T1" +; CHECK-NEXT: DW_AT_default_value {{.*}} (true) + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "char" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK-NEXT: DW_AT_default_value {{.*}} (true) +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "T1" +; CHECK-NEXT: DW_AT_default_value {{.*}} (true) +; ModuleID = '/dir/test.cpp' +source_filename = "/dir/test.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%class.foo = type { i8 } +%class.foo.0 = type { i8 } +%class.foo.1 = type { i8 } + +; Function Attrs: noinline norecurse nounwind optnone uwtable +define dso_local i32 @main() #0 !dbg !7 { +entry: + %retval = alloca i32, align 4 + %f1 = alloca %class.foo, align 1 + %f2 = alloca %class.foo.0, align 1 + %f3 = alloca %class.foo.1, align 1 + store i32 0, i32* %retval, align 4 + call void @llvm.dbg.declare(metadata %class.foo* %f1, metadata !11, metadata !DIExpression()), !dbg !16 + call void @llvm.dbg.declare(metadata %class.foo.0* %f2, metadata !17, metadata !DIExpression()), !dbg !22 + call void @llvm.dbg.declare(metadata %class.foo.1* %f3, metadata !23, metadata !DIExpression()), !dbg !28 + ret i32 0, !dbg !29 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +attributes #0 = { noinline norecurse nounwind optnone uwtable } +attributes #1 = { nounwind readnone speculatable willreturn } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums:
[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates
awpandey updated this revision to Diff 241141. awpandey added a comment. Thanks @dblaikie for figuring out the missing feature. I have added support for the non-type template parameter too. Please let me know if further modifications are required. I will happily address them. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73462/new/ https://reviews.llvm.org/D73462 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-template-parameter.cpp llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/test/DebugInfo/X86/debug-info-template-parameter.ll llvm/unittests/IR/MetadataTest.cpp Index: llvm/unittests/IR/MetadataTest.cpp === --- llvm/unittests/IR/MetadataTest.cpp +++ llvm/unittests/IR/MetadataTest.cpp @@ -2077,16 +2077,16 @@ StringRef Name = "template"; DIType *Type = getBasicType("basic"); - auto *N = DITemplateTypeParameter::get(Context, Name, Type); + auto *N = DITemplateTypeParameter::get(Context, Name, Type, false); EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); - EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type)); + EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type, false)); - EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type)); - EXPECT_NE(N, -DITemplateTypeParameter::get(Context, Name, getBasicType("other"))); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type, false)); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name, +getBasicType("other"), false)); TempDITemplateTypeParameter Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); @@ -2100,21 +2100,23 @@ DIType *Type = getBasicType("basic"); Metadata *Value = getConstantAsMetadata(); - auto *N = DITemplateValueParameter::get(Context, Tag, Name, Type, Value); + auto *N = + DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value); EXPECT_EQ(Tag, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); EXPECT_EQ(Value, N->getValue()); - EXPECT_EQ(N, DITemplateValueParameter::get(Context, Tag, Name, Type, Value)); + EXPECT_EQ( + N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value)); EXPECT_NE(N, DITemplateValueParameter::get( Context, dwarf::DW_TAG_GNU_template_template_param, Name, - Type, Value)); - EXPECT_NE(N, -DITemplateValueParameter::get(Context, Tag, "other", Type, Value)); - EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, - getBasicType("other"), Value)); - EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, + Type, false, Value)); + EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, "other", Type, false, + Value)); + EXPECT_NE(N, DITemplateValueParameter::get( + Context, Tag, Name, getBasicType("other"), false, Value)); + EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, getConstantAsMetadata())); TempDITemplateValueParameter Temp = N->clone(); Index: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-template-parameter.ll @@ -0,0 +1,106 @@ +; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;template +;class foo { +;}; +; +;int main() { +; foo f1; +; foo f2; +; foo<> f3; +; return 0; +;} + +; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c + +; CHECK: .debug_abbrev contents: +; CHECK: DW_AT_default_value DW_FORM_flag_present + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK-NOT: DW_AT_default_value +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "T1" +; CHECK-NEXT: DW_AT_default_value {{.*}} (true) + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "float" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK-NOT: DW_AT_default_value +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "T1" +; CHECK-NEXT: DW_AT_default_value {{.*}} (true) + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "char" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK-NEXT: DW_AT_default_value {{.*}} (
[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates
awpandey updated this revision to Diff 241391. awpandey marked 7 inline comments as done. awpandey added a comment. Hi @dblaikie, I have incorporated your suggestions (renaming variables, test case modification). CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73462/new/ https://reviews.llvm.org/D73462 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-template-parameter.cpp llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/test/DebugInfo/X86/debug-info-template-parameter.ll llvm/unittests/IR/MetadataTest.cpp Index: llvm/unittests/IR/MetadataTest.cpp === --- llvm/unittests/IR/MetadataTest.cpp +++ llvm/unittests/IR/MetadataTest.cpp @@ -2077,16 +2077,16 @@ StringRef Name = "template"; DIType *Type = getBasicType("basic"); - auto *N = DITemplateTypeParameter::get(Context, Name, Type); + auto *N = DITemplateTypeParameter::get(Context, Name, Type, false); EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); - EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type)); + EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type, false)); - EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type)); - EXPECT_NE(N, -DITemplateTypeParameter::get(Context, Name, getBasicType("other"))); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type, false)); + EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name, +getBasicType("other"), false)); TempDITemplateTypeParameter Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); @@ -2100,21 +2100,23 @@ DIType *Type = getBasicType("basic"); Metadata *Value = getConstantAsMetadata(); - auto *N = DITemplateValueParameter::get(Context, Tag, Name, Type, Value); + auto *N = + DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value); EXPECT_EQ(Tag, N->getTag()); EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Type, N->getType()); EXPECT_EQ(Value, N->getValue()); - EXPECT_EQ(N, DITemplateValueParameter::get(Context, Tag, Name, Type, Value)); + EXPECT_EQ( + N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value)); EXPECT_NE(N, DITemplateValueParameter::get( Context, dwarf::DW_TAG_GNU_template_template_param, Name, - Type, Value)); - EXPECT_NE(N, -DITemplateValueParameter::get(Context, Tag, "other", Type, Value)); - EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, - getBasicType("other"), Value)); - EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, + Type, false, Value)); + EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, "other", Type, false, + Value)); + EXPECT_NE(N, DITemplateValueParameter::get( + Context, Tag, Name, getBasicType("other"), false, Value)); + EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, getConstantAsMetadata())); TempDITemplateValueParameter Temp = N->clone(); Index: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll === --- /dev/null +++ llvm/test/DebugInfo/X86/debug-info-template-parameter.ll @@ -0,0 +1,90 @@ +; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s + +; C++ source to regenerate: + +;template +;class foo { +;}; +; +;int main() { +; foo f1; +; foo<> f2; +; return 0; +;} + +; $ clang++ -O0 -gdwarf-5 -S -gdwarf-5 test.cpp + +; CHECK: .debug_abbrev contents: +; CHECK: DW_AT_default_value DW_FORM_flag_present + +; CHECK: debug_info contents: + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK-NOT: DW_AT_default_value +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "i" +; CHECK-NOT: DW_AT_default_value + +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK: DW_AT_type {{.*}} "char" +; CHECK-NEXT: DW_AT_name {{.*}} "T" +; CHECK_NEXT: DW_AT_default_value {{.*}} true +; CHECK: DW_AT_type {{.*}} "int" +; CHECK-NEXT: DW_AT_name {{.*}} "i" +; CHECK_NEXT: DW_AT_default_value {{.*}} true + +; ModuleID = '/dir/test.cpp' +source_filename = "test.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%class.foo =
[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates
awpandey marked an inline comment as done and an inline comment as not done. awpandey added inline comments. Comment at: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1808-1809 Record.push_back(VE.getMetadataOrNullID(N->getType())); + if (M.getDwarfVersion() >= 5) +Record.push_back(N->getDefault()); Record.push_back(VE.getMetadataOrNullID(N->getValue())); dblaikie wrote: > I don't think we should be using the DWARF version to decide on the schema - > there's no other use of that technique in the parsing/writing code & I can > think of some ways it might go poorly. > > Better to encode it & it can be dropped during actual DWARF emission in the > backend if the version doesn't support it. I am doing this for making record structure consistent with previous dwarf version. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73462/new/ https://reviews.llvm.org/D73462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates
awpandey marked an inline comment as not done. awpandey added a comment. @aprantl Thanks for your valuable feedback. I have a doubt. You need a .ll file its corresponding llvm bytecode generated by current llvm (without my patch). Doest this ll file includes any checks? In the round trip test case I have to do llvm-as followed by llvm-dis then performs checks or something else? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73462/new/ https://reviews.llvm.org/D73462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits