[clang] d20bf5a - [DebugInfo] Upgrade DISubrange to support Fortran dynamic arrays
Author: Alok Kumar Sharma Date: 2020-05-28T13:46:41+05:30 New Revision: d20bf5a7258d4b6a7f017a81b125275dac1aa166 URL: https://github.com/llvm/llvm-project/commit/d20bf5a7258d4b6a7f017a81b125275dac1aa166 DIFF: https://github.com/llvm/llvm-project/commit/d20bf5a7258d4b6a7f017a81b125275dac1aa166.diff LOG: [DebugInfo] Upgrade DISubrange to support Fortran dynamic arrays This patch upgrades DISubrange to support fortran requirements. Summary: Below are the updates/addition of fields. lowerBound - Now accepts signed integer or DIVariable or DIExpression, earlier it accepted only signed integer. upperBound - This field is now added and accepts signed interger or DIVariable or DIExpression. stride - This field is now added and accepts signed interger or DIVariable or DIExpression. This is required to describe bounds of array which are known at runtime. Testing: unit test cases added (hand-written) check clang check llvm check debug-info Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D80197 Added: llvm/test/Bitcode/fortranSubrange.ll llvm/test/Bitcode/fortranSubrangeBackward.ll llvm/test/Bitcode/fortranSubrangeBackward.ll.bc llvm/test/DebugInfo/cDefaultLower.ll llvm/test/DebugInfo/fortranDefaultLower.ll llvm/test/DebugInfo/fortranSubrangeExpr.ll llvm/test/DebugInfo/fortranSubrangeInt.ll llvm/test/DebugInfo/fortranSubrangeVar.ll llvm/test/Verifier/disubrange-count-upperBound.ll llvm/test/Verifier/disubrange-missing-upperBound.ll llvm/test/Verifier/invalid-disubrange-lowerBound.ll llvm/test/Verifier/invalid-disubrange-stride.ll llvm/test/Verifier/invalid-disubrange-upperBound.ll Modified: clang/lib/CodeGen/CGDebugInfo.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/CodeViewDebug.cpp llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.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/lib/IR/Verifier.cpp llvm/test/Assembler/debug-info.ll llvm/test/Assembler/disubrange-empty-array.ll llvm/test/Assembler/invalid-disubrange-count-missing.ll llvm/test/Bindings/llvm-c/debug_info.ll llvm/test/DebugInfo/X86/default-subrange-array.ll llvm/test/DebugInfo/X86/nondefault-subrange-array.ll llvm/unittests/IR/MetadataTest.cpp Removed: diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 7ec792ca0e1f..4e0b6aa0dca6 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2732,9 +2732,17 @@ llvm::DIType *CGDebugInfo::CreateType(const VectorType *Ty, QualType QTy(Ty, 0); auto SizeExpr = SizeExprCache.find(QTy); if (SizeExpr != SizeExprCache.end()) -Subscript = DBuilder.getOrCreateSubrange(0, SizeExpr->getSecond()); - else -Subscript = DBuilder.getOrCreateSubrange(0, Count ? Count : -1); +Subscript = DBuilder.getOrCreateSubrange( +SizeExpr->getSecond() /*count*/, nullptr /*lowerBound*/, +nullptr /*upperBound*/, nullptr /*stride*/); + else { +auto *CountNode = +llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned( +llvm::Type::getInt64Ty(CGM.getLLVMContext()), Count ? Count : -1)); +Subscript = DBuilder.getOrCreateSubrange( +CountNode /*count*/, nullptr /*lowerBound*/, nullptr /*upperBound*/, +nullptr /*stride*/); + } llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript); uint64_t Size = CGM.getContext().getTypeSize(Ty); @@ -2754,8 +2762,18 @@ llvm::DIType *CGDebugInfo::CreateType(const ConstantMatrixType *Ty, // Create ranges for both dimensions. llvm::SmallVector Subscripts; - Subscripts.push_back(DBuilder.getOrCreateSubrange(0, Ty->getNumColumns())); - Subscripts.push_back(DBuilder.getOrCreateSubrange(0, Ty->getNumRows())); + auto *ColumnCountNode = + llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned( + llvm::Type::getInt64Ty(CGM.getLLVMContext()), Ty->getNumColumns())); + auto *RowCountNode = + llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned( + llvm::Type::getInt64Ty(CGM.getLLVMContext()), Ty->getNumRows())); + Subscripts.push_back(DBuilder.getOrCreateSubrange( + ColumnCountNode /*count*/, nullptr /*lowerBound*/, nullptr /*upperBound*/, + nullptr /*stride*/)); + Subscripts.push_back(DBuilder.getOrCreateSubrange( + RowCountNode /*count*/, nullptr /*lowerBound*/, nullptr /*upperBound*/, + nullptr /*stride*/)); llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscripts); return DBuilder.createArrayType(Size, Align,
[clang] 6d6a459 - [DWARF5][clang]: Added support for DebugInfo generation for auto return type for C++ member functions.
Author: Awanish Pandey Date: 2020-01-13T12:40:18+05:30 New Revision: 6d6a4590c5d4c7fc7445d72fe685f966b0a8cafb URL: https://github.com/llvm/llvm-project/commit/6d6a4590c5d4c7fc7445d72fe685f966b0a8cafb DIFF: https://github.com/llvm/llvm-project/commit/6d6a4590c5d4c7fc7445d72fe685f966b0a8cafb.diff LOG: [DWARF5][clang]: Added support for DebugInfo generation for auto return type for C++ member functions. Summary: This patch will provide support for auto return type for the C++ member functions. This patch includes clang side implementation of this feature. Patch by: Awanish Pandey Reviewers: dblaikie, aprantl, shafik, alok, SouraVX, jini.susan.george Reviewed by: dblaikie Differential Revision: https://reviews.llvm.org/D70524 Added: clang/test/CodeGenCXX/debug-info-auto-return.cpp Modified: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h Removed: diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 675df309e3f0..6d2123a7b0e1 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -810,6 +810,10 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) { 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 @@ void CGDebugInfo::CollectRecordFields( 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::DISubroutineType * +CGDebugInfo::getOrCreateInstanceMethodType(QualType ThisPtr, + const FunctionProtoType *Func, + llvm::DIFile *Unit, bool decl) { // Add "this" pointer. llvm::DITypeRefArray Args( cast(getOrCreateType(QualType(Func, 0), Unit)) @@ -1474,9 +1480,12 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType( assert(Args.size() && "Invalid number of arguments!"); SmallVector Elts; - // First element is always return type. For 'void' functions it is NULL. - Elts.push_back(Args[0]); + QualType temp = Func->getReturnType(); + if (temp->getTypeClass() == Type::Auto && decl) +Elts.push_back(CreateType(cast(temp))); + else +Elts.push_back(Args[0]); // "this" pointer is always first argument. const CXXRecordDecl *RD = ThisPtr->getPointeeCXXRecordDecl(); @@ -1535,7 +1544,7 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction( isa(Method) || isa(Method); StringRef MethodName = getFunctionName(Method); - llvm::DISubroutineType *MethodTy = getOrCreateMethodType(Method, Unit); + llvm::DISubroutineType *MethodTy = getOrCreateMethodType(Method, Unit, true); // Since a single ctor/dtor corresponds to multiple functions, it doesn't // make sense to give a single ctor/dtor a linkage name. @@ -2754,7 +2763,7 @@ llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty, return DBuilder.createMemberPointerType( getOrCreateInstanceMethodType( CXXMethodDecl::getThisType(FPT, Ty->getMostRecentCXXRecordDecl()), - FPT, U), + FPT, U, false), ClassType, Size, /*Align=*/0, Flags); } @@ -3529,7 +3538,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D, return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray(None)); if (const auto *Method = dyn_cast(D)) -return getOrCreateMethodType(Method, F); +return getOrCreateMethodType(Method, F, false); const auto *FTy = FnType->getAs(); CallingConv CC = FTy ? FTy->getCallConv() : CallingConv::CC_C; diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index 90e9a61ebe96..d9c6b4d79097 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -165,6 +165,7 @@ class CGDebugInfo { /// ivars and property accessors. llvm::DIType *CreateType(const BuiltinType *Ty); llvm::DIType *CreateType(const ComplexType *Ty); + llvm::DIType *CreateType(const AutoType *Ty); llvm::DIType *Cr
[clang] c2b437d - [DebugInfo][clang][DWARF5]: Added support for debuginfo generation for defaulted parameters
Author: Awanish Pandey Date: 2020-03-02T12:33:05+05:30 New Revision: c2b437d53d40b6dc5603c97f527398f477d9c5f1 URL: https://github.com/llvm/llvm-project/commit/c2b437d53d40b6dc5603c97f527398f477d9c5f1 DIFF: https://github.com/llvm/llvm-project/commit/c2b437d53d40b6dc5603c97f527398f477d9c5f1.diff LOG: [DebugInfo][clang][DWARF5]: Added support for debuginfo generation for defaulted parameters in C++ templates. Summary: This patch adds support for debuginfo generation for defaulted parameters in clang and also extends corresponding DebugMetadata/IR to support this feature. Reviewers: probinson, aprantl, dblaikie Reviewed By: aprantl, dblaikie Differential Revision: https://reviews.llvm.org/D73462 Added: llvm/test/Assembler/DITemplateParameter.ll llvm/test/Bitcode/DITemplateParameter-5.0.ll Modified: clang/lib/CodeGen/CGDebugInfo.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/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/unittests/IR/MetadataTest.cpp Removed: diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index e171082942f6..404ecfa975a1 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1787,18 +1787,36 @@ CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList, for (unsigned i = 0, e = TAList.size(); i != e; ++i) { const TemplateArgument &TA = TAList[i]; StringRef Name; +bool defaultParameter = false; if (TPList) Name = TPList->getParam(i)->getName(); switch (TA.getKind()) { case TemplateArgument::Type: { llvm::DIType *TTy = getOrCreateType(TA.getAsType(), Unit); - TemplateParams.push_back( - DBuilder.createTemplateTypeParameter(TheCU, Name, TTy)); + + if (TPList) +if (auto *templateType = +dyn_cast_or_null(TPList->getParam(i))) + if (templateType->hasDefaultArgument()) +defaultParameter = +templateType->getDefaultArgument() == TA.getAsType(); + + TemplateParams.push_back(DBuilder.createTemplateTypeParameter( + TheCU, Name, TTy, defaultParameter)); + } break; case TemplateArgument::Integral: { llvm::DIType *TTy = getOrCreateType(TA.getIntegralType(), Unit); + if (TPList) +if (auto *templateType = +dyn_cast_or_null(TPList->getParam(i))) + if (templateType->hasDefaultArgument()) +defaultParameter = +templateType->getDefaultArgument()->EvaluateKnownConstInt( +CGM.getContext()) == TA.getAsIntegral(); + TemplateParams.push_back(DBuilder.createTemplateValueParameter( - TheCU, Name, TTy, + TheCU, Name, TTy, defaultParameter, llvm::ConstantInt::get(CGM.getLLVMContext(), TA.getAsIntegral(; } break; case TemplateArgument::Declaration: { @@ -1837,7 +1855,7 @@ CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList, V = V->stripPointerCasts(); } TemplateParams.push_back(DBuilder.createTemplateValueParameter( - TheCU, Name, TTy, cast_or_null(V))); + TheCU, Name, TTy, defaultParameter, cast_or_null(V))); } break; case TemplateArgument::NullPtr: { QualType T = TA.getNullPtrType(); @@ -1855,8 +1873,8 @@ CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList, V = CGM.getCXXABI().EmitNullMemberPointer(MPT); if (!V) V = llvm::ConstantInt::get(CGM.Int8Ty, 0); - TemplateParams.push_back( - DBuilder.createTemplateValueParameter(TheCU, Name, TTy, V)); + TemplateParams.push_back(DBuilder.createTemplateValueParameter( + TheCU, Name, TTy, defaultParameter, V)); } break; case TemplateArgument::Template: TemplateParams.push_back(DBuilder.createTemplateTemplateParameter( @@ -1877,7 +1895,7 @@ CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList, assert(V && "Expression in template argument isn't constant"); llvm::DIType *TTy = getOrCreateType(T, Unit); TemplateParams.push_back(DBuilder.createTemplateValueParameter( - TheCU, Name, TTy, V->stripPointerCasts())); + TheCU, Name, TTy, defaultParameter, V->stripPointerCasts())); } break; // And the following should never occur: case TemplateArgument::TemplateExpansion: diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h index cbc96a483f91..604740dcdfb3 100644 --- a/llvm/include/llvm/IR/DIBuilder.h +++ b/llvm/include/llvm/IR/DIBuilder.h @@ -443,19 +443,22 @@ namespace llvm {
[clang] 7a42bab - Reland "[DebugInfo][clang][DWARF5]: Added support for debuginfo generation for defaulted parameters
Author: Awanish Pandey Date: 2020-03-02T16:45:48+05:30 New Revision: 7a42babeb83e3927e89e72a0e7e45be9d41b6c23 URL: https://github.com/llvm/llvm-project/commit/7a42babeb83e3927e89e72a0e7e45be9d41b6c23 DIFF: https://github.com/llvm/llvm-project/commit/7a42babeb83e3927e89e72a0e7e45be9d41b6c23.diff LOG: Reland "[DebugInfo][clang][DWARF5]: Added support for debuginfo generation for defaulted parameters in C++ templates." This was reverted in 802b22b5c8c30bebc1695a217478be02653c6b53 due to missing .bc file and a chromium bot failure. https://bugs.chromium.org/p/chromium/issues/detail?id=1057559#c1 This revision address both of them. Summary: This patch adds support for debuginfo generation for defaulted parameters in clang and also extends corresponding DebugMetadata/IR to support this feature. Reviewers: probinson, aprantl, dblaikie Reviewed By: aprantl, dblaikie Differential Revision: https://reviews.llvm.org/D73462 Added: llvm/test/Assembler/DIDefaultTemplateParam.ll llvm/test/Bitcode/DITemplateParameter-5.0.ll llvm/test/Bitcode/DITemplateParameter-5.0.ll.bc Modified: clang/lib/CodeGen/CGDebugInfo.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/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/unittests/IR/MetadataTest.cpp Removed: diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index e171082942f6..cbf45a5cf748 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1787,18 +1787,36 @@ CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList, for (unsigned i = 0, e = TAList.size(); i != e; ++i) { const TemplateArgument &TA = TAList[i]; StringRef Name; +bool defaultParameter = false; if (TPList) Name = TPList->getParam(i)->getName(); switch (TA.getKind()) { case TemplateArgument::Type: { llvm::DIType *TTy = getOrCreateType(TA.getAsType(), Unit); - TemplateParams.push_back( - DBuilder.createTemplateTypeParameter(TheCU, Name, TTy)); + + if (TPList) +if (auto *templateType = +dyn_cast_or_null(TPList->getParam(i))) + if (templateType->hasDefaultArgument()) +defaultParameter = +templateType->getDefaultArgument() == TA.getAsType(); + + TemplateParams.push_back(DBuilder.createTemplateTypeParameter( + TheCU, Name, TTy, defaultParameter)); + } break; case TemplateArgument::Integral: { llvm::DIType *TTy = getOrCreateType(TA.getIntegralType(), Unit); + if (TPList && CGM.getCodeGenOpts().DwarfVersion >= 5) +if (auto *templateType = +dyn_cast_or_null(TPList->getParam(i))) + if (templateType->hasDefaultArgument()) +defaultParameter = +templateType->getDefaultArgument()->EvaluateKnownConstInt( +CGM.getContext()) == TA.getAsIntegral(); + TemplateParams.push_back(DBuilder.createTemplateValueParameter( - TheCU, Name, TTy, + TheCU, Name, TTy, defaultParameter, llvm::ConstantInt::get(CGM.getLLVMContext(), TA.getAsIntegral(; } break; case TemplateArgument::Declaration: { @@ -1837,7 +1855,7 @@ CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList, V = V->stripPointerCasts(); } TemplateParams.push_back(DBuilder.createTemplateValueParameter( - TheCU, Name, TTy, cast_or_null(V))); + TheCU, Name, TTy, defaultParameter, cast_or_null(V))); } break; case TemplateArgument::NullPtr: { QualType T = TA.getNullPtrType(); @@ -1855,8 +1873,8 @@ CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList, V = CGM.getCXXABI().EmitNullMemberPointer(MPT); if (!V) V = llvm::ConstantInt::get(CGM.Int8Ty, 0); - TemplateParams.push_back( - DBuilder.createTemplateValueParameter(TheCU, Name, TTy, V)); + TemplateParams.push_back(DBuilder.createTemplateValueParameter( + TheCU, Name, TTy, defaultParameter, V)); } break; case TemplateArgument::Template: TemplateParams.push_back(DBuilder.createTemplateTemplateParameter( @@ -1877,7 +1895,7 @@ CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList, assert(V && "Expression in template argument isn't constant"); llvm::DIType *TTy = getOrCreateType(T, Unit); TemplateParams.push_back(DBuilder.createTemplateValueParameter( - TheCU, Name, TTy, V->stripPointerCasts())); + TheCU, Name, TTy, defaultParameter, V->stripPointerCasts())); } break; // And the
[clang] 1cb0e01 - [DebugInfo][DWARF5]: Added support for debuginfo generation for defaulted parameters
Author: Awanish Pandey Date: 2020-03-03T13:09:53+05:30 New Revision: 1cb0e01e42ca5e9de44d9b7cb03d23552a9a9ae1 URL: https://github.com/llvm/llvm-project/commit/1cb0e01e42ca5e9de44d9b7cb03d23552a9a9ae1 DIFF: https://github.com/llvm/llvm-project/commit/1cb0e01e42ca5e9de44d9b7cb03d23552a9a9ae1.diff LOG: [DebugInfo][DWARF5]: Added support for debuginfo generation for defaulted parameters This patch adds support for dwarf emission/dumping part of debuginfo generation for defaulted parameters. Reviewers: probinson, aprantl, dblaikie Reviewed By: aprantl, dblaikie Differential Revision: https://reviews.llvm.org/D73462 Added: clang/test/CodeGenCXX/debug-info-template-parameter.cpp Modified: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Removed: diff --git a/clang/test/CodeGenCXX/debug-info-template-parameter.cpp b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp new file mode 100644 index ..95e7a187fe10 --- /dev/null +++ b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp @@ -0,0 +1,29 @@ +// Test for DebugInfo for Defaulted parameters for C++ templates +// Supported: -O0, standalone DI + +// 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: DILocalVariable(name: "f1", {{.*}}, type: ![[TEMPLATE_TYPE:[0-9]+]] +// CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}}, templateParams: ![[F1_TYPE:[0-9]+]] +// CHECK: [[F1_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]]} +// CHECK: [[FIRST]] = !DITemplateTypeParameter(name: "T", type: !{{[0-9]*}}) +// CHECK: [[SECOND]] = !DITemplateValueParameter(name: "i", type: !{{[0-9]*}}, value: i32 6) + +// CHECK: DILocalVariable(name: "f2", {{.*}}, type: ![[TEMPLATE_TYPE:[0-9]+]] +// CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}}, templateParams: ![[F2_TYPE:[0-9]+]] +// CHECK: [[F2_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]]} +// CHECK: [[FIRST]] = !DITemplateTypeParameter(name: "T", type: !{{[0-9]*}}, defaulted: true) +// CHECK: [[SECOND]] = !DITemplateValueParameter(name: "i", type: !{{[0-9]*}}, defaulted: true, value: i32 3) + +template +class foo { +}; + +int main() { + foo f1; + foo<> f2; + return 0; +} diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index def2dc0e0889..134ef74b2704 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1045,6 +1045,8 @@ void DwarfUnit::constructTemplateTypeParameterDIE( addType(ParamDIE, TP->getType()); if (!TP->getName().empty()) addString(ParamDIE, dwarf::DW_AT_name, TP->getName()); + if (TP->isDefault() && (DD->getDwarfVersion() >= 5)) +addFlag(ParamDIE, dwarf::DW_AT_default_value); } void DwarfUnit::constructTemplateValueParameterDIE( @@ -1057,6 +1059,8 @@ void DwarfUnit::constructTemplateValueParameterDIE( addType(ParamDIE, VP->getType()); if (!VP->getName().empty()) addString(ParamDIE, dwarf::DW_AT_name, VP->getName()); + if (VP->isDefault() && (DD->getDwarfVersion() >= 5)) +addFlag(ParamDIE, dwarf::DW_AT_default_value); if (Metadata *Val = VP->getValue()) { if (ConstantInt *CI = mdconst::dyn_extract(Val)) addConstantValue(ParamDIE, CI, VP->getType()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 52ea308 - [NFC]: Removed an implicit capture argument from lambda.
Author: Sourabh Singh Tomar Date: 2019-11-02T01:37:46+05:30 New Revision: 52ea308f705af0a8f5d55e036a64fd2b5e4c2ee6 URL: https://github.com/llvm/llvm-project/commit/52ea308f705af0a8f5d55e036a64fd2b5e4c2ee6 DIFF: https://github.com/llvm/llvm-project/commit/52ea308f705af0a8f5d55e036a64fd2b5e4c2ee6.diff LOG: [NFC]: Removed an implicit capture argument from lambda. Added: Modified: clang/lib/CodeGen/CGDebugInfo.cpp Removed: diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index d2d9e8e59119..38750d7d3369 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1608,7 +1608,7 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction( // We're checking for deleted C++ special member functions // [Ctors,Dtors, Copy/Move] - auto checkAttrDeleted = [&SPFlags](const auto *Method) { + auto checkAttrDeleted = [&](const auto *Method) { if (Method->getCanonicalDecl()->isDeleted()) SPFlags |= llvm::DISubprogram::SPFlagDeleted; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 423f541 - [DWARF5]Addition of alignment atrribute in typedef DIE.
Author: Sourabh Singh Tomar Date: 2019-11-16T21:56:53+05:30 New Revision: 423f541c1a322963cf482683fe9777ef0692082d URL: https://github.com/llvm/llvm-project/commit/423f541c1a322963cf482683fe9777ef0692082d DIFF: https://github.com/llvm/llvm-project/commit/423f541c1a322963cf482683fe9777ef0692082d.diff LOG: [DWARF5]Addition of alignment atrribute in typedef DIE. This patch, adds support for DW_AT_alignment[DWARF5] attribute, to be emitted with typdef DIE. When explicit alignment is specified. Patch by Awanish Pandey Reviewers: aprantl, dblaikie, jini.susan.george, SouraVX, alok, deadalinx Differential Revision: https://reviews.llvm.org/D70111 Added: clang/test/CodeGenCXX/debug-info-template-align.cpp llvm/test/DebugInfo/X86/debug-info-template-align.ll Modified: clang/lib/CodeGen/CGDebugInfo.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/tools/llvm-c-test/debuginfo.c Removed: diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 75c4b2ae2339..f204b9716926 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1127,7 +1127,8 @@ llvm::DIType *CGDebugInfo::CreateType(const TemplateSpecializationType *Ty, SourceLocation Loc = AliasDecl->getLocation(); return DBuilder.createTypedef(Src, OS.str(), getOrCreateFile(Loc), getLineNumber(Loc), -getDeclContextDescriptor(AliasDecl)); +getDeclContextDescriptor(AliasDecl), +/* Alignment */ None); } llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty, @@ -1143,9 +1144,10 @@ llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty, SourceLocation Loc = Ty->getDecl()->getLocation(); // Typedefs are derived from some other type. - return DBuilder.createTypedef(Underlying, Ty->getDecl()->getName(), -getOrCreateFile(Loc), getLineNumber(Loc), -getDeclContextDescriptor(Ty->getDecl())); + return DBuilder.createTypedef( + Underlying, Ty->getDecl()->getName(), getOrCreateFile(Loc), + getLineNumber(Loc), getDeclContextDescriptor(Ty->getDecl()), + getDeclAlignIfRequired(Ty->getDecl(), CGM.getContext())); } static unsigned getDwarfCC(CallingConv CC) { @@ -2324,7 +2326,8 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCTypeParamType *Ty, return DBuilder.createTypedef( getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit), Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc), - getDeclContextDescriptor(Ty->getDecl())); + getDeclContextDescriptor(Ty->getDecl()), + /* Alignment */ None); } /// \return true if Getter has the default name for the property PD. diff --git a/clang/test/CodeGenCXX/debug-info-template-align.cpp b/clang/test/CodeGenCXX/debug-info-template-align.cpp new file mode 100644 index ..42fdb269a30b --- /dev/null +++ b/clang/test/CodeGenCXX/debug-info-template-align.cpp @@ -0,0 +1,14 @@ +// Test for debug info related to DW_AT_alignment attribute in the typedef operator +// Supported: -O0, standalone DI +// 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: DIDerivedType(tag: DW_TAG_typedef, {{.*}}, align: 512 + +typedef char __attribute__((__aligned__(64))) alchar; + +int main() { + alchar newChar; +} diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h index 41e9f96bbb92..891faedb636f 100644 --- a/llvm/include/llvm-c/DebugInfo.h +++ b/llvm/include/llvm-c/DebugInfo.h @@ -875,7 +875,7 @@ LLVMMetadataRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, - LLVMMetadataRef Scope); + LLVMMetadataRef Scope, uint32_t AlignInBits); /** * Create debugging information entry to establish inheritance relationship diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h index ad9a35b55414..3c738b8a4f9f 100644 --- a/llvm/include/llvm/IR/DIBuilder.h +++ b/llvm/include/llvm/IR/DIBuilder.h @@ -237,8 +237,10 @@ namespace llvm { /// \param FileFile where this type is defined. /// \param LineNo Line number. /// \param Context The surrounding context for the typedef. +/// \param AlignInBits Alignment. (Optional) DIDerivedType *createTypedef(DIType *Ty, StringRef Name, DIFile *File, -
[clang] f1e3988 - Recommit "[DWARF5]Addition of alignment atrribute in typedef DIE."
Author: Sourabh Singh Tomar Date: 2019-12-03T09:51:43+05:30 New Revision: f1e3988aa6016188c376b9bcca1afc7559f9fbc0 URL: https://github.com/llvm/llvm-project/commit/f1e3988aa6016188c376b9bcca1afc7559f9fbc0 DIFF: https://github.com/llvm/llvm-project/commit/f1e3988aa6016188c376b9bcca1afc7559f9fbc0.diff LOG: Recommit "[DWARF5]Addition of alignment atrribute in typedef DIE." This revision is revised to update Go-bindings and Release Notes. The original commit message follows. This patch, adds support for DW_AT_alignment[DWARF5] attribute, to be emitted with typdef DIE. When explicit alignment is specified. Patch by Awanish Pandey Reviewers: aprantl, dblaikie, jini.susan.george, SouraVX, alok, deadalinx Differential Revision: https://reviews.llvm.org/D70111 Added: clang/test/CodeGenCXX/debug-info-template-align.cpp llvm/test/DebugInfo/X86/debug-info-template-align.ll Modified: clang/lib/CodeGen/CGDebugInfo.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/tools/llvm-c-test/debuginfo.c Removed: diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index db5893a7b51f..8d6406c02773 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1141,10 +1141,11 @@ llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty, // declared. SourceLocation Loc = Ty->getDecl()->getLocation(); + uint32_t Align = getDeclAlignIfRequired(Ty->getDecl(), CGM.getContext()); // Typedefs are derived from some other type. return DBuilder.createTypedef(Underlying, Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc), -getDeclContextDescriptor(Ty->getDecl())); +getDeclContextDescriptor(Ty->getDecl()), Align); } static unsigned getDwarfCC(CallingConv CC) { diff --git a/clang/test/CodeGenCXX/debug-info-template-align.cpp b/clang/test/CodeGenCXX/debug-info-template-align.cpp new file mode 100644 index ..42fdb269a30b --- /dev/null +++ b/clang/test/CodeGenCXX/debug-info-template-align.cpp @@ -0,0 +1,14 @@ +// Test for debug info related to DW_AT_alignment attribute in the typedef operator +// Supported: -O0, standalone DI +// 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: DIDerivedType(tag: DW_TAG_typedef, {{.*}}, align: 512 + +typedef char __attribute__((__aligned__(64))) alchar; + +int main() { + alchar newChar; +} diff --git a/llvm/bindings/go/llvm/dibuilder.go b/llvm/bindings/go/llvm/dibuilder.go index e84536927160..e30a964beaf6 100644 --- a/llvm/bindings/go/llvm/dibuilder.go +++ b/llvm/bindings/go/llvm/dibuilder.go @@ -504,6 +504,7 @@ type DITypedef struct { FileMetadata Lineint Context Metadata + AlignInBits unit32 } // CreateTypedef creates typedef type debug metadata. @@ -518,6 +519,7 @@ func (d *DIBuilder) CreateTypedef(t DITypedef) Metadata { t.File.C, C.unsigned(t.Line), t.Context.C, +C.uint32_t(t.AlignInBits), ) return Metadata{C: result} } diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst index e85a85053fb9..c27f3bc8b692 100644 --- a/llvm/docs/ReleaseNotes.rst +++ b/llvm/docs/ReleaseNotes.rst @@ -166,6 +166,16 @@ Changes to the OCaml bindings Changes to the C API +* C DebugInfo API ``LLVMDIBuilderCreateTypedef`` is updated to include an extra +argument ``AlignInBits``, to facilitate / propagate specified Alignment information +present in a ``typedef`` to Debug information in LLVM IR. + + +Changes to the Go bindings +-- +* Go DebugInfo API ``CreateTypedef`` is updated to include an extra argument ``AlignInBits``, +to facilitate / propagate specified Alignment information present in a ``typedef`` +to Debug information in LLVM IR. Changes to the DAG infrastructure diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h index ab60b88a31f4..731f32741e19 100644 --- a/llvm/include/llvm-c/DebugInfo.h +++ b/llvm/include/llvm-c/DebugInfo.h @@ -874,7 +874,7 @@ LLVMMetadataRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, - LLVMMetadataRef Scope); + LLVMMetadataRef Scope, uint32_t AlignInBits); /** * Create debugging information entry to est
[clang] 6ef0158 - [DWARF5] Start emitting DW_AT_dwo_name when -gdwarf-5 is specified.
Author: Sourabh Singh Tomar Date: 2019-12-11T01:18:02+05:30 New Revision: 6ef01588f4d75ef43da4ed2a37ba7a8b8daab259 URL: https://github.com/llvm/llvm-project/commit/6ef01588f4d75ef43da4ed2a37ba7a8b8daab259 DIFF: https://github.com/llvm/llvm-project/commit/6ef01588f4d75ef43da4ed2a37ba7a8b8daab259.diff LOG: [DWARF5] Start emitting DW_AT_dwo_name when -gdwarf-5 is specified. Added: Modified: clang/test/CodeGen/split-debug-output.c clang/test/CodeGen/thinlto-split-dwarf.c llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp llvm/test/DebugInfo/X86/debug_addr.ll llvm/test/DebugInfo/X86/string-offsets-table.ll Removed: diff --git a/clang/test/CodeGen/split-debug-output.c b/clang/test/CodeGen/split-debug-output.c index 1507edd24849..19569f8d574b 100644 --- a/clang/test/CodeGen/split-debug-output.c +++ b/clang/test/CodeGen/split-debug-output.c @@ -1,7 +1,11 @@ // REQUIRES: x86-registered-target -// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -split-dwarf-file foo.dwo -split-dwarf-output %t -emit-obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck %s -// RUN: llvm-dwarfdump -debug-info %t | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -dwarf-version=4 -split-dwarf-file foo.dwo -split-dwarf-output %t -emit-obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck --check-prefix=DWARFv4 %s +// RUN: llvm-dwarfdump -debug-info %t | FileCheck --check-prefix=DWARFv4 %s + +// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -dwarf-version=5 -split-dwarf-file foo.dwo -split-dwarf-output %t -emit-obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck --check-prefix=DWARFv5 %s +// RUN: llvm-dwarfdump -debug-info %t | FileCheck --check-prefix=DWARFv5 %s int f() { return 0; } -// CHECK: DW_AT_GNU_dwo_name ("foo.dwo") +// DWARFv4: DW_AT_GNU_dwo_name ("foo.dwo") +// DWARFv5: DW_AT_dwo_name ("foo.dwo") diff --git a/clang/test/CodeGen/thinlto-split-dwarf.c b/clang/test/CodeGen/thinlto-split-dwarf.c index 60649b0881bb..419bd1320bb2 100644 --- a/clang/test/CodeGen/thinlto-split-dwarf.c +++ b/clang/test/CodeGen/thinlto-split-dwarf.c @@ -13,11 +13,31 @@ // RUN: -o %t.native.o -split-dwarf-file %t.file.dwo \ // RUN: -split-dwarf-output %t.output.dwo -x ir %t.o -// RUN: llvm-dwarfdump %t.native.o | FileCheck --check-prefix=O %s -// RUN: llvm-dwarfdump %t.output.dwo | FileCheck --check-prefix=DWO %s +// RUN: llvm-dwarfdump %t.native.o | FileCheck --check-prefix=DWARFv4-O %s +// RUN: llvm-dwarfdump %t.output.dwo | FileCheck --check-prefix=DWARFv4-DWO %s -// O: DW_AT_GNU_dwo_name ("{{.*}}.file.dwo") -// O-NOT: DW_TAG_subprogram -// DWO: DW_TAG_subprogram +// DWARFv4-O: DW_AT_GNU_dwo_name ("{{.*}}.file.dwo") +// DWARFv4-O-NOT: DW_TAG_subprogram +// DWARFv4-DWO: DW_TAG_subprogram + +// RUN: %clang_cc1 -debug-info-kind=limited -dwarf-version=5 -triple x86_64-unknown-linux-gnu \ +// RUN: -flto=thin -emit-llvm-bc \ +// RUN: -o %t.o %s + +// RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \ +// RUN: -o %t2.index \ +// RUN: -r=%t.o,main,px + +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \ +// RUN: -emit-obj -fthinlto-index=%t.o.thinlto.bc \ +// RUN: -o %t.native.o -dwarf-version=5 -split-dwarf-file %t.file.dwo \ +// RUN: -split-dwarf-output %t.output.dwo -x ir %t.o + +// RUN: llvm-dwarfdump %t.native.o | FileCheck --check-prefix=DWARFv5-O %s +// RUN: llvm-dwarfdump %t.output.dwo | FileCheck --check-prefix=DWARFv5-DWO %s + +// DWARFv5-O: DW_AT_dwo_name ("{{.*}}.file.dwo") +// DWARFv5-O-NOT: DW_TAG_subprogram +// DWARFv5-DWO: DW_TAG_subprogram int main() {} diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 89a0e350f8fe..f6039cc5bc00 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -856,10 +856,13 @@ void DwarfDebug::finishUnitAttributes(const DICompileUnit *DIUnit, // This CU is either a clang module DWO or a skeleton CU. NewCU.addUInt(Die, dwarf::DW_AT_GNU_dwo_id, dwarf::DW_FORM_data8, DIUnit->getDWOId()); -if (!DIUnit->getSplitDebugFilename().empty()) +if (!DIUnit->getSplitDebugFilename().empty()) { // This is a prefabricated skeleton CU. - NewCU.addString(Die, dwarf::DW_AT_GNU_dwo_name, - DIUnit->getSplitDebugFilename()); + dwarf::Attribute attrDWOName = getDwarfVersion() >= 5 + ? dwarf::DW_AT_dwo_name + : dwarf::DW_AT_GNU_dwo_name; + NewCU.addString(Die, attrDWOName, DIUnit->getSplitDebugFilename()); +} } } // Create new DwarfCompileUnit for the given metadata node with tag @@ -1101,10 +1104,13 @@ void DwarfDebug::finalizeModuleInfo() { bool HasSplitUnit = SkC
[clang] d82b6ba - Revert "[DWARF5] Start emitting DW_AT_dwo_name when -gdwarf-5 is specified."
Author: Sourabh Singh Tomar Date: 2019-12-11T01:20:40+05:30 New Revision: d82b6ba21b32ddf00af886b9160feef88211773e URL: https://github.com/llvm/llvm-project/commit/d82b6ba21b32ddf00af886b9160feef88211773e DIFF: https://github.com/llvm/llvm-project/commit/d82b6ba21b32ddf00af886b9160feef88211773e.diff LOG: Revert "[DWARF5] Start emitting DW_AT_dwo_name when -gdwarf-5 is specified." This reverts commit 6ef01588f4d75ef43da4ed2a37ba7a8b8daab259. Missing Differetial revision. Added: Modified: clang/test/CodeGen/split-debug-output.c clang/test/CodeGen/thinlto-split-dwarf.c llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp llvm/test/DebugInfo/X86/debug_addr.ll llvm/test/DebugInfo/X86/string-offsets-table.ll Removed: diff --git a/clang/test/CodeGen/split-debug-output.c b/clang/test/CodeGen/split-debug-output.c index 19569f8d574b..1507edd24849 100644 --- a/clang/test/CodeGen/split-debug-output.c +++ b/clang/test/CodeGen/split-debug-output.c @@ -1,11 +1,7 @@ // REQUIRES: x86-registered-target -// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -dwarf-version=4 -split-dwarf-file foo.dwo -split-dwarf-output %t -emit-obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck --check-prefix=DWARFv4 %s -// RUN: llvm-dwarfdump -debug-info %t | FileCheck --check-prefix=DWARFv4 %s - -// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -dwarf-version=5 -split-dwarf-file foo.dwo -split-dwarf-output %t -emit-obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck --check-prefix=DWARFv5 %s -// RUN: llvm-dwarfdump -debug-info %t | FileCheck --check-prefix=DWARFv5 %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -split-dwarf-file foo.dwo -split-dwarf-output %t -emit-obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck %s +// RUN: llvm-dwarfdump -debug-info %t | FileCheck %s int f() { return 0; } -// DWARFv4: DW_AT_GNU_dwo_name ("foo.dwo") -// DWARFv5: DW_AT_dwo_name ("foo.dwo") +// CHECK: DW_AT_GNU_dwo_name ("foo.dwo") diff --git a/clang/test/CodeGen/thinlto-split-dwarf.c b/clang/test/CodeGen/thinlto-split-dwarf.c index 419bd1320bb2..60649b0881bb 100644 --- a/clang/test/CodeGen/thinlto-split-dwarf.c +++ b/clang/test/CodeGen/thinlto-split-dwarf.c @@ -13,31 +13,11 @@ // RUN: -o %t.native.o -split-dwarf-file %t.file.dwo \ // RUN: -split-dwarf-output %t.output.dwo -x ir %t.o -// RUN: llvm-dwarfdump %t.native.o | FileCheck --check-prefix=DWARFv4-O %s -// RUN: llvm-dwarfdump %t.output.dwo | FileCheck --check-prefix=DWARFv4-DWO %s +// RUN: llvm-dwarfdump %t.native.o | FileCheck --check-prefix=O %s +// RUN: llvm-dwarfdump %t.output.dwo | FileCheck --check-prefix=DWO %s -// DWARFv4-O: DW_AT_GNU_dwo_name ("{{.*}}.file.dwo") -// DWARFv4-O-NOT: DW_TAG_subprogram -// DWARFv4-DWO: DW_TAG_subprogram - -// RUN: %clang_cc1 -debug-info-kind=limited -dwarf-version=5 -triple x86_64-unknown-linux-gnu \ -// RUN: -flto=thin -emit-llvm-bc \ -// RUN: -o %t.o %s - -// RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \ -// RUN: -o %t2.index \ -// RUN: -r=%t.o,main,px - -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \ -// RUN: -emit-obj -fthinlto-index=%t.o.thinlto.bc \ -// RUN: -o %t.native.o -dwarf-version=5 -split-dwarf-file %t.file.dwo \ -// RUN: -split-dwarf-output %t.output.dwo -x ir %t.o - -// RUN: llvm-dwarfdump %t.native.o | FileCheck --check-prefix=DWARFv5-O %s -// RUN: llvm-dwarfdump %t.output.dwo | FileCheck --check-prefix=DWARFv5-DWO %s - -// DWARFv5-O: DW_AT_dwo_name ("{{.*}}.file.dwo") -// DWARFv5-O-NOT: DW_TAG_subprogram -// DWARFv5-DWO: DW_TAG_subprogram +// O: DW_AT_GNU_dwo_name ("{{.*}}.file.dwo") +// O-NOT: DW_TAG_subprogram +// DWO: DW_TAG_subprogram int main() {} diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index f6039cc5bc00..89a0e350f8fe 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -856,13 +856,10 @@ void DwarfDebug::finishUnitAttributes(const DICompileUnit *DIUnit, // This CU is either a clang module DWO or a skeleton CU. NewCU.addUInt(Die, dwarf::DW_AT_GNU_dwo_id, dwarf::DW_FORM_data8, DIUnit->getDWOId()); -if (!DIUnit->getSplitDebugFilename().empty()) { +if (!DIUnit->getSplitDebugFilename().empty()) // This is a prefabricated skeleton CU. - dwarf::Attribute attrDWOName = getDwarfVersion() >= 5 - ? dwarf::DW_AT_dwo_name - : dwarf::DW_AT_GNU_dwo_name; - NewCU.addString(Die, attrDWOName, DIUnit->getSplitDebugFilename()); -} + NewCU.addString(Die, dwarf::DW_AT_GNU_dwo_name, + DIUnit->getSplitDebugFilename()); } } // Create new DwarfCompileUnit for the given metadata nod
[clang] fb4d8fe - Recommit "[DWARF5] Start emitting DW_AT_dwo_name when -gdwarf-5 is specified."
Author: Sourabh Singh Tomar Date: 2019-12-11T01:24:50+05:30 New Revision: fb4d8fe1a86232f4711c911e6feccce778e27afa URL: https://github.com/llvm/llvm-project/commit/fb4d8fe1a86232f4711c911e6feccce778e27afa DIFF: https://github.com/llvm/llvm-project/commit/fb4d8fe1a86232f4711c911e6feccce778e27afa.diff LOG: Recommit "[DWARF5] Start emitting DW_AT_dwo_name when -gdwarf-5 is specified." Reviewers: dblaikie, aprantl, probinson Tags: #debug-info #llvm Differential Revision: https://reviews.llvm.org/D71185 Added: Modified: clang/test/CodeGen/split-debug-output.c clang/test/CodeGen/thinlto-split-dwarf.c llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp llvm/test/DebugInfo/X86/debug_addr.ll llvm/test/DebugInfo/X86/string-offsets-table.ll Removed: diff --git a/clang/test/CodeGen/split-debug-output.c b/clang/test/CodeGen/split-debug-output.c index 1507edd24849..19569f8d574b 100644 --- a/clang/test/CodeGen/split-debug-output.c +++ b/clang/test/CodeGen/split-debug-output.c @@ -1,7 +1,11 @@ // REQUIRES: x86-registered-target -// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -split-dwarf-file foo.dwo -split-dwarf-output %t -emit-obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck %s -// RUN: llvm-dwarfdump -debug-info %t | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -dwarf-version=4 -split-dwarf-file foo.dwo -split-dwarf-output %t -emit-obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck --check-prefix=DWARFv4 %s +// RUN: llvm-dwarfdump -debug-info %t | FileCheck --check-prefix=DWARFv4 %s + +// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -dwarf-version=5 -split-dwarf-file foo.dwo -split-dwarf-output %t -emit-obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck --check-prefix=DWARFv5 %s +// RUN: llvm-dwarfdump -debug-info %t | FileCheck --check-prefix=DWARFv5 %s int f() { return 0; } -// CHECK: DW_AT_GNU_dwo_name ("foo.dwo") +// DWARFv4: DW_AT_GNU_dwo_name ("foo.dwo") +// DWARFv5: DW_AT_dwo_name ("foo.dwo") diff --git a/clang/test/CodeGen/thinlto-split-dwarf.c b/clang/test/CodeGen/thinlto-split-dwarf.c index 60649b0881bb..419bd1320bb2 100644 --- a/clang/test/CodeGen/thinlto-split-dwarf.c +++ b/clang/test/CodeGen/thinlto-split-dwarf.c @@ -13,11 +13,31 @@ // RUN: -o %t.native.o -split-dwarf-file %t.file.dwo \ // RUN: -split-dwarf-output %t.output.dwo -x ir %t.o -// RUN: llvm-dwarfdump %t.native.o | FileCheck --check-prefix=O %s -// RUN: llvm-dwarfdump %t.output.dwo | FileCheck --check-prefix=DWO %s +// RUN: llvm-dwarfdump %t.native.o | FileCheck --check-prefix=DWARFv4-O %s +// RUN: llvm-dwarfdump %t.output.dwo | FileCheck --check-prefix=DWARFv4-DWO %s -// O: DW_AT_GNU_dwo_name ("{{.*}}.file.dwo") -// O-NOT: DW_TAG_subprogram -// DWO: DW_TAG_subprogram +// DWARFv4-O: DW_AT_GNU_dwo_name ("{{.*}}.file.dwo") +// DWARFv4-O-NOT: DW_TAG_subprogram +// DWARFv4-DWO: DW_TAG_subprogram + +// RUN: %clang_cc1 -debug-info-kind=limited -dwarf-version=5 -triple x86_64-unknown-linux-gnu \ +// RUN: -flto=thin -emit-llvm-bc \ +// RUN: -o %t.o %s + +// RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \ +// RUN: -o %t2.index \ +// RUN: -r=%t.o,main,px + +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \ +// RUN: -emit-obj -fthinlto-index=%t.o.thinlto.bc \ +// RUN: -o %t.native.o -dwarf-version=5 -split-dwarf-file %t.file.dwo \ +// RUN: -split-dwarf-output %t.output.dwo -x ir %t.o + +// RUN: llvm-dwarfdump %t.native.o | FileCheck --check-prefix=DWARFv5-O %s +// RUN: llvm-dwarfdump %t.output.dwo | FileCheck --check-prefix=DWARFv5-DWO %s + +// DWARFv5-O: DW_AT_dwo_name ("{{.*}}.file.dwo") +// DWARFv5-O-NOT: DW_TAG_subprogram +// DWARFv5-DWO: DW_TAG_subprogram int main() {} diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 89a0e350f8fe..f6039cc5bc00 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -856,10 +856,13 @@ void DwarfDebug::finishUnitAttributes(const DICompileUnit *DIUnit, // This CU is either a clang module DWO or a skeleton CU. NewCU.addUInt(Die, dwarf::DW_AT_GNU_dwo_id, dwarf::DW_FORM_data8, DIUnit->getDWOId()); -if (!DIUnit->getSplitDebugFilename().empty()) +if (!DIUnit->getSplitDebugFilename().empty()) { // This is a prefabricated skeleton CU. - NewCU.addString(Die, dwarf::DW_AT_GNU_dwo_name, - DIUnit->getSplitDebugFilename()); + dwarf::Attribute attrDWOName = getDwarfVersion() >= 5 + ? dwarf::DW_AT_dwo_name + : dwarf::DW_AT_GNU_dwo_name; + NewCU.addString(Die, attrDWOName, DIUnit->getSplitDebugFilename()); +} } } // Create new DwarfCompile
[clang] c83602f - Recommit "[DWARF5][clang]: Added support for DebugInfo generation for auto return type for C++ member functions."
Author: Awanish Pandey Date: 2020-01-24T14:50:17+05:30 New Revision: c83602fdf51b2692e3bacb06bf861f20f74e987f URL: https://github.com/llvm/llvm-project/commit/c83602fdf51b2692e3bacb06bf861f20f74e987f DIFF: https://github.com/llvm/llvm-project/commit/c83602fdf51b2692e3bacb06bf861f20f74e987f.diff LOG: Recommit "[DWARF5][clang]: Added support for DebugInfo generation for auto return type for C++ member functions." Summary: This was reverted in e45fcfc3aa57bb237fd4fd694d0c257be66d5482 due to libcxx build failure. This revision addresses that case. Original commit message: This patch will provide support for auto return type for the C++ member functions. This patch includes clang side implementation of this feature. Patch by: Awanish Pandey Reviewers: dblaikie, aprantl, shafik, alok, SouraVX, jini.susan.george Reviewed by: dblaikie Differential Revision: https://reviews.llvm.org/D70524 Added: clang/test/CodeGenCXX/debug-info-auto-return.cpp Modified: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h Removed: diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index ffc3870c153b..fd2c61b9aea3 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -815,6 +815,10 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) { 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; @@ -1462,16 +1466,18 @@ void CGDebugInfo::CollectRecordFields( 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::DISubroutineType * +CGDebugInfo::getOrCreateInstanceMethodType(QualType ThisPtr, + const FunctionProtoType *Func, + llvm::DIFile *Unit, bool decl) { // Add "this" pointer. llvm::DITypeRefArray Args( cast(getOrCreateType(QualType(Func, 0), Unit)) @@ -1479,9 +1485,12 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType( assert(Args.size() && "Invalid number of arguments!"); SmallVector Elts; - // First element is always return type. For 'void' functions it is NULL. - Elts.push_back(Args[0]); + QualType temp = Func->getReturnType(); + if (temp->getTypeClass() == Type::Auto && decl) +Elts.push_back(CreateType(cast(temp))); + else +Elts.push_back(Args[0]); // "this" pointer is always first argument. const CXXRecordDecl *RD = ThisPtr->getPointeeCXXRecordDecl(); @@ -1540,7 +1549,7 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction( isa(Method) || isa(Method); StringRef MethodName = getFunctionName(Method); - llvm::DISubroutineType *MethodTy = getOrCreateMethodType(Method, Unit); + llvm::DISubroutineType *MethodTy = getOrCreateMethodType(Method, Unit, true); // Since a single ctor/dtor corresponds to multiple functions, it doesn't // make sense to give a single ctor/dtor a linkage name. @@ -2776,7 +2785,7 @@ llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty, return DBuilder.createMemberPointerType( getOrCreateInstanceMethodType( CXXMethodDecl::getThisType(FPT, Ty->getMostRecentCXXRecordDecl()), - FPT, U), + FPT, U, false), ClassType, Size, /*Align=*/0, Flags); } @@ -3551,7 +3560,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D, return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray(None)); if (const auto *Method = dyn_cast(D)) -return getOrCreateMethodType(Method, F); +return getOrCreateMethodType(Method, F, false); const auto *FTy = FnType->getAs(); CallingConv CC = FTy ? FTy->getCallConv() : CallingConv::CC_C; diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index 90e9a61ebe96..d9c6b4d79097 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -165,6 +165,7 @@ class CGDebugInfo { /// ivars and p