Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / thread_local.c
blobb97f31c2fff2f6cdcdeac1216370a8b7b64e9a21
1 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -std=c23 -emit-llvm -o - %s | FileCheck %s
3 // Ensure that thread_local and _Thread_local emit the same codegen. See
4 // https://github.com/llvm/llvm-project/issues/70068 for details.
6 void func(void) {
7 static thread_local int i = 12;
8 static _Thread_local int j = 13;
10 extern thread_local int k;
11 extern thread_local int l;
13 (void)k;
14 (void)l;
17 // CHECK: @func.i = internal thread_local global i32 12, align 4
18 // CHECK-NEXT: @func.j = internal thread_local global i32 13, align 4
19 // CHECK-NEXT: @k = external thread_local global i32, align 4
20 // CHECK-NEXT: @l = external thread_local global i32, align 4
22 // CHECK: define dso_local void @func()
23 // CHECK-NEXT: entry:
24 // CHECK-NEXT: %[[K:.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @k)
25 // CHECK-NEXT: load i32, ptr %[[K]], align 4
26 // CHECK-NEXT: %[[L:.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @l)
27 // CHECK-NEXT: load i32, ptr %[[L]], align 4