From: Hans Wennborg Date: Fri, 26 Apr 2019 08:31:00 +0000 (+0000) Subject: Fix alignment in AArch64InstructionSelector::emitConstantPoolEntry() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d51e7039947344978a225dc5074f6ae2e33feab2;p=llvm Fix alignment in AArch64InstructionSelector::emitConstantPoolEntry() The code was using the alignment of a pointer to the value, not the alignment of the constant itself. Maybe we got away with it so far because the pointer alignment is fairly high, but we did end up under-aligning <16 x i8> vectors, which was caught in the Chromium build after lld stopped over-aligning the .rodata.cst16 section in r356428. (See crbug.com/953815) Differential revision: https://reviews.llvm.org/D61124 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359287 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/AArch64/AArch64InstructionSelector.cpp b/lib/Target/AArch64/AArch64InstructionSelector.cpp index 51501c1a9c7..8a3310bf4e3 100644 --- a/lib/Target/AArch64/AArch64InstructionSelector.cpp +++ b/lib/Target/AArch64/AArch64InstructionSelector.cpp @@ -2572,7 +2572,7 @@ void AArch64InstructionSelector::collectShuffleMaskIndices( unsigned AArch64InstructionSelector::emitConstantPoolEntry(Constant *CPVal, MachineFunction &MF) const { - Type *CPTy = CPVal->getType()->getPointerTo(); + Type *CPTy = CPVal->getType(); unsigned Align = MF.getDataLayout().getPrefTypeAlignment(CPTy); if (Align == 0) Align = MF.getDataLayout().getTypeAllocSize(CPTy); diff --git a/test/CodeGen/AArch64/GlobalISel/select-shuffle-vector.mir b/test/CodeGen/AArch64/GlobalISel/select-shuffle-vector.mir index 008c43fad63..20f3c38005d 100644 --- a/test/CodeGen/AArch64/GlobalISel/select-shuffle-vector.mir +++ b/test/CodeGen/AArch64/GlobalISel/select-shuffle-vector.mir @@ -82,7 +82,7 @@ body: | ; CHECK-LABEL: name: shuffle_v4i32 ; CHECK: constants: ; CHECK: value: '<16 x i8> ' - ; CHECK: alignment: 8 + ; CHECK: alignment: 16 ; CHECK: isTargetSpecific: false ; CHECK: liveins: $q0, $q1 ; CHECK: [[COPY:%[0-9]+]]:fpr128 = COPY $q0 @@ -117,7 +117,7 @@ body: | ; CHECK-LABEL: name: shuffle_tbl_v4i32 ; CHECK: constants: ; CHECK: value: '<16 x i8> ' - ; CHECK: alignment: 8 + ; CHECK: alignment: 16 ; CHECK: isTargetSpecific: false ; CHECK: liveins: $q0, $q1 ; CHECK: [[COPY:%[0-9]+]]:fpr128 = COPY $q0 @@ -153,7 +153,7 @@ body: | ; CHECK-LABEL: name: shuffle_v2i64 ; CHECK: constants: ; CHECK: value: '<16 x i8> ' - ; CHECK: alignment: 8 + ; CHECK: alignment: 16 ; CHECK: isTargetSpecific: false ; CHECK: liveins: $q0, $q1 ; CHECK: [[COPY:%[0-9]+]]:fpr128 = COPY $q0