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

Commit 436f297

Browse files
author
Weiming Zhao
committed
Fix PR 18369: [Thumbv8] asserts due to inconsistent CPSR liveness of IT blocks
The issue is caused when Post-RA scheduler reorders a bundle instruction (IT block). However, it only flips the CPSR liveness of the bundle instruction, leaves the instructions inside the bundle unchanged, which causes inconstancy and crashes Thumb2SizeReduction.cpp::ReduceMBB(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199127 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 99c7fec commit 436f297

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/Target/ARM/Thumb2SizeReduction.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,9 @@ bool Thumb2SizeReduce::ReduceMBB(MachineBasicBlock &MBB) {
980980
MachineOperand *MO = BundleMI->findRegisterDefOperand(ARM::CPSR);
981981
if (MO && !MO->isDead())
982982
LiveCPSR = true;
983+
MO = BundleMI->findRegisterUseOperand(ARM::CPSR);
984+
if (MO && !MO->isKill())
985+
LiveCPSR = true;
983986
}
984987

985988
bool DefCPSR = false;

test/CodeGen/Thumb2/2011-12-16-T2SizeReduceAssert.ll

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llc < %s -mtriple=thumbv7-apple-ios -relocation-model=pic -disable-fp-elim -mcpu=cortex-a8
2+
; RUN: llc < %s -mtriple=thumbv8-none-linux-gnueabi | FileCheck %s
23

34
%struct.LIST_NODE.0.16 = type { %struct.LIST_NODE.0.16*, i8* }
45

@@ -26,3 +27,24 @@ bb3: ; preds = %bb2, %entry
2627
bb5: ; preds = %bb3, %bb
2728
ret %struct.LIST_NODE.0.16* null
2829
}
30+
31+
declare void @use(i32)
32+
define double @find_max_double(i32 %n, double* nocapture readonly %aa) {
33+
entry:
34+
;CHECK-LABEL: find_max_double:
35+
br i1 undef, label %for.body, label %for.end
36+
37+
for.body: ; preds = %for.body, %entry
38+
%0 = load double* null, align 8
39+
%cmp2.6 = fcmp ogt double %0, 0.000000e+00
40+
%idx.1.6 = select i1 %cmp2.6, i32 undef, i32 0
41+
%idx.1.7 = select i1 undef, i32 undef, i32 %idx.1.6
42+
%max.1.7 = select i1 undef, double 0.000000e+00, double undef
43+
br i1 undef, label %for.end, label %for.body
44+
45+
for.end: ; preds = %for.body, %entry
46+
%max.0.lcssa = phi double [ undef, %entry ], [ %max.1.7, %for.body ]
47+
%idx.0.lcssa = phi i32 [ 0, %entry ], [ %idx.1.7, %for.body ]
48+
tail call void @use(i32 %idx.0.lcssa)
49+
ret double %max.0.lcssa
50+
}

0 commit comments

Comments
 (0)