Skip to content

Commit ab699d7

Browse files
alokkrsharmaSouraVX
authored andcommitted
[DebugInfo] llvm rejects DWARF operator DW_OP_push_object_address
llvm rejects DWARF operator DW_OP_push_object_address.This DWARF operator is needed for Flang to support allocatable array. Summary: Currently llvm rejects DWARF operator DW_OP_push_object_address. below error is produced when llvm finds this operator. [..] invalid expression !DIExpression(151) warning: ignoring invalid debug info in pushobj.ll [..] There are some parts missing in support of this operator, need to be completed. Testing -added a unit testcase -check-debuginfo -check-llvm Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D79306
1 parent 454de99 commit ab699d7

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

llvm/docs/LangRef.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5102,6 +5102,9 @@ The current supported opcode vocabulary is limited:
51025102
signed offset of the specified register. The opcode is only generated by the
51035103
``AsmPrinter`` pass to describe call site parameter value which requires an
51045104
expression over two registers.
5105+
- ``DW_OP_push_object_address`` pushes the address of the object which can then
5106+
serve as a descriptor in subsequent calculation. This opcode can be used to
5107+
calculate bounds of fortran allocatable array which has array descriptors.
51055108

51065109
DWARF specifies three kinds of simple location descriptions: Register, memory,
51075110
and implicit location descriptions. Note that a location description is

llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ void DwarfExpression::addExpression(DIExpressionCursor &&ExprCursor,
451451
case dwarf::DW_OP_lit0:
452452
case dwarf::DW_OP_not:
453453
case dwarf::DW_OP_dup:
454+
case dwarf::DW_OP_push_object_address:
454455
emitOp(OpNum);
455456
break;
456457
case dwarf::DW_OP_deref:

llvm/lib/IR/DebugInfoMetadata.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,7 @@ bool DIExpression::isValid() const {
947947
case dwarf::DW_OP_dup:
948948
case dwarf::DW_OP_regx:
949949
case dwarf::DW_OP_bregx:
950+
case dwarf::DW_OP_push_object_address:
950951
break;
951952
}
952953
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
;; This test checks whether DWARF operator DW_OP_push_object_address
2+
;; is accepted and processed.
3+
4+
; RUN: %llc -mtriple=x86_64-unknown-linux-gnu %s -filetype=obj -o - | llvm-dwarfdump - | FileCheck %s
5+
6+
;; Test whether DW_OP_push_object_address is accepted.
7+
8+
; CHECK-LABEL: DW_TAG_variable
9+
; CHECK: DW_AT_location
10+
; CHECK-SAME: DW_OP_push_object_address
11+
12+
;; Below is the original test case this IR is generated from
13+
;;---------------------------
14+
;;int main() {
15+
;;int var;
16+
;;return var;
17+
;;}
18+
;;---------------------------
19+
;; step 1: generate IR using -g -O0 -S -emit-llvm
20+
;; step 2: insert DW_OP_push_object_address in dbg.declare instruction
21+
;; This is meaningless test case focused to test DW_OP_push_object_address.
22+
23+
; ModuleID = 'dwarfdump-pushobjectaddress.c'
24+
source_filename = "dwarfdump-pushobjectaddress.c"
25+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
26+
27+
; Function Attrs: noinline nounwind optnone uwtable
28+
define dso_local i32 @main() !dbg !7 {
29+
entry:
30+
%retval = alloca i32, align 4
31+
%var = alloca i32, align 4
32+
store i32 0, i32* %retval, align 4
33+
call void @llvm.dbg.declare(metadata i32* %var, metadata !11, metadata !DIExpression(DW_OP_push_object_address)), !dbg !12
34+
%0 = load i32, i32* %var, align 4, !dbg !13
35+
ret i32 %0, !dbg !14
36+
}
37+
38+
; Function Attrs: nounwind readnone speculatable willreturn
39+
declare void @llvm.dbg.declare(metadata, metadata, metadata)
40+
41+
!llvm.dbg.cu = !{!0}
42+
!llvm.module.flags = !{!3, !4, !5}
43+
!llvm.ident = !{!6}
44+
45+
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
46+
!1 = !DIFile(filename: "dwarfdump-pushobjectaddress.c", directory: "/dir")
47+
!2 = !{}
48+
!3 = !{i32 7, !"Dwarf Version", i32 4}
49+
!4 = !{i32 2, !"Debug Info Version", i32 3}
50+
!5 = !{i32 1, !"wchar_size", i32 4}
51+
!6 = !{!"clang version 11.0.0"}
52+
!7 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
53+
!8 = !DISubroutineType(types: !9)
54+
!9 = !{!10}
55+
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
56+
!11 = !DILocalVariable(name: "var", scope: !7, file: !1, line: 2, type: !10)
57+
!12 = !DILocation(line: 2, column: 5, scope: !7)
58+
!13 = !DILocation(line: 3, column: 8, scope: !7)
59+
!14 = !DILocation(line: 3, column: 1, scope: !7)

0 commit comments

Comments
 (0)