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

Commit 321a494

Browse files
pftbestarielb1
authored andcommitted
[ARM] Fix PR32130: Handle promotion of zero sized constants.
The special case of zero sized values was previously not handled correctly. This patch handles this by not promoting if the size is zero. Patch by Tim Neumann. Differential Revision: https://reviews.llvm.org/D31116 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298320 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 01e00ed commit 321a494

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)