28 lines · c
1// RUN: %clang_cc1 -triple i686-pc-linux-gnu -std=c23 -emit-llvm -o - %s | FileCheck %s2 3// Ensure that thread_local and _Thread_local emit the same codegen. See4// https://github.com/llvm/llvm-project/issues/70068 for details.5 6void func(void) {7 static thread_local int i = 12;8 static _Thread_local int j = 13;9 10 extern thread_local int k;11 extern thread_local int l;12 13 (void)k;14 (void)l;15}16 17// CHECK: @func.i = internal thread_local global i32 12, align 418// CHECK-NEXT: @func.j = internal thread_local global i32 13, align 419// CHECK-NEXT: @k = external thread_local global i32, align 420// CHECK-NEXT: @l = external thread_local global i32, align 421 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 426// CHECK-NEXT: %[[L:.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @l)27// CHECK-NEXT: load i32, ptr %[[L]], align 428