akhuang created this revision. akhuang added reviewers: rnk, dblaikie. akhuang requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
This change adds function types to further differentiate between FUNC_IDs in -gline-tables-only. Size increase of object files in clang are Before: 917990 kb After: 999312 kb Bug: https://bugs.llvm.org/show_bug.cgi?id=48432 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D95001 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp Index: clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp +++ clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp @@ -5,7 +5,6 @@ namespace NS { struct C { -public: void m() {} }; void f() {} @@ -14,17 +13,24 @@ NS::C c; void test() { - // CHECK: ![[EMPTY:[0-9]+]] = !{} // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]], // CHECK-SAME: type: ![[F:[0-9]+]] // CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null) - // CHECK: ![[F]] = !DISubroutineType(types: ![[EMPTY]]) + // CHECK: ![[F]] = !DISubroutineType(types: ![[FTYPE:[0-9]+]]) + // CHECK: ![[FTYPE]] = !{null} NS::f(); - // CHECK: !DISubprogram(name: "m", scope: ![[C:[0-9]+]], - // CHECK-SAME: type: ![[F]] + // CHECK: ![[M:[0-9]+]] = distinct !DISubprogram(name: "m", scope: ![[C:[0-9]+]], + // CHECK-SAME: type: ![[MTYPE:[0-9]+]] // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C", // CHECK-SAME: flags: DIFlagFwdDecl // CHECK-NOT: identifier c.m(); + + // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA:[0-9]+]] + // CHECK: ![[LAMBDA]] = !DICompositeType(tag: DW_TAG_class_type, + // CHECK-SAME: flags: DIFlagFwdDecl + // CHECK-SAME: identifier: {{.*lambda.*}} + auto lambda1 = []() {}; + lambda1(); } Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -1047,8 +1047,9 @@ // Create the type. SmallString<256> Identifier; - // Don't include a linkage name in line tables only. - if (CGM.getCodeGenOpts().hasReducedDebugInfo()) + // Don't include a linkage name in line tables only, except to differentiate + // between lambdas. + if (CGM.getCodeGenOpts().hasReducedDebugInfo() || RD->isLambda()) Identifier = getTypeIdentifier(Ty, CGM, TheCU); llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType( getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align, Flags, @@ -3734,7 +3735,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile *F) { - if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly) + if (!D) // Create fake but valid subroutine type. Otherwise -verify would fail, and // subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields. return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray(None));
Index: clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp +++ clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp @@ -5,7 +5,6 @@ namespace NS { struct C { -public: void m() {} }; void f() {} @@ -14,17 +13,24 @@ NS::C c; void test() { - // CHECK: ![[EMPTY:[0-9]+]] = !{} // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]], // CHECK-SAME: type: ![[F:[0-9]+]] // CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null) - // CHECK: ![[F]] = !DISubroutineType(types: ![[EMPTY]]) + // CHECK: ![[F]] = !DISubroutineType(types: ![[FTYPE:[0-9]+]]) + // CHECK: ![[FTYPE]] = !{null} NS::f(); - // CHECK: !DISubprogram(name: "m", scope: ![[C:[0-9]+]], - // CHECK-SAME: type: ![[F]] + // CHECK: ![[M:[0-9]+]] = distinct !DISubprogram(name: "m", scope: ![[C:[0-9]+]], + // CHECK-SAME: type: ![[MTYPE:[0-9]+]] // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C", // CHECK-SAME: flags: DIFlagFwdDecl // CHECK-NOT: identifier c.m(); + + // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA:[0-9]+]] + // CHECK: ![[LAMBDA]] = !DICompositeType(tag: DW_TAG_class_type, + // CHECK-SAME: flags: DIFlagFwdDecl + // CHECK-SAME: identifier: {{.*lambda.*}} + auto lambda1 = []() {}; + lambda1(); } Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -1047,8 +1047,9 @@ // Create the type. SmallString<256> Identifier; - // Don't include a linkage name in line tables only. - if (CGM.getCodeGenOpts().hasReducedDebugInfo()) + // Don't include a linkage name in line tables only, except to differentiate + // between lambdas. + if (CGM.getCodeGenOpts().hasReducedDebugInfo() || RD->isLambda()) Identifier = getTypeIdentifier(Ty, CGM, TheCU); llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType( getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align, Flags, @@ -3734,7 +3735,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile *F) { - if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly) + if (!D) // Create fake but valid subroutine type. Otherwise -verify would fail, and // subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields. return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray(None));
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits