[llvm-branch-commits] [llvm] 975b64b - [docs] Release notes for IsDecl in DIModule.
Author: Chih-Ping Chen Date: 2021-01-04T07:03:34-05:00 New Revision: 975b64b29375cdfb3672fedee4216c6512672fbf URL: https://github.com/llvm/llvm-project/commit/975b64b29375cdfb3672fedee4216c6512672fbf DIFF: https://github.com/llvm/llvm-project/commit/975b64b29375cdfb3672fedee4216c6512672fbf.diff LOG: [docs] Release notes for IsDecl in DIModule. Please see https://reviews.llvm.org/D93462 for the actual code change. Differential Revision: https://reviews.llvm.org/D93558 Added: Modified: llvm/docs/ReleaseNotes.rst Removed: diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst index b77d054079a3..48fa42f5c930 100644 --- a/llvm/docs/ReleaseNotes.rst +++ b/llvm/docs/ReleaseNotes.rst @@ -169,6 +169,12 @@ Changes to the Debug Info During this release ... +* The DIModule metadata is extended with a field to indicate if it is a + module declaration. This extension enables the emission of debug info + for a Fortran 'use ' statement. For more information + on what the debug info entries should look like and how the debugger + can use them, please see test/DebugInfo/X86/dimodule-external-fortran.ll. + Changes to the LLVM tools - ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 5f75dcf - [DebugInfo] Support Fortran 'use ' statement.
Author: Chih-Ping Chen Date: 2020-12-18T13:10:57-05:00 New Revision: 5f75dcf5719f8ba2819b73109888175cf92fe253 URL: https://github.com/llvm/llvm-project/commit/5f75dcf5719f8ba2819b73109888175cf92fe253 DIFF: https://github.com/llvm/llvm-project/commit/5f75dcf5719f8ba2819b73109888175cf92fe253.diff LOG: [DebugInfo] Support Fortran 'use ' statement. The main change is to add a 'IsDecl' field to DIModule so that when IsDecl is set to true, the debug info entry generated for the module would be marked as a declaration. That way, the debugger would look up the definition of the module in the gloabl scope. Please see the comments in llvm/test/DebugInfo/X86/dimodule.ll for what the debug info entries would look like. Differential Revision: https://reviews.llvm.org/D93462 Added: llvm/test/Bitcode/DIModule-fortran-external-module.ll llvm/test/DebugInfo/X86/dimodule.ll Modified: 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/dimodule.ll llvm/unittests/IR/MetadataTest.cpp Removed: diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h index 11c6e9784cfa..e0238567f251 100644 --- a/llvm/include/llvm/IR/DIBuilder.h +++ b/llvm/include/llvm/IR/DIBuilder.h @@ -772,14 +772,18 @@ namespace llvm { ///definitions as they would appear on a command line. /// \param IncludePath The path to the module map file. /// \param APINotesFile The path to an API notes file for this module. -/// \param FileSource file of the module declaration. Used for -///Fortran modules. -/// \param LineNo Source line number of the module declaration. +/// \param FileSource file of the module. ///Used for Fortran modules. +/// \param LineNo Source line number of the module. +///Used for Fortran modules. +/// \param IsDecl This is a module declaration; default to false; +///when set to true, only Scope and Name are required +///as this entry is just a hint for the debugger to find +///the corresponding definition in the global scope. DIModule *createModule(DIScope *Scope, StringRef Name, StringRef ConfigurationMacros, StringRef IncludePath, StringRef APINotesFile = {}, DIFile *File = nullptr, - unsigned LineNo = 0); + unsigned LineNo = 0, bool IsDecl = false); /// This creates a descriptor for a lexical block with a new file /// attached. This merely extends the existing diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index 0ba4c09dc92f..94b3beb4effd 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -2297,49 +2297,52 @@ class DIModule : public DIScope { friend class LLVMContextImpl; friend class MDNode; unsigned LineNo; + bool IsDecl; DIModule(LLVMContext &Context, StorageType Storage, unsigned LineNo, - ArrayRef Ops) + bool IsDecl, ArrayRef Ops) : DIScope(Context, DIModuleKind, Storage, dwarf::DW_TAG_module, Ops), -LineNo(LineNo) {} +LineNo(LineNo), IsDecl(IsDecl) {} ~DIModule() = default; static DIModule *getImpl(LLVMContext &Context, DIFile *File, DIScope *Scope, StringRef Name, StringRef ConfigurationMacros, StringRef IncludePath, StringRef APINotesFile, - unsigned LineNo, StorageType Storage, + unsigned LineNo, bool IsDecl, StorageType Storage, bool ShouldCreate = true) { return getImpl(Context, File, Scope, getCanonicalMDString(Context, Name), getCanonicalMDString(Context, ConfigurationMacros), getCanonicalMDString(Context, IncludePath), - getCanonicalMDString(Context, APINotesFile), LineNo, Storage, - ShouldCreate); + getCanonicalMDString(Context, APINotesFile), LineNo, IsDecl, + Storage, ShouldCreate); } static DIModule *getImpl(LLVMContext &Context, Metadata *File, Metadata *Scope, MDString *Name, MDString *ConfigurationMacros, MDString *IncludePath, - MDString *APINotesFile, unsigned LineNo, +
[llvm-branch-commits] [llvm] 08c4b40 - Rename files with same (case insensitive) name
Author: Chih-Ping Chen Date: 2020-12-18T16:01:37-05:00 New Revision: 08c4b4054b3ded660fc87ccbaa9a6bc4e390f6ff URL: https://github.com/llvm/llvm-project/commit/08c4b4054b3ded660fc87ccbaa9a6bc4e390f6ff DIFF: https://github.com/llvm/llvm-project/commit/08c4b4054b3ded660fc87ccbaa9a6bc4e390f6ff.diff LOG: Rename files with same (case insensitive) name Patch by: Aditya Kumar. Differential Revision: https://reviews.llvm.org/D93559 Added: llvm/test/DebugInfo/X86/dimodule-external-fortran.ll Modified: Removed: llvm/test/DebugInfo/X86/dimodule.ll diff --git a/llvm/test/DebugInfo/X86/dimodule.ll b/llvm/test/DebugInfo/X86/dimodule-external-fortran.ll similarity index 100% rename from llvm/test/DebugInfo/X86/dimodule.ll rename to llvm/test/DebugInfo/X86/dimodule-external-fortran.ll ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 1f67247 - [DebugInfo] Add handling of stringLengthExp operand of DIStringType.
Author: Chih-Ping Chen Date: 2020-12-08T14:49:59-05:00 New Revision: 1f67247eea13f62f26de3b0eca3755ed8b3a2b8e URL: https://github.com/llvm/llvm-project/commit/1f67247eea13f62f26de3b0eca3755ed8b3a2b8e DIFF: https://github.com/llvm/llvm-project/commit/1f67247eea13f62f26de3b0eca3755ed8b3a2b8e.diff LOG: [DebugInfo] Add handling of stringLengthExp operand of DIStringType. This patch makes DWARF writer emit DW_AT_string_length using the stringLengthExp operand of DIStringType. This is part of the effort to add debug info support for Fortran deferred length strings. Also updated the tests to exercise the change. Differential Revision: https://reviews.llvm.org/D92412 Added: Modified: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/test/DebugInfo/X86/distringtype.ll llvm/test/DebugInfo/fortran-string-type.ll Removed: diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index a74ee0f736a4..b552a07c99c0 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -696,6 +696,15 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIStringType *STy) { if (DIVariable *Var = STy->getStringLength()) { if (auto *VarDIE = getDIE(Var)) addDIEEntry(Buffer, dwarf::DW_AT_string_length, *VarDIE); + } else if (DIExpression *Expr = STy->getStringLengthExp()) { +DIELoc *Loc = new (DIEValueAllocator) DIELoc; +DIEDwarfExpression DwarfExpr(*Asm, getCU(), *Loc); +// This is to describe the memory location of the +// length of a Fortran deferred length string, so +// lock it down as such. +DwarfExpr.setMemoryLocationKind(); +DwarfExpr.addExpression(Expr); +addBlock(Buffer, dwarf::DW_AT_string_length, DwarfExpr.finalize()); } else { uint64_t Size = STy->getSizeInBits() >> 3; addUInt(Buffer, dwarf::DW_AT_byte_size, None, Size); diff --git a/llvm/test/DebugInfo/X86/distringtype.ll b/llvm/test/DebugInfo/X86/distringtype.ll index 65fac64ae3b1..5d53de29f82d 100644 --- a/llvm/test/DebugInfo/X86/distringtype.ll +++ b/llvm/test/DebugInfo/X86/distringtype.ll @@ -1,17 +1,23 @@ ;; Test for !DIStringType.!DIStringType is used to construct a Fortran ;; CHARACTER intrinsic type, with a LEN type parameter where LEN is a ;; dynamic parameter as in a deferred-length CHARACTER. LLVM after -;; processing this !DIStringType metadata, generates DW_AT_string_length attribute. -;; !DIStringType(name: "character(*)", stringLength: !{{[0-9]+}}, -;; stringLengthExpression: !DIExpression(), size: 32) +;; processing !DIStringType metadata in either of the following forms, +;; generates DW_AT_string_length attribute +;; !DIStringType(name: "character(*)", stringLength: !{{[0-9]+}}) +;; !DIStringType(name: "character(*)", stringLengthExpr: !DIExpression(...)) ; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s ; CHECK: DW_TAG_string_type +; CHECK: DW_AT_name (".str.DEFERRED") +; CHECK-NEXT: DW_AT_string_length (DW_OP_push_object_address, DW_OP_plus_uconst 0x8) +; CHECK: DW_TAG_string_type ; CHECK: DW_AT_name ("character(*)!2") ; CHECK-NEXT: DW_AT_string_length -;; sample fortran testcase involving assumed length string type. +;; sample fortran testcase involving deferred and assumed length string types. ;; program assumedLength +;; character(len=:), allocatable :: deferred +;; allocate(character(10)::deferred) ;; call sub('Hello') ;; call sub('Goodbye') ;; contains @@ -22,111 +28,144 @@ ;; end subroutine sub ;; end program assumedLength +; ModuleID = 'distring.f90' +source_filename = "distring.f90" 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.struct_ul_MAIN__324 = type <{ i8* }> - -@.C327_MAIN_ = internal constant [7 x i8] c"Goodbye" -@.C326_MAIN_ = internal constant [5 x i8] c"Hello" -@.C306_MAIN_ = internal constant i32 0 -@.C336_assumedlength_sub = internal constant i32 14 -@.C306_assumedlength_sub = internal constant i32 0 -@.C307_assumedlength_sub = internal constant i64 0 -@.C331_assumedlength_sub = internal constant i32 6 -@.C329_assumedlength_sub = internal constant [8 x i8] c"test.f90" -@.C328_assumedlength_sub = internal constant i32 8 - -define void @MAIN_() !dbg !5 { -L.entry: - %.S_331 = alloca %struct.struct_ul_MAIN__324, align 8 - %0 = bitcast i32* @.C306_MAIN_ to i8*, !dbg !8 - %1 = bitcast void (...)* @fort_init to void (i8*, ...)*, !dbg !8 - call void (i8*, ...) %1(i8* %0), !dbg !8 - br label %L.LB1_335 - -L.LB1_335:; preds = %L.entry - %2 = bitcast [5 x i8]* @.C326_MAIN_ to i64*, !dbg !9 - %3 = bitcast %struct.struct_ul_MAIN__324* %.S_331 to i64*, !dbg !9