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

Commit 5c54c25

Browse files
Eli Friedmanalexcrichton
authored andcommitted
[LivePhysRegs] Preserve pristine regs in blocks with no successors.
One common source of blocks with no successors is calls to noreturn functions; we want to preserve pristine registers in case they throw an exception. The whole pristine register thing is messy (we should really prefer to explicitly model registers), but this fills a hole in the model for now. Fixes https://bugs.llvm.org/show_bug.cgi?id=36073. Differential Revision: https://reviews.llvm.org/D42509 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323559 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 77ab1f0 commit 5c54c25

2 files changed

Lines changed: 49 additions & 2 deletions

File tree

‎lib/CodeGen/LivePhysRegs.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ void LivePhysRegs::addLiveOutsNoPristines(const MachineBasicBlock &MBB) {
225225

226226
voidLivePhysRegs::addLiveOuts(const MachineBasicBlock &MBB) {
227227
const MachineFunction &MF = *MBB.getParent();
228-
if (!MBB.succ_empty()) {
228+
if (!MBB.isReturnBlock()) {
229229
addPristines(MF);
230230
addLiveOutsNoPristines(MBB);
231-
} elseif (MBB.isReturnBlock()) {
231+
} else {
232232
// For the return block: Add all callee saved registers.
233233
const MachineFrameInfo &MFI = MF.getFrameInfo();
234234
if (MFI.isCalleeSavedInfoValid())
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
; RUN: llc < %s | FileCheck %s
2+
targettriple = "thumbv6---gnueabi"
3+
4+
; Use STM to save the three registers
5+
; CHECK-LABEL: use_stm:
6+
; CHECK: .save {r7, lr}
7+
; CHECK: .setfp r7, sp
8+
; CHECK: stm r3!, {r0, r1, r2}
9+
; CHECK: bl throws_1
10+
definevoid@use_stm(i32%a, i32%b, i32%c, i32*%d) local_unnamed_addrnoreturn"no-frame-pointer-elim"="true" {
11+
entry:
12+
%arrayidx = getelementptrinboundsi32, i32*%d, i322
13+
storei32%a, i32*%arrayidx, align4
14+
%arrayidx1 = getelementptrinboundsi32, i32*%d, i323
15+
storei32%b, i32*%arrayidx1, align4
16+
%arrayidx2 = getelementptrinboundsi32, i32*%d, i324
17+
storei32%c, i32*%arrayidx2, align4
18+
tailcallvoid@throws_1(i32%a, i32%b, i32%c) noreturn
19+
unreachable
20+
}
21+
22+
; Don't use STM: there is no available register to store
23+
; the address. We could transform this with some extra math, but
24+
; that currently isn't implemented.
25+
; CHECK-LABEL: no_stm:
26+
; CHECK: .save {r7, lr}
27+
; CHECK: .setfp r7, sp
28+
; CHECK: str r0,
29+
; CHECK: str r1,
30+
; CHECK: str r2,
31+
; CHECK: bl throws_2
32+
definevoid@no_stm(i32%a, i32%b, i32%c, i32*%d) local_unnamed_addrnoreturn"no-frame-pointer-elim"="true" {
33+
entry:
34+
%arrayidx = getelementptrinboundsi32, i32*%d, i322
35+
storei32%a, i32*%arrayidx, align4
36+
%arrayidx1 = getelementptrinboundsi32, i32*%d, i323
37+
storei32%b, i32*%arrayidx1, align4
38+
%arrayidx2 = getelementptrinboundsi32, i32*%d, i324
39+
storei32%c, i32*%arrayidx2, align4
40+
tailcallvoid@throws_2(i32%a, i32%b, i32%c, i32*%d) noreturn
41+
unreachable
42+
}
43+
44+
45+
declarevoid@throws_1(i32, i32, i32) noreturn
46+
declarevoid@throws_2(i32, i32, i32, i32*) noreturn
47+

0 commit comments

Comments
 (0)