mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-28 04:56:06 +00:00

RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 Fixed PR51501 (tests from D112337). 1. Reuse of DISubprogram's 'retainedNodes' to track other function-local entities together with local variables and labels (this patch cares about function-local import while D144006 and D144008 use the same approach for local types and static variables). So, effectively this patch moves ownership of tracking local import from DICompileUnit's 'imports' field to DISubprogram's 'retainedNodes' and adjusts DWARF emitter for the new layout. The old layout is considered unsupported (DwarfDebug would assert on such debug metadata). DICompileUnit's 'imports' field is supposed to track global imported declarations as it does before. This addresses various FIXMEs and simplifies the next part of the patch. 2. Postpone emission of function-local imported entities from `DwarfDebug::endFunctionImpl()` to `DwarfDebug::endModule()`. While in `DwarfDebug::endFunctionImpl()` we do not have all the information about a parent subprogram or a referring subprogram (whether a subprogram inlined or not), so we can't guarantee we emit an imported entity correctly and place it in a proper subprogram tree. So now, we just gather needed details about the import itself and its parent entity (either a Subprogram or a LexicalBlock) during processing in `DwarfDebug::endFunctionImpl()`, but all the real work is done in `DwarfDebug::endModule()` when we have all the required information to make proper emission. Authored-by: Kristina Bessonova <kbessonova@accesssoftek.com> Differential Revision: https://reviews.llvm.org/D144004
106 lines
4.4 KiB
LLVM
106 lines
4.4 KiB
LLVM
;; This test checks processing of DIImportedEntity with elements field.
|
|
; REQUIRES: x86_64-linux
|
|
|
|
; RUN: llc %s -filetype=obj -o - | llvm-dwarfdump - | FileCheck %s
|
|
|
|
; CHECK: [[MYMOD:0x[0-9a-f]+]]: DW_TAG_module
|
|
; CHECK: DW_AT_name ("mymod")
|
|
; CHECK: [[VAR1:0x[0-9a-f]+]]: DW_TAG_variable
|
|
; CHECK: DW_AT_name ("var1")
|
|
|
|
; CHECK: DW_TAG_subprogram
|
|
; CHECK: DW_AT_name ("main")
|
|
; CHECK: DW_TAG_subprogram
|
|
; CHECK: DW_AT_name ("use_renamed")
|
|
; CHECK: DW_TAG_imported_module
|
|
; CHECK: DW_AT_import ([[MYMOD]])
|
|
; CHECK: DW_TAG_imported_declaration
|
|
; CHECK: DW_AT_import ([[VAR1]])
|
|
; CHECK: DW_AT_name ("var4")
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;;This test case is generated from
|
|
;;module mymod
|
|
;; integer :: var1 = 11
|
|
;; integer :: var2 = 12
|
|
;; integer :: var3 = 13
|
|
;;end module mymod
|
|
;;
|
|
;;Program main
|
|
;; call use_renamed()
|
|
;; contains
|
|
;; subroutine use_renamed()
|
|
;; use mymod, var4 => var1
|
|
;; print *, var4
|
|
;; end subroutine use_renamed
|
|
;;end program main
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; ModuleID = 'DIImportedEntity_elements.ll'
|
|
source_filename = "/tmp/usemodulealias.ll"
|
|
|
|
%struct_mymod_8_ = type <{ [12 x i8] }>
|
|
%struct.struct_ul_MAIN__348 = type { ptr }
|
|
|
|
@_mymod_8_ = global %struct_mymod_8_ <{ [12 x i8] c"\0B\00\00\00\0C\00\00\00\0D\00\00\00" }>, align 64, !dbg !0, !dbg !7, !dbg !10
|
|
@.C330_MAIN_ = internal constant i32 0
|
|
@.C364_main_use_renamed = internal constant i32 25
|
|
@.C330_main_use_renamed = internal constant i32 0
|
|
@.C331_main_use_renamed = internal constant i64 0
|
|
@.C359_main_use_renamed = internal constant i32 6
|
|
@.C357_main_use_renamed = internal constant [18 x i8] c"usemodulealias.f90"
|
|
@.C352_main_use_renamed = internal constant i32 12
|
|
|
|
define i32 @mymod_() {
|
|
.L.entry:
|
|
ret i32 undef
|
|
}
|
|
|
|
define void @MAIN_() !dbg !15 {
|
|
L.entry:
|
|
%.S0000_353 = alloca %struct.struct_ul_MAIN__348, align 8
|
|
call void (ptr, ...) @fort_init(ptr @.C330_MAIN_)
|
|
br label %L.LB2_357
|
|
|
|
L.LB2_357: ; preds = %L.entry
|
|
call void @main_use_renamed(ptr %.S0000_353), !dbg !23
|
|
ret void, !dbg !24
|
|
}
|
|
|
|
define internal void @main_use_renamed(ptr noalias %.S0000) !dbg !14 {
|
|
L.entry:
|
|
ret void, !dbg !25
|
|
}
|
|
|
|
declare void @fort_init(...)
|
|
|
|
!llvm.module.flags = !{!21, !22}
|
|
!llvm.dbg.cu = !{!4}
|
|
|
|
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
|
|
!1 = distinct !DIGlobalVariable(name: "var1", scope: !2, file: !3, line: 2, type: !9, isLocal: false, isDefinition: true)
|
|
!2 = !DIModule(scope: !4, name: "mymod", file: !3, line: 1)
|
|
!3 = !DIFile(filename: "DIImportedEntity_elements.f90", directory: "/tmp")
|
|
!4 = distinct !DICompileUnit(language: DW_LANG_Fortran90, file: !3, producer: " F90 Flang - 1.5 2017-05-01", isOptimized: false, flags: "'+flang usemodulealias.f90 -g -S -emit-llvm'", runtimeVersion: 0, emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, nameTableKind: None)
|
|
!5 = !{}
|
|
!6 = !{!0, !7, !10}
|
|
!7 = !DIGlobalVariableExpression(var: !8, expr: !DIExpression(DW_OP_plus_uconst, 4))
|
|
!8 = distinct !DIGlobalVariable(name: "var2", scope: !2, file: !3, line: 3, type: !9, isLocal: false, isDefinition: true)
|
|
!9 = !DIBasicType(name: "integer", size: 32, align: 32, encoding: DW_ATE_signed)
|
|
!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression(DW_OP_plus_uconst, 8))
|
|
!11 = distinct !DIGlobalVariable(name: "var3", scope: !2, file: !3, line: 4, type: !9, isLocal: false, isDefinition: true)
|
|
!12 = !{!13}
|
|
!13 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !14, entity: !2, file: !3, line: 10, elements: !19)
|
|
!14 = distinct !DISubprogram(name: "use_renamed", scope: !15, file: !3, line: 10, type: !18, scopeLine: 10, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !4, retainedNodes: !12)
|
|
!15 = distinct !DISubprogram(name: "main", scope: !4, file: !3, line: 7, type: !16, scopeLine: 7, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, unit: !4)
|
|
!16 = !DISubroutineType(cc: DW_CC_program, types: !17)
|
|
!17 = !{null}
|
|
!18 = !DISubroutineType(types: !17)
|
|
!19 = !{!20}
|
|
!20 = !DIImportedEntity(tag: DW_TAG_imported_declaration, name: "var4", scope: !14, entity: !1, file: !3, line: 10)
|
|
!21 = !{i32 2, !"Dwarf Version", i32 4}
|
|
!22 = !{i32 2, !"Debug Info Version", i32 3}
|
|
!23 = !DILocation(line: 8, column: 1, scope: !15)
|
|
!24 = !DILocation(line: 9, column: 1, scope: !15)
|
|
!25 = !DILocation(line: 13, column: 1, scope: !14)
|