Skip to content

Commit cd68532

Browse files
committed
[RISCV] relaxDwarfCallFrameFragment: remove unneeded relocations for -mno-relax
Follow-up to 2ef56d1 for -mrelax. https://reviews.llvm.org/D155357 allowed us to use Layout as the parameter without correctness issues.
1 parent 41a08e7 commit cd68532

File tree

2 files changed

+35
-20
lines changed

2 files changed

+35
-20
lines changed

llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ bool RISCVAsmBackend::relaxDwarfCFA(MCDwarfCallFrameFragment &DF,
280280
size_t OldSize = Data.size();
281281

282282
int64_t Value;
283-
if (AddrDelta.evaluateAsAbsolute(Value, Layout.getAssembler()))
283+
if (AddrDelta.evaluateAsAbsolute(Value, Layout))
284284
return false;
285285
[[maybe_unused]] bool IsAbsolute =
286286
AddrDelta.evaluateKnownAbsolute(Value, Layout);

llvm/test/MC/RISCV/cfi-advance.s

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,41 @@
1-
# RUN: llvm-mc -filetype=obj -triple riscv32 %s -o %t.o
2-
# RUN: llvm-readelf -sr %t.o | FileCheck %s
1+
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=-relax %s -o %t.o
2+
# RUN: llvm-readelf -sr %t.o | FileCheck %s --check-prefix=NORELAX
33
# RUN: llvm-dwarfdump --debug-frame %t.o 2>&1 \
44
# RUN: | FileCheck -check-prefix=CHECK-DWARFDUMP %s
5+
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+relax %s -o %t.relax.o
6+
# RUN: llvm-readelf -sr %t.relax.o | FileCheck %s --check-prefix=RELAX
57

8+
# NORELAX: Relocation section '.rela.text1' at offset {{.*}} contains 1 entries:
9+
# NORELAX-NEXT: Offset Info Type Sym. Value Symbol's Name + Addend
10+
# NORELAX-NEXT: 00000000 00000313 R_RISCV_CALL_PLT 00000004 .L0 + 0
11+
# NORELAX-EMPTY:
12+
# NORELAX-NEXT: Relocation section '.rela.eh_frame' at offset {{.*}} contains 1 entries:
13+
# NORELAX: Offset Info Type Sym. Value Symbol's Name + Addend
14+
# NORELAX-NEXT: 0000001c 00000139 R_RISCV_32_PCREL 00000000 .L0 + 0
15+
# NORELAX-EMPTY:
16+
# NORELAX: Symbol table '.symtab' contains 13 entries:
17+
# NORELAX-NEXT: Num: Value Size Type Bind Vis Ndx Name
18+
# NORELAX-NEXT: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
19+
# NORELAX-NEXT: 1: 00000000 0 NOTYPE LOCAL DEFAULT 2 .L0 {{$}}
20+
# NORELAX: 3: 00000004 0 NOTYPE LOCAL DEFAULT 2 .L0{{$}}
21+
# NORELAX-NOT: .L0
622

7-
# CHECK: Relocation section '.rela.text1' at offset {{.*}} contains 1 entries:
8-
# CHECK-NEXT: Offset Info Type Sym. Value Symbol's Name + Addend
9-
# CHECK-NEXT: 00000000 00000313 R_RISCV_CALL_PLT 00000004 .L0 + 0
10-
# CHECK-EMPTY:
11-
# CHECK-NEXT: Relocation section '.rela.eh_frame' at offset {{.*}} contains 3 entries:
12-
# CHECK: Offset Info Type Sym. Value Symbol's Name + Addend
13-
# CHECK-NEXT: 0000001c 00000139 R_RISCV_32_PCREL 00000000 .L0 + 0
14-
# CHECK-NEXT: 00000035 00000b35 R_RISCV_SET6 00010178 .L0 + 0
15-
# CHECK-NEXT: 00000035 00000934 R_RISCV_SUB6 0001016e .L0 + 0
16-
# CHECK-EMPTY:
17-
# CHECK: Symbol table '.symtab' contains 15 entries:
18-
# CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name
19-
# CHECK-NEXT: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
20-
# CHECK-NEXT: 1: 00000000 0 NOTYPE LOCAL DEFAULT 2 .L0 {{$}}
21-
# CHECK: 3: 00000004 0 NOTYPE LOCAL DEFAULT 2 .L0{{$}}
22-
# CHECK: 9: 0001016e 0 NOTYPE LOCAL DEFAULT 2 .L0 {{$}}
23-
# CHECK: 11: 00010178 0 NOTYPE LOCAL DEFAULT 2 .L0 {{$}}
23+
# RELAX: Relocation section '.rela.eh_frame' at offset {{.*}} contains 5 entries:
24+
# RELAX-NEXT: Offset Info Type Sym. Value Symbol's Name + Addend
25+
# RELAX-NEXT: 0000001c 00000139 R_RISCV_32_PCREL 00000000 .L0 + 0
26+
# RELAX-NEXT: 00000020 00000c23 R_RISCV_ADD32 0001017a .L0 + 0
27+
# RELAX-NEXT: 00000020 00000127 R_RISCV_SUB32 00000000 .L0 + 0
28+
# RELAX-NEXT: 00000035 00000b35 R_RISCV_SET6 00010176 .L0 + 0
29+
# RELAX-NEXT: 00000035 00000934 R_RISCV_SUB6 0001016e .L0 + 0
30+
# RELAX-EMPTY:
31+
# RELAX: Symbol table '.symtab' contains 16 entries:
32+
# RELAX-NEXT: Num: Value Size Type Bind Vis Ndx Name
33+
# RELAX-NEXT: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
34+
# RELAX-NEXT: 1: 00000000 0 NOTYPE LOCAL DEFAULT 2 .L0 {{$}}
35+
# RELAX: 3: 00000004 0 NOTYPE LOCAL DEFAULT 2 .L0{{$}}
36+
# RELAX: 9: 0001016e 0 NOTYPE LOCAL DEFAULT 2 .L0 {{$}}
37+
# RELAX: 11: 00010176 0 NOTYPE LOCAL DEFAULT 2 .L0 {{$}}
38+
# RELAX: 12: 0001017a 0 NOTYPE LOCAL DEFAULT 2 .L0 {{$}}
2439

2540
# CHECK-DWARFDUMP: DW_CFA_advance_loc1: 104
2641
# CHECK-DWARFDUMP-NEXT: DW_CFA_def_cfa_offset: +8

0 commit comments

Comments
 (0)