[PATCH] D88646: [LLD] Add baseline test for TLS alignment. NFC.

Luqman Aden via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 03:37:41 PDT 2020


luqmana updated this revision to Diff 295520.
luqmana added a comment.

Update.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88646/new/

https://reviews.llvm.org/D88646

Files:
  lld/test/COFF/tls-alignment.ll


Index: lld/test/COFF/tls-alignment.ll
===================================================================
--- /dev/null
+++ lld/test/COFF/tls-alignment.ll
@@ -0,0 +1,47 @@
+; This test is to make sure that the necessary alignment for thread locals
+; gets reflected in the TLS Directory of the generated executable.
+;
+; aligned_thread_local specifies 'align 32' and so the generated
+; exe should reflect that with a value of IMAGE_SCN_ALIGN_32BYTES
+; in the Characteristics field of the IMAGE_TLS_DIRECTORY
+
+; RUN: llc -filetype=obj %s -o %t.obj
+; RUN: lld-link %t.obj -entry:main -nodefaultlib -out:%t.exe
+; RUN: llvm-readobj --coff-tls-directory %t.exe | FileCheck %s
+
+; CHECK: Characteristics [ (0x0)
+
+target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc"
+
+%IMAGE_TLS_DIRECTORY = type {
+    i64,    ; StartAddressOfRawData
+    i64,    ; EndAddressOfRawData
+    i64,    ; AddressOfIndex
+    i64,    ; AddressOfCallBacks
+    i32,    ; SizeOfZeroFill
+    i32     ; Characteristics
+}
+
+; We manually create these here as we're not linking against
+; the CRT which would usually provide these.
+ at _tls_start = global i8 zeroinitializer, section ".tls"
+ at _tls_end = global i8 zeroinitializer, section ".tls$ZZZ"
+ at _tls_index = global i64 1
+ at _tls_used = global %IMAGE_TLS_DIRECTORY {
+    i64 ptrtoint (i8* @_tls_start to i64),
+    i64 ptrtoint (i8* @_tls_end to i64),
+    i64 ptrtoint (i64* @_tls_index to i64),
+    i64 0,
+    i32 0,
+    i32 0
+}, section ".rdata$T"
+
+ at _fltused = global i8 zeroinitializer
+
+ at aligned_thread_local = thread_local global [32 x i8] zeroinitializer, align 32
+
+define i32 @main() #0 {
+  store <8 x float> zeroinitializer, <8 x float>* bitcast ([32 x i8]* @aligned_thread_local to <8 x float>*), align 32
+  ret i32 0
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88646.295520.patch
Type: text/x-patch
Size: 1859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201001/5a5acb67/attachment.bin>


More information about the llvm-commits mailing list