llvm.org GIT mirror llvm / 40cd57e
[ARM] Fix a bug in constant island pass that was triggering an assertion. The assert was being triggered when the distance between a constant pool entry and its user exceeded the maximally allowed distance after thumb2 branch shortening. A padding was inserted after a thumb2 branch instruction was shrunk, which caused the user to be out of range. This is wrong as the padding should have been inserted by the layout algorithm so that the distance between two instructions doesn't grow later during thumb2 instruction optimization. This commit fixes the code in ARMConstantIslands::createNewWater to call computeBlockSize and set BasicBlock::Unalign when a branch instruction is inserted to create new water after a basic block. A non-zero Unalign causes the worst-case padding to be inserted when adjustBBOffsetsAfter is called to recompute the basic block offsets. rdar://problem/19130476 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225467 91177308-0d34-0410-b5e6-96231b3b80d8 Akira Hatanaka 5 years ago
2 changed file(s) with 43 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
12691269 unsigned MaxDisp = getUnconditionalBrDisp(UncondBr);
12701270 ImmBranches.push_back(ImmBranch(&UserMBB->back(),
12711271 MaxDisp, false, UncondBr));
1272 BBInfo[UserMBB->getNumber()].Size += Delta;
1272 computeBlockSize(UserMBB);
12731273 adjustBBOffsetsAfter(UserMBB);
12741274 return;
12751275 }
0 ; RUN: llc < %s -mtriple=thumbv7-apple-ios %s -o - | FileCheck %s
1
2 @g0 = common global i32 0, align 4
3 @d0 = common global double 0.000000e+00, align 8
4 @f0 = common global float 0.000000e+00, align 4
5 @g1 = common global i32 0, align 4
6
7 declare i32 @llvm.arm.space(i32, i32)
8
9 ; Check that the constant island pass moves the float constant pool entry inside
10 ; the function.
11
12 ; CHECK: .long 1067320814 @ float 1.23455596
13 ; CHECK: {{.*}} %do.end
14
15 define i32 @testpadding(i32 %a) {
16 entry:
17 %0 = load i32* @g0, align 4
18 %add = add nsw i32 %0, 12
19 store i32 %add, i32* @g0, align 4
20 %1 = load double* @d0, align 8
21 %add1 = fadd double %1, 0x3FF3C0B8ED46EACB
22 store double %add1, double* @d0, align 8
23 %tmpcall11 = call i32 @llvm.arm.space(i32 28, i32 undef)
24 call void @foo20(i32 191)
25 %2 = load float* @f0, align 4
26 %add2 = fadd float %2, 0x3FF3C0BDC0000000
27 store float %add2, float* @f0, align 4
28 br label %do.body
29
30 do.body: ; preds = %do.body, %entry
31 tail call void @foo20(i32 19)
32 %3 = load i32* @g1, align 4
33 %tobool = icmp eq i32 %3, 0
34 br i1 %tobool, label %do.end, label %do.body
35
36 do.end: ; preds = %do.body
37 %tmpcall111 = call i32 @llvm.arm.space(i32 954, i32 undef)
38 ret i32 10
39 }
40
41 declare void @foo20(i32)