Skip to content

Commit

Permalink
[ARM] f16 constant pool fix
Browse files Browse the repository at this point in the history
This is a follow up of r325012, that allowed half types in constant pools.
Proper alignment was enforced when a big basic block was split up, but not when
a CPE was placed before/after a block; the successor block had the wrong
alignment.

Differential Revision: https://reviews.llvm.org/D43580

llvm-svn: 325754
  • Loading branch information
Sjoerd Meijer committed Feb 22, 2018
1 parent 971514d commit 7d5909e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
6 changes: 2 additions & 4 deletions llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1425,10 +1425,6 @@ void ARMConstantIslands::createNewWater(unsigned CPUserIndex,
assert(!isThumb || getITInstrPredicate(*MI, PredReg) == ARMCC::AL));

NewMBB = splitBlockBeforeInstr(&*MI);

// 4 byte align the next block after the constant pool when the CPE is a
// 16-bit value in ARM mode, and 2 byte for Thumb.
NewMBB->setAlignment(isThumb ? 1 : 2);
}

/// handleConstantPoolUser - Analyze the specified user, checking to see if it
Expand Down Expand Up @@ -1489,6 +1485,8 @@ bool ARMConstantIslands::handleConstantPoolUser(unsigned CPUserIndex,
// We are adding new water. Update NewWaterList.
NewWaterList.insert(NewIsland);
}
// Always align the new block because CP entries can be smaller than 4 bytes.
NewMBB->setAlignment(isThumb ? 1 : 2);

// Remove the original WaterList entry; we want subsequent insertions in
// this vicinity to go after the one we're about to insert. This
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/ARM/constant-islands-cfg.mir
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fixedStack:
# CHECK: successors: %[[LONG_BR_BB:bb.[0-9]+]](0x{{[0-9a-f]+}}), %[[DEST1:bb.[0-9]+]](0x{{[0-9a-f]+}}){{$}}
# CHECK: tBcc %[[LONG_BR_BB]], 0, $cpsr
# CHECK: tB %[[DEST1]]
# CHECK: [[LONG_BR_BB]]:
# CHECK: [[LONG_BR_BB]] (align 1):
# CHECK: successors: %[[DEST2:bb.[0-9]+]](0x{{[0-9a-f]+}}){{$}}
# CHECK: tB %[[DEST2]]
# CHECK: [[DEST1]]:
Expand All @@ -52,7 +52,7 @@ body: |
tBcc %bb.2, 1, killed $cpsr
tB %bb.3, 14, $noreg
bb.1:
bb.1 (align 1):
dead $r0 = SPACE 256, undef $r0
bb.2:
Expand Down
4 changes: 3 additions & 1 deletion llvm/test/CodeGen/ARM/fp16-litpool-arm.mir
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# RUN: llc -mtriple=arm-none-eabi -run-pass=arm-cp-islands %s -o - | FileCheck %s

#
# This checks alignment of a new block when a big basic block is split up.
#
--- |
; ModuleID = '<stdin>'
source_filename = "<stdin>"
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/CodeGen/ARM/fp16-litpool-thumb.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# RUN: llc -mtriple=thumbv7-none-eabi -run-pass=arm-cp-islands %s -o - | FileCheck %s
#
# This checks alignment of a new block when a big basic block is split up.
#
--- |
; ModuleID = '<stdin>'
source_filename = "<stdin>"
Expand Down

0 comments on commit 7d5909e

Please sign in to comment.