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

Commit 64449e1

Browse files
authored
Merge pull request #71 from TimNN/arm-backport-4.0
Backport "[ARM] Fix PR32130: Handle promotion of zero sized constants."
2 parents f1e7336 + 2680a42 commit 64449e1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2980,7 +2980,8 @@ static SDValue promoteToConstantPool(const GlobalValue *GV, SelectionDAG &DAG,
29802980
unsigned RequiredPadding = 4 - (Size % 4);
29812981
bool PaddingPossible =
29822982
RequiredPadding == 4 || (CDAInit && CDAInit->isString());
2983-
if (!PaddingPossible || Align > 4 || Size > ConstpoolPromotionMaxSize)
2983+
if (!PaddingPossible || Align > 4 || Size > ConstpoolPromotionMaxSize ||
2984+
Size == 0)
29842985
return SDValue();
29852986

29862987
unsigned PaddedSize = Size + ((RequiredPadding == 4) ? 0 : RequiredPadding);

test/CodeGen/ARM/constantpool-promote.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ target triple = "armv7--linux-gnueabihf"
1616
@.arr3 = private unnamed_addr constant [2 x i16*] [i16* null, i16* null], align 4
1717
@.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
1818
@.arr4 = private unnamed_addr constant [2 x i16] [i16 3, i16 4], align 16
19+
@.zerosize = private unnamed_addr constant [0 x i16] zeroinitializer, align 4
1920

2021
; CHECK-LABEL: @test1
2122
; CHECK: adr r0, [[x:.*]]
@@ -134,6 +135,13 @@ define void @test9() #0 {
134135
ret void
135136
}
136137

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

138146
declare void @b(i8*) #1
139147
declare void @c(i16*) #1

0 commit comments

Comments
 (0)