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

Backport "[ARM] Fix PR32130: Handle promotion of zero sized constants." #71

Merged
merged 1 commit into from
Apr 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/Target/ARM/ARMISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2980,7 +2980,8 @@ static SDValue promoteToConstantPool(const GlobalValue *GV, SelectionDAG &DAG,
unsigned RequiredPadding = 4 - (Size % 4);
bool PaddingPossible =
RequiredPadding == 4 || (CDAInit && CDAInit->isString());
if (!PaddingPossible || Align > 4 || Size > ConstpoolPromotionMaxSize)
if (!PaddingPossible || Align > 4 || Size > ConstpoolPromotionMaxSize ||
Size == 0)
return SDValue();

unsigned PaddedSize = Size + ((RequiredPadding == 4) ? 0 : RequiredPadding);
Expand Down
8 changes: 8 additions & 0 deletions test/CodeGen/ARM/constantpool-promote.ll
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ target triple = "armv7--linux-gnueabihf"
@.arr3 = private unnamed_addr constant [2 x i16*] [i16* null, i16* null], align 4
@.ptr = private unnamed_addr constant [2 x i16*] [i16* getelementptr inbounds ([2 x i16], [2 x i16]* @.arr2, i32 0, i32 0), i16* null], align 2
@.arr4 = private unnamed_addr constant [2 x i16] [i16 3, i16 4], align 16
@.zerosize = private unnamed_addr constant [0 x i16] zeroinitializer, align 4

; CHECK-LABEL: @test1
; CHECK: adr r0, [[x:.*]]
Expand Down Expand Up @@ -134,6 +135,13 @@ define void @test9() #0 {
ret void
}

; Ensure that zero sized values are supported / not promoted.
; CHECK-LABEL: @pr32130
; CHECK-NOT: adr
define void @pr32130() #0 {
tail call void @c(i16* getelementptr inbounds ([0 x i16], [0 x i16]* @.zerosize, i32 0, i32 0)) #2
ret void
}

declare void @b(i8*) #1
declare void @c(i16*) #1
Expand Down