Fix emulated TLS alignment for large variables (#171037)
Fix emulated TLS alignment for larger variables (>= 32 bytes) to use preferred alignment. Fixes #167219
This commit is contained in:
parent
c4e6cf0abf
commit
9c64cb6dca
@ -146,7 +146,7 @@ bool addEmuTlsVar(Module &M, const GlobalVariable *GV) {
|
||||
return true;
|
||||
|
||||
Type *GVType = GV->getValueType();
|
||||
Align GVAlignment = DL.getValueOrABITypeAlignment(GV->getAlign(), GVType);
|
||||
Align GVAlignment = GV->getPointerAlignment(DL);
|
||||
|
||||
// Define "__emutls_t.*" if there is InitValue
|
||||
GlobalVariable *EmuTlsTmplVar = nullptr;
|
||||
|
||||
@ -175,7 +175,7 @@ entry:
|
||||
; ARM64: .globl __emutls_v.s1
|
||||
; ARM64-LABEL: __emutls_v.s1:
|
||||
; ARM64-NEXT: .xword 2
|
||||
; ARM64-NEXT: .xword 2
|
||||
; ARM64-NEXT: .xword 4
|
||||
; ARM64-NEXT: .xword 0
|
||||
; ARM64-NEXT: .xword __emutls_t.s1
|
||||
|
||||
@ -186,7 +186,7 @@ entry:
|
||||
; ARM64: .data{{$}}
|
||||
; ARM64-LABEL: __emutls_v.b1:
|
||||
; ARM64-NEXT: .xword 1
|
||||
; ARM64-NEXT: .xword 1
|
||||
; ARM64-NEXT: .xword 4
|
||||
; ARM64-NEXT: .xword 0
|
||||
; ARM64-NEXT: .xword 0
|
||||
|
||||
|
||||
20
llvm/test/CodeGen/ARM/emutls-alignment.ll
Normal file
20
llvm/test/CodeGen/ARM/emutls-alignment.ll
Normal file
@ -0,0 +1,20 @@
|
||||
; RUN: llc -emulated-tls -mtriple=armv7-linux-android -relocation-model=pic < %s | FileCheck %s
|
||||
|
||||
; Test that emulated TLS uses preferred alignment for variables.
|
||||
; This fixes a bug where emutls would use lower alignment than expected
|
||||
; by the code generator, causing crashes with vectorized accesses.
|
||||
; Fixes https://github.com/llvm/llvm-project/issues/167219
|
||||
|
||||
; A 64-byte array should get 16-byte alignment (preferred for ARM NEON).
|
||||
@large_array = internal thread_local global [64 x i8] c"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
|
||||
define ptr @get_large_array() {
|
||||
entry:
|
||||
ret ptr @large_array
|
||||
}
|
||||
|
||||
; CHECK-LABEL: __emutls_v.large_array:
|
||||
; CHECK-NEXT: .long 64
|
||||
; CHECK-NEXT: .long 16
|
||||
; CHECK-NEXT: .long 0
|
||||
; CHECK-NEXT: .long __emutls_t.large_array
|
||||
Loading…
x
Reference in New Issue
Block a user