module foo;

fn int test()
{
    static int x = 1;
    tlocal int y = 2;
    x++;
    return x;
}

/* #expect: foo.ll

@test.x = internal unnamed_addr global i32 1, align 4
@test.y = internal thread_local(localdynamic) unnamed_addr global i32 2, align 4

define i32 @foo.test() #0 {
entry:
  %0 = call ptr @llvm.threadlocal.address.p0(ptr @test.y)
  %1 = load i32, ptr @test.x, align 4
  %add = add i32 %1, 1
  store i32 %add, ptr @test.x, align 4
  %2 = load i32, ptr @test.x, align 4
  ret i32 %2
}