Skip to content

Commit 8b54030

Browse files
Clean up some details
1 parent c1a97b0 commit 8b54030

File tree

3 files changed

+61
-15
lines changed

3 files changed

+61
-15
lines changed

llvm/lib/MC/MCSFrame.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ struct SFrameFDE {
7575
MCFixup::getDataKindForSize(4)));
7676
S.emitInt32(0);
7777

78-
// sfde_func_start_num_fres
79-
S.emitInt32(FREs.size());
78+
// sfde_func_num_fres
79+
// TODO: When we actually emit fres, replace 0 with FREs.size()
80+
S.emitInt32(0);
8081

8182
// sfde_func_info word
8283
FDEInfo<endianness::native> I;
@@ -121,7 +122,7 @@ class SFrameEmitterImpl {
121122
}
122123
Streamer.getContext().reportWarning(
123124
I.getLoc(), "Canonical Frame Address not in stack- or frame-pointer. "
124-
"Omitting SFrame unwind info.");
125+
"Omitting SFrame unwind info for this function.");
125126
FDE.Invalid = true;
126127
return false;
127128
}
@@ -132,8 +133,8 @@ class SFrameEmitterImpl {
132133
return true;
133134

134135
Streamer.getContext().reportWarning(
135-
I.getLoc(), "skipping SFrame FDE; .cfi_def_cfa_offset "
136-
"without CFA base register in effect");
136+
I.getLoc(), "Adjusting CFA offset without a base register. "
137+
"Omitting SFrame unwind info for this function.");
137138
FDE.Invalid = true;
138139
return false;
139140
}
@@ -241,11 +242,11 @@ class SFrameEmitterImpl {
241242
// sets the DF.RAReg.
242243
// FIXME: This also prevents providing a proper location for the error.
243244
// LLVM doesn't change the return column itself, so this was
244-
// externally-generated assembly.
245+
// hand-written assembly.
245246
if (DF.RAReg != RAReg) {
246247
Streamer.getContext().reportWarning(
247-
SMLoc(),
248-
"skipping SFrame FDE; non-default RA register " + Twine(DF.RAReg));
248+
SMLoc(), "Non-default RA register " + Twine(DF.RAReg) +
249+
". Omitting SFrame unwind info for this function.");
249250
// Continue with the FDE to find any addtional errors. Discard it at
250251
// the end.
251252
FDE.Invalid = true;
@@ -308,8 +309,8 @@ class SFrameEmitterImpl {
308309
Streamer.emitInt32(FDEs.size());
309310
// shf_num_fres
310311
uint32_t TotalFREs = 0;
311-
for (auto &FDE : FDEs)
312-
TotalFREs += FDE.FREs.size();
312+
// for (auto &FDE : FDEs)
313+
// TotalFREs += FDE.FREs.size();
313314
Streamer.emitInt32(TotalFREs);
314315

315316
// shf_fre_len
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// TODO: Add other architectures as they gain sframe support
2+
// REQUIRES: x86-registered-target
3+
// RUN: llvm-mc --assemble --filetype=obj --gsframe -triple x86_64 %s -o %t.o 2>&1 | FileCheck %s
4+
// RUN: llvm-readelf --sframe %t.o | FileCheck --check-prefix=CHECK-NOFDES %s
5+
6+
7+
.cfi_sections .sframe
8+
f1:
9+
.cfi_startproc simple
10+
nop
11+
.cfi_def_cfa_offset 16 // No base register yet
12+
nop
13+
.cfi_adjust_cfa_offset 16 // No base register yet
14+
nop
15+
.cfi_return_column 0
16+
nop
17+
.cfi_endproc
18+
19+
f2:
20+
.cfi_startproc
21+
nop
22+
.cfi_def_cfa 0, 4
23+
nop
24+
25+
.cfi_endproc
26+
27+
// CHECK: Non-default RA register {{.*}}
28+
// asm parser doesn't give a location with .cfi_def_cfa_offset
29+
// CHECK: :0:{{.*}} Adjusting CFA offset without a base register.{{.*}}
30+
// .cfi_adjust_cfa_offset
31+
// CHECK: :13:{{.*}} Adjusting CFA offset without a base register. {{.*}}
32+
// CHECK: Canonical Frame Address not in stack- or frame-pointer. {{.*}}
33+
34+
// CHECK-NOFDES: Num FDEs: 0
35+
// CHECK-NOFDES: Num FREs: 0

llvm/test/MC/ELF/cfi-sframe.s

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,18 @@
55

66
.cfi_sections .sframe
77
f1:
8-
.cfi_startproc
8+
.cfi_startproc // FRE 0
9+
nop
10+
.cfi_def_cfa_offset 16 // FRE 1
11+
.cfi_def_cfa_offset 8 // location didn't change. No new FRE, but new offset.
12+
nop
13+
.cfi_def_cfa_offset 8 // offset didn't change. No new FRE.
914
nop
15+
.cfi_def_cfa_offset 16 // FRE 2. new location, new offset.
16+
nop
17+
.cfi_register 0, 1 // Uninteresting register. No new FRE.
18+
nop
19+
1020
.cfi_endproc
1121

1222
f2:
@@ -32,11 +42,11 @@ f2:
3242
// CHECK: Function Index [
3343
// CHECK-NEXT: FuncDescEntry [0] {
3444
// CHECK-NEXT: PC {
35-
// CHECK-NEXT: Relocation: {{.*}}32{{.*}}
45+
// CHECK-NEXT: Relocation: {{.*}}PC32{{.*}}
3646
// CHECK-NEXT: Symbol Name: .text
37-
// CHECK-NEXT: Start Address: 0x0
47+
// CHECK-NEXT: Start Address: {{.*}}
3848
// CHECK-NEXT: }
39-
// CHECK-NEXT: Size: 0x1
49+
// CHECK-NEXT: Size: 0x5
4050
// CHECK-NEXT: Start FRE Offset: 0x0
4151
// CHECK-NEXT: Num FREs: 0
4252
// CHECK-NEXT: Info {
@@ -51,7 +61,7 @@ f2:
5161
// CHECK-NEXT: }
5262
// CHECK-NEXT: FuncDescEntry [1] {
5363
// CHECK-NEXT: PC {
54-
// CHECK-NEXT: Relocation: R_X86_64_PC32
64+
// CHECK-NEXT: Relocation: {{.*}}PC32{{.*}}
5565
// CHECK-NEXT: Symbol Name: .text
5666
// CHECK-NEXT: Start Address: {{.*}}
5767
// CHECK-NEXT: }

0 commit comments

Comments
 (0)