Skip to content

Commit 5b1c62c

Browse files
committed
[MC][MachO]Do not emit DWARF for no-personality case
Detail: Follow up to D144999, where we emitted DWARF for non-canonical personality. Reviewed By: jyknight Differential Revision: https://reviews.llvm.org/D152540
1 parent a982431 commit 5b1c62c

File tree

3 files changed

+154
-8
lines changed

3 files changed

+154
-8
lines changed

llvm/lib/MC/MCAsmBackend.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,17 @@ bool MCAsmBackend::fixupNeedsRelaxationAdvanced(
117117
}
118118

119119
bool MCAsmBackend::isDarwinCanonicalPersonality(const MCSymbol *Sym) const {
120-
if (Sym && Sym->isMachO()) {
121-
StringRef name = Sym->getName();
122-
// XXX: We intentionally leave out "___gcc_personality_v0" because, despite
123-
// being system-defined like these two, it is not very commonly-used.
124-
// Reserving an empty slot for it seems silly.
125-
return name == "___gxx_personality_v0" || name == "___objc_personality_v0";
126-
}
127-
return false;
120+
// Consider a NULL personality (ie., no personality encoding) to be canonical
121+
// because it's always at 0.
122+
if (!Sym)
123+
return true;
124+
125+
if (!Sym->isMachO())
126+
llvm_unreachable("Expected MachO symbols only");
127+
128+
StringRef name = Sym->getName();
129+
// XXX: We intentionally leave out "___gcc_personality_v0" because, despite
130+
// being system-defined like these two, it is not very commonly-used.
131+
// Reserving an empty slot for it seems silly.
132+
return name == "___gxx_personality_v0" || name == "___objc_personality_v0";
128133
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos11.0 %s | llvm-objdump --unwind-info - | FileCheck %s
2+
3+
# Check that we emit the right encoding for the no-personality case.
4+
5+
# CHECK: Contents of __compact_unwind section:
6+
# CHECK: Entry at offset {{.+}}
7+
# CHECK: start: {{.+}} ltmp0
8+
# CHECK: length: {{.+}}
9+
# CHECK: compact encoding: 0x02001000
10+
# CHECK: Entry at offset {{.+}}
11+
# CHECK: start: {{.+}} __Z3foov
12+
# CHECK: length: {{.+}}
13+
# CHECK: compact encoding: 0x04000000
14+
# CHECK: Entry at offset {{.+}}
15+
# CHECK: start: {{.+}} _main
16+
# CHECK: length: {{.+}}
17+
# CHECK: compact encoding: 0x04000000
18+
19+
20+
.section __TEXT,__text,regular,pure_instructions
21+
.build_version macos, 11, 0
22+
.globl __Z3barPi
23+
.p2align 2
24+
__Z3barPi:
25+
.cfi_startproc
26+
sub sp, sp, #16
27+
.cfi_def_cfa_offset 16
28+
str x0, [sp, #8]
29+
add sp, sp, #16
30+
ret
31+
.cfi_endproc
32+
33+
.globl __Z3foov
34+
.p2align 2
35+
__Z3foov:
36+
.cfi_startproc
37+
38+
sub sp, sp, #32
39+
.cfi_def_cfa_offset 32
40+
stp x29, x30, [sp, #16]
41+
add x29, sp, #16
42+
.cfi_def_cfa w29, 16
43+
.cfi_offset w30, -8
44+
.cfi_offset w29, -16
45+
sub x0, x29, #4
46+
bl __Z3barPi
47+
ldp x29, x30, [sp, #16]
48+
add sp, sp, #32
49+
ret
50+
.cfi_endproc
51+
52+
.globl _main
53+
.p2align 2
54+
_main:
55+
.cfi_startproc
56+
sub sp, sp, #32
57+
.cfi_def_cfa_offset 32
58+
stp x29, x30, [sp, #16]
59+
add x29, sp, #16
60+
.cfi_def_cfa w29, 16
61+
.cfi_offset w30, -8
62+
.cfi_offset w29, -16
63+
mov w8, #0
64+
str w8, [sp, #8]
65+
stur wzr, [x29, #-4]
66+
bl __Z3foov
67+
ldr w0, [sp, #8]
68+
ldp x29, x30, [sp, #16]
69+
add sp, sp, #32
70+
ret
71+
.cfi_endproc
72+
73+
.subsections_via_symbols
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin10.0 %s | llvm-objdump --unwind-info - | FileCheck %s
2+
3+
# Check that we emit the right encoding for the no-personality case.
4+
5+
# CHECK: Contents of __compact_unwind section:
6+
# CHECK: Entry at offset {{.+}}
7+
# CHECK: start: {{.+}} __Z3barPi
8+
# CHECK: length: {{.+}}
9+
# CHECK: compact encoding: 0x01000000
10+
# CHECK: Entry at offset {{.+}}
11+
# CHECK: start: {{.+}} __Z3foov
12+
# CHECK: length: {{.+}}
13+
# CHECK: compact encoding: 0x01000000
14+
# CHECK: Entry at offset {{.+}}
15+
# CHECK: start: {{.+}} _main
16+
# CHECK: length: 0x1c
17+
18+
.section __TEXT,__text,regular,pure_instructions
19+
.globl __Z3barPi
20+
.p2align 4, 0x90
21+
__Z3barPi:
22+
.cfi_startproc
23+
pushq %rbp
24+
.cfi_def_cfa_offset 16
25+
.cfi_offset %rbp, -16
26+
movq %rsp, %rbp
27+
.cfi_def_cfa_register %rbp
28+
movq %rdi, -8(%rbp)
29+
popq %rbp
30+
retq
31+
.cfi_endproc
32+
33+
.globl __Z3foov
34+
.p2align 4, 0x90
35+
__Z3foov:
36+
.cfi_startproc
37+
pushq %rbp
38+
.cfi_def_cfa_offset 16
39+
.cfi_offset %rbp, -16
40+
movq %rsp, %rbp
41+
.cfi_def_cfa_register %rbp
42+
subq $16, %rsp
43+
leaq -4(%rbp), %rdi
44+
callq __Z3barPi
45+
addq $16, %rsp
46+
popq %rbp
47+
retq
48+
.cfi_endproc
49+
50+
.globl _main
51+
.p2align 4, 0x90
52+
_main:
53+
.cfi_startproc
54+
pushq %rbp
55+
.cfi_def_cfa_offset 16
56+
.cfi_offset %rbp, -16
57+
movq %rsp, %rbp
58+
.cfi_def_cfa_register %rbp
59+
subq $16, %rsp
60+
movl $0, -4(%rbp)
61+
callq __Z3foov
62+
xorl %eax, %eax
63+
addq $16, %rsp
64+
popq %rbp
65+
retq
66+
.cfi_endproc
67+
68+
.subsections_via_symbols

0 commit comments

Comments
 (0)