Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5c54c25

Browse files
Eli Friedmanalexcrichton
Eli Friedman
authored andcommittedJan 26, 2018
[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

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed
 

‎lib/CodeGen/LivePhysRegs.cpp

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

226226
void LivePhysRegs::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-
} else if (MBB.isReturnBlock()) {
231+
} else {
232232
// For the return block: Add all callee saved registers.
233233
const MachineFrameInfo &MFI = MF.getFrameInfo();
234234
if (MFI.isCalleeSavedInfoValid())

‎test/CodeGen/Thumb/stm-scavenging.ll

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
; RUN: llc < %s | FileCheck %s
2+
target triple = "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+
define void @use_stm(i32 %a, i32 %b, i32 %c, i32* %d) local_unnamed_addr noreturn "no-frame-pointer-elim"="true" {
11+
entry:
12+
%arrayidx = getelementptr inbounds i32, i32* %d, i32 2
13+
store i32 %a, i32* %arrayidx, align 4
14+
%arrayidx1 = getelementptr inbounds i32, i32* %d, i32 3
15+
store i32 %b, i32* %arrayidx1, align 4
16+
%arrayidx2 = getelementptr inbounds i32, i32* %d, i32 4
17+
store i32 %c, i32* %arrayidx2, align 4
18+
tail call void @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+
define void @no_stm(i32 %a, i32 %b, i32 %c, i32* %d) local_unnamed_addr noreturn "no-frame-pointer-elim"="true" {
33+
entry:
34+
%arrayidx = getelementptr inbounds i32, i32* %d, i32 2
35+
store i32 %a, i32* %arrayidx, align 4
36+
%arrayidx1 = getelementptr inbounds i32, i32* %d, i32 3
37+
store i32 %b, i32* %arrayidx1, align 4
38+
%arrayidx2 = getelementptr inbounds i32, i32* %d, i32 4
39+
store i32 %c, i32* %arrayidx2, align 4
40+
tail call void @throws_2(i32 %a, i32 %b, i32 %c, i32* %d) noreturn
41+
unreachable
42+
}
43+
44+
45+
declare void @throws_1(i32, i32, i32) noreturn
46+
declare void @throws_2(i32, i32, i32, i32*) noreturn
47+

0 commit comments

Comments
 (0)
This repository has been archived.