[PATCH] D31116: [ARM] handle promotion of zero sized constants.

Tim Neumann via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 18 04:35:58 PDT 2017


TimNN updated this revision to Diff 92250.
TimNN retitled this revision from "arm: don't promote too small constants" to "[ARM] handle promotion of zero sized constants.".
TimNN edited the summary of this revision.
TimNN added a comment.

I have updated the patch as suggested.


https://reviews.llvm.org/D31116

Files:
  lib/Target/ARM/ARMISelLowering.cpp
  test/CodeGen/ARM/constantpool-promote.ll


Index: test/CodeGen/ARM/constantpool-promote.ll
===================================================================
--- test/CodeGen/ARM/constantpool-promote.ll
+++ test/CodeGen/ARM/constantpool-promote.ll
@@ -21,6 +21,7 @@
 @.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
+ at .zerosize = private unnamed_addr constant [0 x i16] zeroinitializer, align 4
 
 ; CHECK-LABEL: @test1
 ; CHECK: adr r0, [[x:.*]]
@@ -139,6 +140,14 @@
   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
+}
+
 ; CHECK-LABEL: @test10
 ; CHECK-V6M: adr r{{[0-9]*}}, [[x:.*]]
 ; CHECK-V6M: [[x]]:
Index: lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- lib/Target/ARM/ARMISelLowering.cpp
+++ lib/Target/ARM/ARMISelLowering.cpp
@@ -3063,7 +3063,8 @@
   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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31116.92250.patch
Type: text/x-patch
Size: 1653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170318/ce921630/attachment.bin>


More information about the llvm-commits mailing list