Skip to content
This repository was archived by the owner on Dec 20, 2019. It is now read-only.

Conversation

@lewurm
Copy link

@lewurm lewurm commented Jul 8, 2019

Consider the following prologue:

0xce2d34: 0xe92d40f0   push   {r4, r5, r6, r7, lr}
0xce2d38: 0xe28d700c   add    r7, sp, #12
0xce2d3c: 0xe92d0c00   push   {r10, r11}

Without this patch the following unwind information would be emitted:

CFA: [0] def_cfa: arm_sp+0x0
CFA: [4] def_cfa: arm_v4+0x8
CFA: [4] offset: pc at cfa-0x4
CFA: [4] offset: arm_v4 at cfa-0x8
CFA: [4] offset: arm_v3 at cfa-0xc
CFA: [4] offset: arm_v2 at cfa-0x10
CFA: [4] offset: arm_v1 at cfa-0x14
CFA: [8] offset: arm_fp at cfa-0x18
CFA: [c] offset: arm_v7 at cfa-0x1c
CFA: [c] def_cfa_offset: 0x14

which is almost correct. The last bit messes up our unwinding machine and also doesn't make sense in general. If anything this should be def_cfa: arm_sp+0x1c.

Anyway, since the framepointer is always +8 to the old stack pointer, we can use that to restore the CFA and can omit whatever DefCFAOffsetCandidates would compute.

Consider the following prologue:
```
0xce2d34: 0xe92d40f0   push   {r4, r5, r6, r7, lr}
0xce2d38: 0xe28d700c   add    r7, sp, mono#12
0xce2d3c: 0xe92d0c00   push   {r10, r11}
```
Without this patch the following unwind information would be emitted:

```
CFA: [0] def_cfa: arm_sp+0x0
CFA: [4] def_cfa: arm_v4+0x8
CFA: [4] offset: pc at cfa-0x4
CFA: [4] offset: arm_v4 at cfa-0x8
CFA: [4] offset: arm_v3 at cfa-0xc
CFA: [4] offset: arm_v2 at cfa-0x10
CFA: [4] offset: arm_v1 at cfa-0x14
CFA: [8] offset: arm_fp at cfa-0x18
CFA: [c] offset: arm_v7 at cfa-0x1c
CFA: [c] def_cfa_offset: 0x14

```

which is _almost_ correct. The last bit messes up our unwinding machine and also doesn't make sense in general. If _anything_ this should be `def_cfa: arm_sp+0x1c`.

Anyway, since the framepointer is always `+8` to the old stack pointer, we can use that to restore the CFA and can omit whatever DefCFAOffsetCandidates would compute.
@lewurm lewurm requested review from BrzVlad and vargaz July 8, 2019 20:22
lewurm added a commit to lewurm/mono that referenced this pull request Jul 8, 2019
Instead of
```
push    {r4, r5, r6, r7, r10, r11, lr}
```

LLVM will generate
```
push    {r4, r5, r6, r7, lr}
add     r7, sp, mono#12
push    {r10, r11}
```

Seems like this mono/llvm@a04e9e4 assumes that `-disable-fp-elim` is passed for iOS targets. I wondered why this wouldn't break things for them, but when you run `clang` from Xcode with `-v`, you will discover that its driver passes `-mdisable-fp-elim`.

Together with mono/llvm#48 this fixes crashes with FullAOT+LLVM on iOS 32bit.

Fixes mono#15058

Contributes to mono#9621
@vargaz vargaz merged commit 29f36fd into mono:release_60 Jul 8, 2019
monojenkins pushed a commit to monojenkins/mono that referenced this pull request Jul 8, 2019
Instead of
```
push    {r4, r5, r6, r7, r10, r11, lr}
```

LLVM will generate
```
push    {r4, r5, r6, r7, lr}
add     r7, sp, mono#12
push    {r10, r11}
```

Seems like this mono/llvm@a04e9e4 assumes that `-disable-fp-elim` is passed for iOS targets. I wondered why this wouldn't break things for them, but when you run `clang` from Xcode with `-v`, you will discover that its driver passes `-mdisable-fp-elim`.

Together with mono/llvm#48 this fixes crashes with FullAOT+LLVM on iOS 32bit.

Fixes mono#15058

Contributes to mono#9621
monojenkins added a commit to mono/mono that referenced this pull request Jul 9, 2019
[2019-06] [llvm] avoid FP elimination on iOS/armv7

Instead of
```
push    {r4, r5, r6, r7, r10, r11, lr}
```

LLVM will generate
```
push    {r4, r5, r6, r7, lr}
add     r7, sp, #12
push    {r9, r10}
```

Seems like this mono/llvm@a04e9e4 assumes that `-disable-fp-elim` is passed for iOS targets. I wondered why this wouldn't break things for them, but when you run `clang` from Xcode with `-v`, you will discover that its driver passes `-mdisable-fp-elim`.

Together with mono/llvm#48 this fixes crashes with FullAOT+LLVM on iOS 32bit.

Fixes #15058

Contributes to #9621



Backport of #15617.

/cc @lewurm
monojenkins pushed a commit to mono/mono that referenced this pull request Jul 14, 2019
[llvm] avoid FP elimination on iOS/armv7

Instead of
```
push    {r4, r5, r6, r7, r10, r11, lr}
```

LLVM will generate
```
push    {r4, r5, r6, r7, lr}
add     r7, sp, #12
push    {r9, r10}
```

Seems like this mono/llvm@a04e9e4 assumes that `-disable-fp-elim` is passed for iOS targets. I wondered why this wouldn't break things for them, but when you run `clang` from Xcode with `-v`, you will discover that its driver passes `-mdisable-fp-elim`.

Together with mono/llvm#48 this fixes crashes with FullAOT+LLVM on iOS 32bit.

Fixes #15058

Contributes to #9621
vargaz added a commit that referenced this pull request Oct 1, 2019
[arm] fix CFA when frame pointer is used
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants