1; RUN: llc < %s -emulated-tls -relocation-model=pic -mtriple=i686-unknown-linux-gnu -fast-isel | FileCheck %s 2; RUN: llc < %s -relocation-model=pic -mtriple=i686-unknown-linux-gnu -fast-isel \ 3; RUN: | FileCheck -check-prefix=NoEMU %s 4; PR3654 5 6; NoEMU-NOT: __emutls 7 8@v = thread_local global i32 0 9define i32 @f() nounwind { 10entry: 11 %t = load i32, i32* @v 12 %s = add i32 %t, 1 13 ret i32 %s 14} 15 16; CHECK-LABEL: f: 17; CHECK: movl __emutls_v.v@GOT(%ebx), %eax 18; CHECK-NEXT: movl %eax, (%esp) 19; CHECK-NEXT: calll __emutls_get_address@PLT 20; CHECK-NEXT: movl (%eax), %eax 21 22@alias = internal alias i32, i32* @v 23define i32 @f_alias() nounwind { 24entry: 25 %t = load i32, i32* @v 26 %s = add i32 %t, 1 27 ret i32 %s 28} 29 30; CHECK-LABEL: f_alias: 31; CHECK: movl __emutls_v.v@GOT(%ebx), %eax 32; CHECK-NEXT: movl %eax, (%esp) 33; CHECK-NEXT: calll __emutls_get_address@PLT 34; CHECK-NEXT: movl (%eax), %eax 35 36; Use my_emutls_get_address like __emutls_get_address. 37@my_emutls_v_xyz = external global i8*, align 4 38declare i8* @my_emutls_get_address(i8*) 39 40define i32 @my_get_xyz() { 41entry: 42 %call = call i8* @my_emutls_get_address(i8* bitcast (i8** @my_emutls_v_xyz to i8*)) 43 %0 = bitcast i8* %call to i32* 44 %1 = load i32, i32* %0, align 4 45 ret i32 %1 46} 47 48; CHECK-LABEL: my_get_xyz: 49; CHECK: movl my_emutls_v_xyz@GOT(%ebx), %eax 50; CHECK-NEXT: movl %eax, (%esp) 51; CHECK-NEXT: calll my_emutls_get_address@PLT 52; CHECK-NEXT: movl (%eax), %eax 53