Skip to content

Commit

Permalink
[DebugInfo][test] Fix tests for LLVM 19 compatibility
Browse files Browse the repository at this point in the history
Upstream LLVM has eliminated debug intrinsics like @llvm.dbg.value()
and @llvm.dbg.declare(), and replaced them with DPValue objects that
are printed as #dbg_value() and #dbg_declare(). This patch modifies
the FileCheck patterns in the tests to match, and make them require
the "llvm-19" feature.
  • Loading branch information
bryanpkc committed Oct 2, 2024
1 parent 291f7cc commit 28d23db
Show file tree
Hide file tree
Showing 17 changed files with 261 additions and 177 deletions.
27 changes: 16 additions & 11 deletions test/debug_info/allocatable_arr_param.f90
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
!RUN: %flang -gdwarf-4 -S -emit-llvm %s -o - | FileCheck %s

!CHECK-LABEL: define void @callee_
!CHECK: call void @llvm.dbg.declare(metadata ptr %"array$p", metadata [[DLOC:![0-9]+]]
!CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %"array$p", metadata [[ALLOCATED:![0-9]+]]
!CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %"array$sd", metadata [[ARRAY:![0-9]+]], metadata !DIExpression())
!CHECK: [[ARRAY]] = !DILocalVariable(name: "array",
!CHECK-SAME: arg: 2,
!CHECK-SAME: type: [[TYPE:![0-9]+]]
!CHECK: [[TYPE]] = !DICompositeType(tag: DW_TAG_array_type,
!CHECK-SAME: dataLocation: [[DLOC]], allocated: [[ALLOCATED]]
! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
! See https://llvm.org/LICENSE.txt for license information.
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

! REQUIRES: llvm-19
! RUN: %flang -gdwarf-4 -S -emit-llvm %s -o - | FileCheck %s

! CHECK-LABEL: define void @callee_
! CHECK: #dbg_declare(ptr %"array$p", [[DLOC:![0-9]+]]
! CHECK-NEXT: #dbg_declare(ptr %"array$p", [[ALLOCATED:![0-9]+]]
! CHECK-NEXT: #dbg_declare(ptr %"array$sd", [[ARRAY:![0-9]+]], !DIExpression()
! CHECK: [[ARRAY]] = !DILocalVariable(name: "array",
! CHECK-SAME: arg: 2,
! CHECK-SAME: type: [[TYPE:![0-9]+]]
! CHECK: [[TYPE]] = !DICompositeType(tag: DW_TAG_array_type,
! CHECK-SAME: dataLocation: [[DLOC]], allocated: [[ALLOCATED]]

subroutine callee (array)
integer, allocatable :: array(:, :)
Expand Down
57 changes: 34 additions & 23 deletions test/debug_info/assumed_rank.f90
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
!Check debug info generation for assumed rank arrays with DWARF5 and lower.
! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
! See https://llvm.org/LICENSE.txt for license information.
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

!RUN: %flang -gdwarf-4 -S -emit-llvm %s -o - | FileCheck %s --check-prefix=DWARF4
!RUN: %flang -gdwarf-5 -S -emit-llvm %s -o - | FileCheck %s --check-prefix=DWARF5
! REQUIRES: llvm-19
! RUN: %flang -gdwarf-4 -S -emit-llvm %s -o - | FileCheck %s --check-prefix=DWARF4
! RUN: %flang -gdwarf-5 -S -emit-llvm %s -o - | FileCheck %s --check-prefix=DWARF5

!DWARF4: call void @llvm.dbg.value(metadata ptr %ararray, metadata [[DLOC:![0-9]+]], metadata !DIExpression())
!DWARF4: !DILocalVariable(name: "ararray"
!DWARF4-SAME: arg: 2
!DWARF4-SAME: type: [[ARTYPE:![0-9]+]])
!DWARF4: [[ARTYPE]] = !DICompositeType(tag: DW_TAG_array_type, baseType: !{{[0-9]+}}, size: {{[0-9]+}}, align: {{[0-9]+}}, elements: [[ELEMS:![0-9]+]], dataLocation: [[DLOC:![0-9]+]])
!DWARF4: [[ELEMS]] = !{[[ELEM1:![0-9]+]], [[ELEM2:![0-9]+]], [[ELEM3:![0-9]+]], [[ELEM4:![0-9]+]], [[ELEM5:![0-9]+]], [[ELEM6:![0-9]+]], [[ELEM7:![0-9]+]]}
!DWARF4: [[ELEM1]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 80, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 120, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 112, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
!DWARF4: [[ELEM2]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 128, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 168, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 160, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
!DWARF4: [[ELEM3]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 176, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 216, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 208, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
!DWARF4: [[ELEM4]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 224, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 264, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 256, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
!DWARF4: [[ELEM5]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 272, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 312, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 304, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
!DWARF4: [[ELEM6]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 320, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 360, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 352, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
!DWARF4: [[ELEM7]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 368, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 408, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 400, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
! Check debug info generation for assumed rank arrays with DWARF5 and lower.


!DWARF5: call void @llvm.dbg.value(metadata ptr %ararray, metadata [[DLOC:![0-9]+]], metadata !DIExpression())
!DWARF5: !DILocalVariable(name: "ararray"
!DWARF5-SAME: arg: 2
!DWARF5-SAME: type: [[ARTYPE:![0-9]+]])
!DWARF5: [[ARTYPE]] = !DICompositeType(tag: DW_TAG_array_type, baseType: !{{[0-9]+}}, size: {{[0-9]+}}, align: {{[0-9]+}}, elements: [[ELEMS:![0-9]+]], dataLocation: [[DLOC:![0-9]+]], rank: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_constu, 7, DW_OP_and))
!DWARF5: [[ELEMS]] = !{[[ELEM1:![0-9]+]]}
!DWARF5: [[ELEM1]] = !DIGenericSubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_over, DW_OP_constu, 48, DW_OP_mul, DW_OP_plus_uconst, 80, DW_OP_plus, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_over, DW_OP_constu, 48, DW_OP_mul, DW_OP_plus_uconst, 120, DW_OP_plus, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_over, DW_OP_constu, 48, DW_OP_mul, DW_OP_plus_uconst, 112, DW_OP_plus, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
! DWARF4: #dbg_value(ptr %ararray, [[DLOC:![0-9]+]], !DIExpression()
! DWARF4: distinct !DISubprogram(name: "sub"
! DWARF4-SAME: retainedNodes: [[RETAINS:![0-9]+]]
! DWARF4: [[RETAINS]] = !{{{![0-9]+}}, [[DLOC:![0-9]+]]}
! DWARF4: [[DLOC]] = !DILocalVariable(name: "ararray",
! DWARF4-SAME: arg: 2,
! DWARF4-SAME: type: [[ARTYPE:![0-9]+]])
! DWARF4: [[ARTYPE]] = !DICompositeType(tag: DW_TAG_array_type, baseType: !{{[0-9]+}}, size: {{[0-9]+}}, align: {{[0-9]+}}, elements: [[ELEMS:![0-9]+]], dataLocation: [[DLOC:![0-9]+]])
! DWARF4: [[ELEMS]] = !{[[ELEM1:![0-9]+]], [[ELEM2:![0-9]+]], [[ELEM3:![0-9]+]], [[ELEM4:![0-9]+]], [[ELEM5:![0-9]+]], [[ELEM6:![0-9]+]], [[ELEM7:![0-9]+]]}
! DWARF4: [[ELEM1]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 80, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 120, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 112, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
! DWARF4: [[ELEM2]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 128, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 168, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 160, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
! DWARF4: [[ELEM3]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 176, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 216, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 208, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
! DWARF4: [[ELEM4]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 224, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 264, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 256, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
! DWARF4: [[ELEM5]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 272, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 312, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 304, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
! DWARF4: [[ELEM6]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 320, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 360, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 352, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
! DWARF4: [[ELEM7]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 368, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 408, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 400, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))

! DWARF5: #dbg_value(ptr %ararray, [[DLOC:![0-9]+]], !DIExpression()
! DWARF5: distinct !DISubprogram(name: "sub"
! DWARF5-SAME: retainedNodes: [[RETAINS:![0-9]+]]
! DWARF5: [[RETAINS]] = !{{{![0-9]+}}, [[DLOC:![0-9]+]]}
! DWARF5: [[DLOC]] = !DILocalVariable(name: "ararray",
! DWARF5-SAME: arg: 2,
! DWARF5-SAME: type: [[ARTYPE:![0-9]+]])
! DWARF5: [[ARTYPE]] = !DICompositeType(tag: DW_TAG_array_type, baseType: !{{[0-9]+}}, size: {{[0-9]+}}, align: {{[0-9]+}}, elements: [[ELEMS:![0-9]+]], dataLocation: [[DLOC:![0-9]+]], rank: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_constu, 7, DW_OP_and))
! DWARF5: [[ELEMS]] = !{[[ELEM1:![0-9]+]]}
! DWARF5: [[ELEM1]] = !DIGenericSubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_over, DW_OP_constu, 48, DW_OP_mul, DW_OP_plus_uconst, 80, DW_OP_plus, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_over, DW_OP_constu, 48, DW_OP_mul, DW_OP_plus_uconst, 120, DW_OP_plus, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_over, DW_OP_constu, 48, DW_OP_mul, DW_OP_plus_uconst, 112, DW_OP_plus, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))

subroutine sub(ararray)
real :: ararray(..)
Expand Down
29 changes: 17 additions & 12 deletions test/debug_info/assumed_shape.f90
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
!RUN: %flang -g -S -emit-llvm %s -o - | FileCheck %s
! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
! See https://llvm.org/LICENSE.txt for license information.
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

!CHECK: call void @llvm.dbg.declare(metadata ptr %assume, metadata [[ASSUME:![0-9]+]], metadata !DIExpression())
!CHECK: [[TYPE:![0-9]+]] = !DICompositeType(tag: DW_TAG_array_type, baseType: {{![0-9]+}}, size: 32, align: 32, elements: [[ELEMS:![0-9]+]])
!CHECK: [[ELEMS]] = !{[[ELEM1:![0-9]+]], [[ELEM2:![0-9]+]], [[ELEM3:![0-9]+]], [[ELEM4:![0-9]+]]
!CHECK: [[ELEM1]] = !DISubrange(lowerBound: 1, upperBound: 5)
!CHECK: [[ELEM2]] = !DISubrange(lowerBound: 1, upperBound: [[N1:![0-9]+]])
!CHECK: [[N1]] = distinct !DILocalVariable
!CHECK: [[ELEM3]] = !DISubrange(lowerBound: [[N2:![0-9]+]], upperBound: 9)
!CHECK: [[N2]] = distinct !DILocalVariable
!CHECK: [[ELEM4]] = !DISubrange(lowerBound: [[N3:![0-9]+]], upperBound: [[N4:![0-9]+]])
!CHECK: [[N3]] = distinct !DILocalVariable
!CHECK: [[N4]] = distinct !DILocalVariable
! REQUIRES: llvm-19
! RUN: %flang -g -S -emit-llvm %s -o - | FileCheck %s

! CHECK: #dbg_declare(ptr %assume, [[ASSUME:![0-9]+]], !DIExpression()
! CHECK: [[TYPE:![0-9]+]] = !DICompositeType(tag: DW_TAG_array_type, baseType: {{![0-9]+}}, size: 32, align: 32, elements: [[ELEMS:![0-9]+]])
! CHECK: [[ELEMS]] = !{[[ELEM1:![0-9]+]], [[ELEM2:![0-9]+]], [[ELEM3:![0-9]+]], [[ELEM4:![0-9]+]]
! CHECK: [[ELEM1]] = !DISubrange(lowerBound: 1, upperBound: 5)
! CHECK: [[ELEM2]] = !DISubrange(lowerBound: 1, upperBound: [[N1:![0-9]+]])
! CHECK: [[N1]] = distinct !DILocalVariable
! CHECK: [[ELEM3]] = !DISubrange(lowerBound: [[N2:![0-9]+]], upperBound: 9)
! CHECK: [[N2]] = distinct !DILocalVariable
! CHECK: [[ELEM4]] = !DISubrange(lowerBound: [[N3:![0-9]+]], upperBound: [[N4:![0-9]+]])
! CHECK: [[N3]] = distinct !DILocalVariable
! CHECK: [[N4]] = distinct !DILocalVariable
subroutine sub(assume,n1,n2,n3,n4)
integer(kind=4) :: assume(5,n1,n2:9,n3:n4)
assume(1,1,1,1) = 7
Expand Down
29 changes: 17 additions & 12 deletions test/debug_info/assumed_shape_non_contiguous.f90
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
!RUN: %flang -g -S -emit-llvm %s -o - | FileCheck %s

!CHECK: call void @llvm.dbg.value(metadata ptr %array, metadata [[ARRAYDL:![0-9]+]], metadata !DIExpression())
!CHECK: call void @llvm.dbg.declare(metadata ptr %"array$sd", metadata [[ARRAY:![0-9]+]], metadata !DIExpression())
!CHECK-LABEL: distinct !DICompileUnit(language: DW_LANG_Fortran90,
!CHECK: [[ARRAY]] = !DILocalVariable(name: "array"
!CHECK-SAME: arg: 3
!CHECK-SAME: type: [[TYPE:![0-9]+]])
!CHECK: [[TYPE]] = !DICompositeType(tag: DW_TAG_array_type, baseType: {{![0-9]+}}, size: 32, align: 32, elements: [[ELEM:![0-9]+]], dataLocation: [[ARRAYDL]])
!CHECK: [[ELEM]] = !{[[ELEM1:![0-9]+]], [[ELEM2:![0-9]+]]}
!CHECK: [[ELEM1]] = !DISubrange(count: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 88, DW_OP_deref), lowerBound: 1, stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 112, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
!CHECK: [[ELEM2]] = !DISubrange(count: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 136, DW_OP_deref), lowerBound: 1, stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 160, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
! See https://llvm.org/LICENSE.txt for license information.
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

! REQUIRES: llvm-19
! RUN: %flang -g -S -emit-llvm %s -o - | FileCheck %s

! CHECK: #dbg_value(ptr %array, [[ARRAYDL:![0-9]+]], !DIExpression()
! CHECK: #dbg_declare(ptr %"array$sd", [[ARRAY:![0-9]+]], !DIExpression()
! CHECK-LABEL: distinct !DICompileUnit(language: DW_LANG_Fortran90,
! CHECK: [[ARRAY]] = !DILocalVariable(name: "array"
! CHECK-SAME: arg: 3
! CHECK-SAME: type: [[TYPE:![0-9]+]])
! CHECK: [[TYPE]] = !DICompositeType(tag: DW_TAG_array_type, baseType: {{![0-9]+}}, size: 32, align: 32, elements: [[ELEM:![0-9]+]], dataLocation: [[ARRAYDL]])
! CHECK: [[ELEM]] = !{[[ELEM1:![0-9]+]], [[ELEM2:![0-9]+]]}
! CHECK: [[ELEM1]] = !DISubrange(count: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 88, DW_OP_deref), lowerBound: 1, stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 112, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))
! CHECK: [[ELEM2]] = !DISubrange(count: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 136, DW_OP_deref), lowerBound: 1, stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 160, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_mul))

subroutine show (message, array)
character (len=*) :: message
Expand Down
33 changes: 19 additions & 14 deletions test/debug_info/assumed_size_array.f90
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
!RUN: %flang -g -S -emit-llvm %s -o - | FileCheck %s
! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
! See https://llvm.org/LICENSE.txt for license information.
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

!CHECK: call void @llvm.dbg.declare(metadata ptr %array1, metadata [[ARRAY1:![0-9]+]], metadata !DIExpression())
!CHECK: call void @llvm.dbg.declare(metadata ptr %array2, metadata [[ARRAY2:![0-9]+]], metadata !DIExpression())
!CHECK: [[TYPE1:![0-9]+]] = !DICompositeType(tag: DW_TAG_array_type, baseType: {{![0-9]+}}, align: 32, elements: [[ELEMS1:![0-9]+]])
!CHECK: [[ELEMS1]] = !{[[ELEM11:![0-9]+]]}
!CHECK: [[ELEM11]] = !DISubrange(lowerBound: 1)
!CHECK: [[TYPE2:![0-9]+]] = !DICompositeType(tag: DW_TAG_array_type, baseType: {{![0-9]+}}, align: 32, elements: [[ELEMS2:![0-9]+]])
!CHECK: [[ELEMS2]] = !{[[ELEM21:![0-9]+]], [[ELEM22:![0-9]+]]}
!CHECK: [[ELEM21]] = !DISubrange(lowerBound: 4, upperBound: 9)
!CHECK: [[ELEM22]] = !DISubrange(lowerBound: 10)
!CHECK: [[ARRAY1]] = !DILocalVariable(name: "array1"
!CHECK-SAME: type: [[TYPE1]]
!CHECK: [[ARRAY2]] = !DILocalVariable(name: "array2"
!CHECK-SAME: type: [[TYPE2]]
! REQUIRES: llvm-19
! RUN: %flang -g -S -emit-llvm %s -o - | FileCheck %s

! CHECK: #dbg_declare(ptr %array1, [[ARRAY1:![0-9]+]], !DIExpression()
! CHECK: #dbg_declare(ptr %array2, [[ARRAY2:![0-9]+]], !DIExpression()
! CHECK: [[TYPE1:![0-9]+]] = !DICompositeType(tag: DW_TAG_array_type, baseType: {{![0-9]+}}, align: 32, elements: [[ELEMS1:![0-9]+]])
! CHECK: [[ELEMS1]] = !{[[ELEM11:![0-9]+]]}
! CHECK: [[ELEM11]] = !DISubrange(lowerBound: 1)
! CHECK: [[TYPE2:![0-9]+]] = !DICompositeType(tag: DW_TAG_array_type, baseType: {{![0-9]+}}, align: 32, elements: [[ELEMS2:![0-9]+]])
! CHECK: [[ELEMS2]] = !{[[ELEM21:![0-9]+]], [[ELEM22:![0-9]+]]}
! CHECK: [[ELEM21]] = !DISubrange(lowerBound: 4, upperBound: 9)
! CHECK: [[ELEM22]] = !DISubrange(lowerBound: 10)
! CHECK: [[ARRAY1]] = !DILocalVariable(name: "array1"
! CHECK-SAME: type: [[TYPE1]]
! CHECK: [[ARRAY2]] = !DILocalVariable(name: "array2"
! CHECK-SAME: type: [[TYPE2]]
subroutine sub (array1, array2)
integer :: array1 (*)
integer :: array2 (4:9, 10:*)
Expand Down
36 changes: 22 additions & 14 deletions test/debug_info/byval-name.f90
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
!RUN: %flang -g -S -emit-llvm %s -o - | FileCheck %s
! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
! See https://llvm.org/LICENSE.txt for license information.
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

!Verify the IR contains _V_ (flang)convention naming and the
! operation using them are well formed.
!CHECK: sub_(i32 [[PREFIXED_ARG_NAME:%_V_arg_abc.arg]])
!CHECK: [[PREFIXED_LOCAL_NAME:%_V_arg_abc.addr]] = alloca i32, align 4
!CHECK: call void @llvm.dbg.declare(metadata ptr [[PREFIXED_LOCAL_NAME]]
!CHECK: store i32 [[PREFIXED_ARG_NAME]], ptr [[PREFIXED_LOCAL_NAME]], align 4
! REQUIRES: llvm-19
! RUN: %flang -g -S -emit-llvm %s -o - | FileCheck %s

!Verify the DebugInfo metadata contains prefix _V_ truncated names.
!CHECK: DILocalVariable(name: "arg_abc"
!CHECK-NOT: DILocalVariable(name: "_V_arg_abc"
! Verify that the IR contains "_V_" (Flang's naming convention for byval
! parameters) and that the operation using them are well-formed.

! CHECK: sub_(i32 [[PREFIXED_ARG_NAME:%_V_arg_abc.arg]])
! CHECK: [[PREFIXED_LOCAL_NAME:%_V_arg_abc.addr]] = alloca i32, align 4
! CHECK: #dbg_declare(ptr [[PREFIXED_LOCAL_NAME]]
! CHECK: store i32 [[PREFIXED_ARG_NAME]], ptr [[PREFIXED_LOCAL_NAME]], align 4

! Verify that the names in the DebugInfo metadata have dropped the "_V_" prefix.

! CHECK-NOT: DILocalVariable(name: "_V_arg_abc"
! CHECK-COUNT-2: DILocalVariable(name: "arg_abc"
! CHECK-NOT: DILocalVariable(name: "_V_arg_abc"

subroutine sub(arg_abc)
integer,value :: arg_abc
integer :: abc_local
abc_local = arg_abc
print*, arg_abc
integer, value :: arg_abc
integer :: abc_local
abc_local = arg_abc
print *, arg_abc
end subroutine
Loading

0 comments on commit 28d23db

Please sign in to comment.