Skip to content

Commit 0c31a32

Browse files
RamNalamothumemfrob
authored andcommitted
[MCAsmInfo] Support UsesCFIForDebug for targets with no exception handling
This change enables emitting CFI unwind information for debugging purpose for targets with MCAsmInfo::ExceptionsType == ExceptionHandling::None. Currently generating CFI unwind information is entangled with supporting the exceptions, even when AsmPrinter explicitly recognizes that the unwind tables are being generated as debug information. In fact, the unwind information is not generated even if we specify --force-dwarf-frame-section, unless exceptions are enabled. The LIT test llvm/test/CodeGen/AMDGPU/debug_frame.ll demonstrates this behavior. Enable this option for AMDGPU to prepare for future patches which add complete CFI support. Reviewed By: dblaikie, MaskRay Differential Revision: https://reviews.llvm.org/D78778
1 parent 31e67e4 commit 0c31a32

File tree

11 files changed

+140
-17
lines changed

11 files changed

+140
-17
lines changed

llvm/include/llvm/CodeGen/AsmPrinter.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,12 @@ class AsmPrinter : public MachineFunctionPass {
375375

376376
bool needsSEHMoves();
377377

378+
/// Since emitting CFI unwind information is entangled with supporting the
379+
/// exceptions, this returns true for platforms which use CFI unwind
380+
/// information for debugging purpose when
381+
/// `MCAsmInfo::ExceptionsType == ExceptionHandling::None`.
382+
bool needsCFIForDebug() const;
383+
378384
/// Print to the current output stream assembly representations of the
379385
/// constants in the constant pool MCP. This is used to print out constants
380386
/// which have been "spilled to memory" by the code generator.

llvm/include/llvm/MC/MCAsmInfo.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,10 @@ class MCAsmInfo {
425425
/// Exception handling format for the target. Defaults to None.
426426
ExceptionHandling ExceptionsType = ExceptionHandling::None;
427427

428+
/// True if target uses CFI unwind information for debugging purpose when
429+
/// `ExceptionsType == ExceptionHandling::None`.
430+
bool UsesCFIForDebug = false;
431+
428432
/// Windows exception handling data (.pdata) encoding. Defaults to Invalid.
429433
WinEH::EncodingType WinEHEncodingType = WinEH::EncodingType::Invalid;
430434

@@ -728,6 +732,8 @@ class MCAsmInfo {
728732
ExceptionsType = EH;
729733
}
730734

735+
bool doesUseCFIForDebug() const { return UsesCFIForDebug; }
736+
731737
/// Returns true if the exception handling method for the platform uses call
732738
/// frame information to unwind.
733739
bool usesCFIForEH() const {

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,9 @@ bool AsmPrinter::doInitialization(Module &M) {
351351
}
352352

353353
switch (MAI->getExceptionHandlingType()) {
354+
case ExceptionHandling::None:
355+
// We may want to emit CFI for debug.
356+
LLVM_FALLTHROUGH;
354357
case ExceptionHandling::SjLj:
355358
case ExceptionHandling::DwarfCFI:
356359
case ExceptionHandling::ARM:
@@ -372,7 +375,9 @@ bool AsmPrinter::doInitialization(Module &M) {
372375
EHStreamer *ES = nullptr;
373376
switch (MAI->getExceptionHandlingType()) {
374377
case ExceptionHandling::None:
375-
break;
378+
if (!needsCFIForDebug())
379+
break;
380+
LLVM_FALLTHROUGH;
376381
case ExceptionHandling::SjLj:
377382
case ExceptionHandling::DwarfCFI:
378383
ES = new DwarfCFIException(this);
@@ -1062,9 +1067,15 @@ bool AsmPrinter::needsSEHMoves() {
10621067
return MAI->usesWindowsCFI() && MF->getFunction().needsUnwindTableEntry();
10631068
}
10641069

1070+
bool AsmPrinter::needsCFIForDebug() const {
1071+
return MAI->getExceptionHandlingType() == ExceptionHandling::None &&
1072+
MAI->doesUseCFIForDebug() && ModuleCFISection == CFISection::Debug;
1073+
}
1074+
10651075
void AsmPrinter::emitCFIInstruction(const MachineInstr &MI) {
10661076
ExceptionHandling ExceptionHandlingType = MAI->getExceptionHandlingType();
1067-
if (ExceptionHandlingType != ExceptionHandling::DwarfCFI &&
1077+
if (!needsCFIForDebug() &&
1078+
ExceptionHandlingType != ExceptionHandling::DwarfCFI &&
10681079
ExceptionHandlingType != ExceptionHandling::ARM)
10691080
return;
10701081

llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,13 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) {
120120
shouldEmitLSDA = shouldEmitPersonality &&
121121
LSDAEncoding != dwarf::DW_EH_PE_omit;
122122

123-
shouldEmitCFI = MF->getMMI().getContext().getAsmInfo()->usesCFIForEH() &&
124-
(shouldEmitPersonality || shouldEmitMoves);
123+
const MCAsmInfo &MAI = *MF->getMMI().getContext().getAsmInfo();
124+
if (MAI.getExceptionHandlingType() != ExceptionHandling::None)
125+
shouldEmitCFI =
126+
MAI.usesCFIForEH() && (shouldEmitPersonality || shouldEmitMoves);
127+
else
128+
shouldEmitCFI = Asm->needsCFIForDebug() && shouldEmitMoves;
129+
125130
beginFragment(&*MF->begin(), getExceptionSym);
126131
}
127132

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ AMDGPUMCAsmInfo::AMDGPUMCAsmInfo(const Triple &TT,
4242
HasNoDeadStrip = true;
4343
//===--- Dwarf Emission Directives -----------------------------------===//
4444
SupportsDebugInformation = true;
45+
UsesCFIForDebug = true;
4546
DwarfRegNumForCFI = true;
4647

4748
UseIntegratedAssembler = false;

llvm/test/CodeGen/AMDGPU/debug_frame.ll

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
; RUN: llc -mtriple=amdgcn-amd-amdhsa -filetype=obj -o - < %s | llvm-readelf -S - | FileCheck --check-prefixes=NOEXCEPTIONS_NOFORCE-DEBUG %s
2-
; RUN: llc -mtriple=amdgcn-amd-amdhsa -filetype=obj --force-dwarf-frame-section -o - < %s | llvm-readelf -S - | FileCheck --check-prefixes=NOEXCEPTIONS_FORCE-DEBUG %s
3-
; RUN: llc -mtriple=amdgcn-amd-amdhsa -filetype=obj --exception-model=dwarf -o - < %s | llvm-readelf -S - | FileCheck --check-prefixes=EXCEPTIONS_NOFORCE-DEBUG %s
4-
; RUN: llc -mtriple=amdgcn-amd-amdhsa -filetype=obj --force-dwarf-frame-section --exception-model=dwarf -o - < %s | llvm-readelf -S - | FileCheck --check-prefixes=EXCEPTIONS_FORCE-DEBUG %s
1+
; RUN: llc -mtriple=amdgcn-amd-amdhsa -o - < %s | FileCheck %s
2+
; RUN: llc -mtriple=amdgcn-amd-amdhsa --force-dwarf-frame-section -o - < %s | FileCheck %s
3+
; RUN: llc -mtriple=amdgcn-amd-amdhsa --exception-model=dwarf -o - < %s | FileCheck %s
4+
; RUN: llc -mtriple=amdgcn-amd-amdhsa --force-dwarf-frame-section --exception-model=dwarf -o - < %s | FileCheck %s
55

6-
; Test that demonstrates we produce a .debug_frame only when exceptions are enabled even if --force-dwarf-frame-section is enabled
7-
8-
; NOEXCEPTIONS_NOFORCE-DEBUG-NOT: .debug_frame
9-
; NOEXCEPTIONS_FORCE-DEBUG-NOT: .debug_frame
10-
; EXCEPTIONS_NOFORCE-DEBUG: .debug_frame
11-
; EXCEPTIONS_FORCE-DEBUG: .debug_frame
6+
; CHECK: .cfi_sections .debug_frame
127

138
define void @f() nounwind !dbg !0 {
149
entry:

llvm/test/CodeGen/AMDGPU/ptr-arg-dbg-value.ll

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,23 @@
88
; with the fragment expressions.
99
define hidden void @ptr_arg_split_subregs(%struct.A* %arg1) #0 !dbg !9 {
1010
; CHECK-LABEL: ptr_arg_split_subregs:
11-
; CHECK: ; %bb.0:
12-
; CHECK: ;DEBUG_VALUE: ptr_arg_split_subregs:a <- [DW_OP_LLVM_fragment 32 32] [$vgpr1+0]
13-
; CHECK: ;DEBUG_VALUE: ptr_arg_split_subregs:a <- [DW_OP_LLVM_fragment 0 32] [$vgpr0+0]
11+
; CHECK: .Lfunc_begin0:
12+
; CHECK: .loc 1 5 0 ; example.cpp:5:0
13+
; CHECK-NEXT: .cfi_sections .debug_frame
14+
; CHECK-NEXT: .cfi_startproc
15+
; CHECK-NEXT: ; %bb.0:
16+
; CHECK-NEXT: ;DEBUG_VALUE: ptr_arg_split_subregs:a <- [DW_OP_LLVM_fragment 32 32] [$vgpr1+0]
17+
; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
18+
; CHECK-NEXT: v_mov_b32_e32 v2, 1
19+
; CHECK-NEXT: .Ltmp0:
20+
; CHECK-NEXT: ;DEBUG_VALUE: ptr_arg_split_subregs:a <- [DW_OP_LLVM_fragment 0 32] [$vgpr0+0]
21+
; CHECK-NEXT: .loc 1 7 13 prologue_end ; example.cpp:7:13
22+
; CHECK-NEXT: flat_store_dword v[0:1], v2 offset:396
23+
; CHECK-NEXT: .loc 1 8 5 ; example.cpp:8:5
24+
; CHECK-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
25+
; CHECK-NEXT: s_setpc_b64 s[30:31]
26+
; CHECK-NEXT: .Ltmp1:
27+
; CHECK: .cfi_endproc
1428
call void @llvm.dbg.declare(metadata %struct.A* %arg1, metadata !20, metadata !DIExpression()), !dbg !21
1529
%gep1 = getelementptr inbounds %struct.A, %struct.A* %arg1, i32 0, i32 0, i32 99, !dbg !22
1630
store i32 1, i32* %gep1, align 4, !dbg !23
@@ -27,6 +41,7 @@ define hidden void @ptr_arg_split_reg_mem(<31 x i32>, %struct.A* %arg2) #0 !dbg
2741
; CHECK-LABEL: ptr_arg_split_reg_mem:
2842
; CHECK: .Lfunc_begin1:
2943
; CHECK-NEXT: .loc 1 10 0 ; example.cpp:10:0
44+
; CHECK-NEXT: .cfi_startproc
3045
; CHECK-NEXT: ; %bb.0:
3146
; CHECK-NEXT: ;DEBUG_VALUE: ptr_arg_split_reg_mem:b <- [$vgpr31+0]
3247
; CHECK-NEXT: ;DEBUG_VALUE: ptr_arg_split_reg_mem:b <- [$vgpr31+0]
@@ -41,6 +56,7 @@ define hidden void @ptr_arg_split_reg_mem(<31 x i32>, %struct.A* %arg2) #0 !dbg
4156
; CHECK-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4257
; CHECK-NEXT: s_setpc_b64 s[30:31]
4358
; CHECK-NEXT: .Ltmp3:
59+
; CHECK: .cfi_endproc
4460
call void @llvm.dbg.declare(metadata %struct.A* %arg2, metadata !26, metadata !DIExpression()), !dbg !27
4561
%gep2 = getelementptr inbounds %struct.A, %struct.A* %arg2, i32 0, i32 0, i32 99, !dbg !28
4662
store i32 1, i32* %gep2, align 4, !dbg !29
@@ -53,6 +69,7 @@ define hidden void @ptr_arg_in_memory(<32 x i32>, %struct.A* %arg3) #0 !dbg !31
5369
; CHECK-LABEL: ptr_arg_in_memory:
5470
; CHECK: .Lfunc_begin2:
5571
; CHECK-NEXT: .loc 1 15 0 ; example.cpp:15:0
72+
; CHECK-NEXT: .cfi_startproc
5673
; CHECK-NEXT: ; %bb.0:
5774
; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
5875
; CHECK-NEXT: buffer_load_dword v1, off, s[0:3], s32 offset:4
@@ -66,6 +83,7 @@ define hidden void @ptr_arg_in_memory(<32 x i32>, %struct.A* %arg3) #0 !dbg !31
6683
; CHECK-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6784
; CHECK-NEXT: s_setpc_b64 s[30:31]
6885
; CHECK-NEXT: .Ltmp5:
86+
; CHECK: .cfi_endproc
6987
call void @llvm.dbg.declare(metadata %struct.A* %arg3, metadata !32, metadata !DIExpression()), !dbg !33
7088
%gep3 = getelementptr inbounds %struct.A, %struct.A* %arg3, i32 0, i32 0, i32 99, !dbg !34
7189
store i32 1, i32* %gep3, align 4, !dbg !35

llvm/test/CodeGen/AMDGPU/split-arg-dbg-value.ll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ define hidden <4 x float> @split_v4f32_arg(<4 x float> returned %arg) local_unna
66
; GCN: .Lfunc_begin0:
77
; GCN-NEXT: .file 0
88
; GCN-NEXT: .loc 0 3 0 ; /tmp/dbg.cl:3:0
9+
; GCN-NEXT: .cfi_sections .debug_frame
10+
; GCN-NEXT: .cfi_startproc
911
; GCN-NEXT: ; %bb.0:
1012
; GCN-NEXT: ;DEBUG_VALUE: split_v4f32_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 96 32] $vgpr3
1113
; GCN-NEXT: ;DEBUG_VALUE: split_v4f32_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 64 32] $vgpr2
@@ -16,6 +18,7 @@ define hidden <4 x float> @split_v4f32_arg(<4 x float> returned %arg) local_unna
1618
; GCN-NEXT: .loc 0 4 5 prologue_end ; /tmp/dbg.cl:4:5
1719
; GCN-NEXT: s_setpc_b64 s[30:31]
1820
; GCN-NEXT: .Ltmp1:
21+
; GCN: .cfi_endproc
1922
call void @llvm.dbg.value(metadata <4 x float> %arg, metadata !18, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !19
2023
ret <4 x float> %arg, !dbg !20
2124
}
@@ -24,6 +27,7 @@ define hidden <4 x float> @split_v4f32_multi_arg(<4 x float> %arg0, <2 x float>
2427
; GCN-LABEL: split_v4f32_multi_arg:
2528
; GCN: .Lfunc_begin1:
2629
; GCN-NEXT: .loc 0 7 0 ; /tmp/dbg.cl:7:0
30+
; GCN-NEXT: .cfi_startproc
2731
; GCN-NEXT: ; %bb.0:
2832
; GCN-NEXT: ;DEBUG_VALUE: split_v4f32_multi_arg:arg1 <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 32 32] $vgpr5
2933
; GCN-NEXT: ;DEBUG_VALUE: split_v4f32_multi_arg:arg1 <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 0 32] $vgpr4
@@ -45,6 +49,7 @@ define hidden <4 x float> @split_v4f32_multi_arg(<4 x float> %arg0, <2 x float>
4549
; GCN-NEXT: .loc 0 8 5 is_stmt 0 ; /tmp/dbg.cl:8:5
4650
; GCN-NEXT: s_setpc_b64 s[30:31]
4751
; GCN-NEXT: .Ltmp7:
52+
; GCN: .cfi_endproc
4853
call void @llvm.dbg.value(metadata <4 x float> %arg0, metadata !29, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !31
4954
call void @llvm.dbg.value(metadata <2 x float> %arg1, metadata !30, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !31
5055
%tmp = shufflevector <2 x float> %arg1, <2 x float> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 1>, !dbg !32
@@ -56,6 +61,7 @@ define hidden <4 x half> @split_v4f16_arg(<4 x half> returned %arg) local_unname
5661
; GCN-LABEL: split_v4f16_arg:
5762
; GCN: .Lfunc_begin2:
5863
; GCN-NEXT: .loc 0 11 0 is_stmt 1 ; /tmp/dbg.cl:11:0
64+
; GCN-NEXT: .cfi_startproc
5965
; GCN-NEXT: ; %bb.0:
6066
; GCN-NEXT: ;DEBUG_VALUE: split_v4f16_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 32 32] $vgpr1
6167
; GCN-NEXT: ;DEBUG_VALUE: split_v4f16_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 0 32] $vgpr0
@@ -64,6 +70,7 @@ define hidden <4 x half> @split_v4f16_arg(<4 x half> returned %arg) local_unname
6470
; GCN-NEXT: .loc 0 12 5 prologue_end ; /tmp/dbg.cl:12:5
6571
; GCN-NEXT: s_setpc_b64 s[30:31]
6672
; GCN-NEXT: .Ltmp9:
73+
; GCN: .cfi_endproc
6774
call void @llvm.dbg.value(metadata <4 x half> %arg, metadata !42, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !43
6875
ret <4 x half> %arg, !dbg !44
6976
}
@@ -72,6 +79,7 @@ define hidden double @split_f64_arg(double returned %arg) local_unnamed_addr #0
7279
; GCN-LABEL: split_f64_arg:
7380
; GCN: .Lfunc_begin3:
7481
; GCN-NEXT: .loc 0 15 0 ; /tmp/dbg.cl:15:0
82+
; GCN-NEXT: .cfi_startproc
7583
; GCN-NEXT: ; %bb.0:
7684
; GCN-NEXT: ;DEBUG_VALUE: split_f64_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 32 32] $vgpr1
7785
; GCN-NEXT: ;DEBUG_VALUE: split_f64_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 0 32] $vgpr0
@@ -80,6 +88,7 @@ define hidden double @split_f64_arg(double returned %arg) local_unnamed_addr #0
8088
; GCN-NEXT: .loc 0 16 5 prologue_end ; /tmp/dbg.cl:16:5
8189
; GCN-NEXT: s_setpc_b64 s[30:31]
8290
; GCN-NEXT: .Ltmp11:
91+
; GCN: .cfi_endproc
8392
call void @llvm.dbg.value(metadata double %arg, metadata !50, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !51
8493
ret double %arg, !dbg !52
8594
}
@@ -88,6 +97,7 @@ define hidden <2 x double> @split_v2f64_arg(<2 x double> returned %arg) local_un
8897
; GCN-LABEL: split_v2f64_arg:
8998
; GCN: .Lfunc_begin4:
9099
; GCN-NEXT: .loc 0 19 0 ; /tmp/dbg.cl:19:0
100+
; GCN-NEXT: .cfi_startproc
91101
; GCN-NEXT: ; %bb.0:
92102
; GCN-NEXT: ;DEBUG_VALUE: split_v2f64_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 96 32] $vgpr3
93103
; GCN-NEXT: ;DEBUG_VALUE: split_v2f64_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 64 32] $vgpr2
@@ -98,6 +108,7 @@ define hidden <2 x double> @split_v2f64_arg(<2 x double> returned %arg) local_un
98108
; GCN-NEXT: .loc 0 20 5 prologue_end ; /tmp/dbg.cl:20:5
99109
; GCN-NEXT: s_setpc_b64 s[30:31]
100110
; GCN-NEXT: .Ltmp13:
111+
; GCN: .cfi_endproc
101112
call void @llvm.dbg.value(metadata <2 x double> %arg, metadata !59, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !60
102113
ret <2 x double> %arg, !dbg !61
103114
}
@@ -106,6 +117,7 @@ define hidden i64 @split_i64_arg(i64 returned %arg) local_unnamed_addr #0 !dbg !
106117
; GCN-LABEL: split_i64_arg:
107118
; GCN: .Lfunc_begin5:
108119
; GCN-NEXT: .loc 0 23 0 ; /tmp/dbg.cl:23:0
120+
; GCN-NEXT: .cfi_startproc
109121
; GCN-NEXT: ; %bb.0:
110122
; GCN-NEXT: ;DEBUG_VALUE: split_i64_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 32 32] $vgpr1
111123
; GCN-NEXT: ;DEBUG_VALUE: split_i64_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 0 32] $vgpr0
@@ -114,6 +126,7 @@ define hidden i64 @split_i64_arg(i64 returned %arg) local_unnamed_addr #0 !dbg !
114126
; GCN-NEXT: .loc 0 24 5 prologue_end ; /tmp/dbg.cl:24:5
115127
; GCN-NEXT: s_setpc_b64 s[30:31]
116128
; GCN-NEXT: .Ltmp15:
129+
; GCN: .cfi_endproc
117130
call void @llvm.dbg.value(metadata i64 %arg, metadata !67, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !68
118131
ret i64 %arg, !dbg !69
119132
}
@@ -122,6 +135,7 @@ define hidden i8 addrspace(1)* @split_ptr_arg(i8 addrspace(1)* readnone returned
122135
; GCN-LABEL: split_ptr_arg:
123136
; GCN: .Lfunc_begin6:
124137
; GCN-NEXT: .loc 0 27 0 ; /tmp/dbg.cl:27:0
138+
; GCN-NEXT: .cfi_startproc
125139
; GCN-NEXT: ; %bb.0:
126140
; GCN-NEXT: ;DEBUG_VALUE: split_ptr_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 32 32] $vgpr1
127141
; GCN-NEXT: ;DEBUG_VALUE: split_ptr_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 0 32] $vgpr0
@@ -130,6 +144,7 @@ define hidden i8 addrspace(1)* @split_ptr_arg(i8 addrspace(1)* readnone returned
130144
; GCN-NEXT: .loc 0 28 5 prologue_end ; /tmp/dbg.cl:28:5
131145
; GCN-NEXT: s_setpc_b64 s[30:31]
132146
; GCN-NEXT: .Ltmp17:
147+
; GCN: .cfi_endproc
133148
call void @llvm.dbg.value(metadata i8 addrspace(1)* %arg, metadata !76, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !77
134149
ret i8 addrspace(1)* %arg, !dbg !78
135150
}

llvm/test/DebugInfo/AMDGPU/cfi.ll

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
; RUN: llc -mcpu=gfx900 -mtriple=amdgcn-amd-amdhsa -filetype=obj -o - %s | llvm-dwarfdump -debug-frame - | FileCheck %s
2+
3+
; CHECK: .debug_frame contents:
4+
; CHECK: 00000000 0000000c ffffffff CIE
5+
; CHECK-NEXT: Format: DWARF32
6+
; CHECK-NEXT: Version: 4
7+
; CHECK-NEXT: Augmentation: ""
8+
; CHECK-NEXT: Address size: 8
9+
; CHECK-NEXT: Segment desc size: 0
10+
; CHECK-NEXT: Code alignment factor: 4
11+
; CHECK-NEXT: Data alignment factor: 4
12+
; CHECK-NEXT: Return address column: 16
13+
; CHECK-EMPTY:
14+
; CHECK: DW_CFA_nop:
15+
; CHECK-EMPTY:
16+
; CHECK: 00000010 {{[0-9]+}} 00000000 FDE cie=00000000 pc=00000000...{{[0-9]+}}
17+
; CHECK-NEXT: Format: DWARF32
18+
; CHECK-EMPTY:
19+
; CHECK: .eh_frame contents:
20+
; CHECK-NOT: CIE
21+
22+
define void @func() #0 {
23+
ret void
24+
}
25+
26+
attributes #0 = { nounwind }
27+
28+
!llvm.module.flags = !{!0, !1}
29+
!llvm.dbg.cu = !{!2}
30+
31+
!0 = !{i32 7, !"Dwarf Version", i32 5}
32+
!1 = !{i32 2, !"Debug Info Version", i32 3}
33+
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, emissionKind: FullDebug)
34+
!3 = !DIFile(filename: "file", directory: "dir")

llvm/test/MC/ELF/AMDGPU/cfi.s

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# RUN: llvm-mc -filetype=asm -mcpu=gfx900 -triple amdgcn-amd-amdhsa %s -o - | FileCheck --check-prefix=ASM %s
2+
# RUN: llvm-mc -filetype=obj -mcpu=gfx900 -triple amdgcn-amd-amdhsa %s -o %t
3+
# RUN: llvm-readelf -S -r -x .debug_frame %t | FileCheck --check-prefix=READELF %s
4+
5+
f:
6+
.cfi_sections .debug_frame
7+
.cfi_startproc
8+
s_nop 0
9+
.cfi_endproc
10+
11+
# ASM: f:
12+
# ASM-NEXT: .cfi_sections .debug_frame
13+
# ASM-NEXT: .cfi_startproc
14+
# ASM-NEXT: s_nop 0
15+
# ASM-NEXT: .cfi_endproc
16+
17+
# READELF: Section Headers:
18+
# READELF: Name Type Address Off Size ES Flg Lk Inf Al
19+
# READELF: .debug_frame PROGBITS 0000000000000000 000048 000028 00 0 0 8
20+
21+
# READELF: Relocation section '.rela.debug_frame' at offset 0xd0 contains 2 entries:
22+
# READELF-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
23+
# READELF-NEXT: 0000000000000014 0000000300000006 R_AMDGPU_ABS32 0000000000000000 .debug_frame + 0
24+
# READELF-NEXT: 0000000000000018 0000000100000003 R_AMDGPU_ABS64 0000000000000000 .text + 0
25+
26+
# READELF: Hex dump of section '.debug_frame':
27+
# READELF-NEXT: 0x00000000 0c000000 ffffffff 04000800 04041000 ................
28+
# READELF-NEXT: 0x00000010 14000000 00000000 00000000 00000000 ................
29+
# READELF-NEXT: 0x00000020 04000000 00000000 ........

0 commit comments

Comments
 (0)