diff options
| author | Eli Friedman <efriedma@codeaurora.org> | 2018-09-28 20:21:51 +0000 |
|---|---|---|
| committer | Eli Friedman <efriedma@codeaurora.org> | 2018-09-28 20:21:51 +0000 |
| commit | bb993be56bb38e46c029b682f67fd1b7dc4b9111 (patch) | |
| tree | 162f6e76725f729cea3d11655706e9c73de44414 | |
| parent | b62f73420b91a430e68f60fee350e2a603d91d6f (diff) | |
| download | bcm5719-llvm-bb993be56bb38e46c029b682f67fd1b7dc4b9111.tar.gz bcm5719-llvm-bb993be56bb38e46c029b682f67fd1b7dc4b9111.zip | |
[ARM] Use preferred alignment for constants in promoteToConstantPool.
This mostly affects IR generated by non-clang frontends because clang
generally sets the alignment of globals explicitly.
Fixes https://bugs.llvm.org//show_bug.cgi?id=32394 .
(-arm-promote-constant is currently off by default, and it stays off
with this patch. I'll look into turning it on again when all the known
issues are fixed.)
Differential Revision: https://reviews.llvm.org/D51469
llvm-svn: 343359
| -rw-r--r-- | llvm/lib/Target/ARM/ARMISelLowering.cpp | 2 | ||||
| -rw-r--r-- | llvm/test/CodeGen/ARM/constantpool-promote.ll | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index 16111557650..15b64ef1173 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -3148,7 +3148,7 @@ static SDValue promoteToConstantPool(const GlobalValue *GV, SelectionDAG &DAG, // that are strings for simplicity. auto *CDAInit = dyn_cast<ConstantDataArray>(Init); unsigned Size = DAG.getDataLayout().getTypeAllocSize(Init->getType()); - unsigned Align = GVar->getAlignment(); + unsigned Align = DAG.getDataLayout().getPreferredAlignment(GVar); unsigned RequiredPadding = 4 - (Size % 4); bool PaddingPossible = RequiredPadding == 4 || (CDAInit && CDAInit->isString()); diff --git a/llvm/test/CodeGen/ARM/constantpool-promote.ll b/llvm/test/CodeGen/ARM/constantpool-promote.ll index ccd86257dd3..bea9c9f170c 100644 --- a/llvm/test/CodeGen/ARM/constantpool-promote.ll +++ b/llvm/test/CodeGen/ARM/constantpool-promote.ll @@ -22,6 +22,7 @@ @.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 +@implicit_alignment_vector = private unnamed_addr constant <4 x i32> <i32 1, i32 2, i32 3, i32 4> ; CHECK-LABEL: @test1 ; CHECK: adr r0, [[x:.*]] @@ -178,9 +179,19 @@ define void @test11(i16* %a) local_unnamed_addr #0 { ret void } +; Promotion only works with globals with alignment 4 or less; a vector has +; implicit alignment 16. +; CHECK-LABEL: @test12 +; CHECK-NOT: adr +define void @test12() local_unnamed_addr #0 { + call void @d(<4 x i32>* @implicit_alignment_vector) + ret void +} + declare void @b(i8*) #1 declare void @c(i16*) #1 +declare void @d(<4 x i32>*) #1 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1) declare void @llvm.memmove.p0i8.p0i8.i32(i8*, i8*, i32, i1) local_unnamed_addr declare void @llvm.memmove.p0i16.p0i16.i32(i16*, i16*, i32, i1) local_unnamed_addr |

