340 lines · plain
1; RUN: llc < %s -emulated-tls -mtriple=i386-linux-gnu | FileCheck -check-prefix=X86 %s2; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-gnu | FileCheck -check-prefix=X64 %s3; RUN: llc < %s -emulated-tls -mtriple=i386-linux-android | FileCheck -check-prefix=X86 %s4; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-android | FileCheck -check-prefix=X64 %s5 6; RUN: llc < %s -mtriple=i386-linux-gnu | FileCheck -check-prefix=NoEMU %s7; RUN: llc < %s -mtriple=x86_64-linux-gnu | FileCheck -check-prefix=NoEMU %s8; RUN: llc < %s -mtriple=i386-linux-android | FileCheck -check-prefix=X86 %s9; RUN: llc < %s -mtriple=x86_64-linux-android | FileCheck -check-prefix=X64 %s10 11; Copied from tls.ll; emulated TLS model is not implemented12; for *-pc-win32 and *-pc-windows targets yet.13 14; NoEMU-NOT: __emutls15 16; Use my_emutls_get_address like __emutls_get_address.17@my_emutls_v_xyz = external global ptr, align 418declare ptr @my_emutls_get_address(ptr)19 20define dso_local i32 @my_get_xyz() {21; X86-LABEL: my_get_xyz:22; X86: movl $my_emutls_v_xyz, (%esp)23; X86-NEXT: calll my_emutls_get_address24; X86-NEXT: movl (%eax), %eax25; X86-NEXT: addl $12, %esp26; X86-NEXT: .cfi_def_cfa_offset 427; X86-NEXT: retl28;29; X64-LABEL: my_get_xyz:30; X64: movq my_emutls_v_xyz@GOTPCREL(%rip), %rdi31; X64-NEXT: callq my_emutls_get_address32; X64-NEXT: movl (%rax), %eax33; X64-NEXT: popq %rcx34; X64-NEXT: .cfi_def_cfa_offset 835; X64-NEXT: retq36entry:37 %call = call ptr @my_emutls_get_address(ptr @my_emutls_v_xyz)38 %0 = load i32, ptr %call, align 439 ret i32 %040}41 42@i1 = dso_local thread_local global i32 1543@i2 = external thread_local global i3244@i3 = internal thread_local global i32 1545@i4 = hidden thread_local global i32 1546@i5 = external hidden thread_local global i3247@s1 = dso_local thread_local global i16 1548@b1 = dso_local thread_local global i8 049 50define dso_local i32 @f1() {51; X86-LABEL: f1:52; X86: movl $__emutls_v.i1, (%esp)53; X86-NEXT: calll __emutls_get_address54; X86-NEXT: movl (%eax), %eax55; X86-NEXT: addl $12, %esp56; X86-NEXT: .cfi_def_cfa_offset 457; X86-NEXT: retl58;59; X64-LABEL: f1:60; X64: movl $__emutls_v.i1, %edi61; X64-NEXT: callq __emutls_get_address62; X64-NEXT: movl (%rax), %eax63; X64-NEXT: popq %rcx64; X64-NEXT: .cfi_def_cfa_offset 865; X64-NEXT: retq66entry:67 %tmp1 = load i32, ptr @i168 ret i32 %tmp169}70 71define dso_local ptr @f2() {72; X86-LABEL: f2:73; X86: movl $__emutls_v.i1, (%esp)74; X86-NEXT: calll __emutls_get_address75; X86-NEXT: addl $12, %esp76; X86-NEXT: .cfi_def_cfa_offset 477; X86-NEXT: retl78;79; X64-LABEL: f2:80; X64: movl $__emutls_v.i1, %edi81; X64-NEXT: callq __emutls_get_address82; X64-NEXT: popq %rcx83; X64-NEXT: .cfi_def_cfa_offset 884; X64-NEXT: retq85entry:86 ret ptr @i187}88 89define dso_local i32 @f3() nounwind {90; X86-LABEL: f3:91; X86: movl $__emutls_v.i2, (%esp)92; X86-NEXT: calll __emutls_get_address93; X86-NEXT: movl (%eax), %eax94; X86-NEXT: addl $12, %esp95; X86-NEXT: retl96entry:97 %tmp1 = load i32, ptr @i298 ret i32 %tmp199}100 101define dso_local ptr @f4() {102; X86-LABEL: f4:103; X86: movl $__emutls_v.i2, (%esp)104; X86-NEXT: calll __emutls_get_address105; X86-NEXT: addl $12, %esp106; X86-NEXT: .cfi_def_cfa_offset 4107; X86-NEXT: retl108entry:109 ret ptr @i2110}111 112define dso_local i32 @f5() nounwind {113; X86-LABEL: f5:114; X86: movl $__emutls_v.i3, (%esp)115; X86-NEXT: calll __emutls_get_address116; X86-NEXT: movl (%eax), %eax117; X86-NEXT: addl $12, %esp118; X86-NEXT: retl119entry:120 %tmp1 = load i32, ptr @i3121 ret i32 %tmp1122}123 124define dso_local ptr @f6() {125; X86-LABEL: f6:126; X86: movl $__emutls_v.i3, (%esp)127; X86-NEXT: calll __emutls_get_address128; X86-NEXT: addl $12, %esp129; X86-NEXT: .cfi_def_cfa_offset 4130; X86-NEXT: retl131entry:132 ret ptr @i3133}134 135define dso_local i32 @f7() {136; X86-LABEL: f7:137; X86: movl $__emutls_v.i4, (%esp)138; X86-NEXT: calll __emutls_get_address139; X86-NEXT: movl (%eax), %eax140; X86-NEXT: addl $12, %esp141; X86-NEXT: .cfi_def_cfa_offset 4142; X86-NEXT: retl143entry:144 %tmp1 = load i32, ptr @i4145 ret i32 %tmp1146}147 148define dso_local ptr @f8() {149; X86-LABEL: f8:150; X86: movl $__emutls_v.i4, (%esp)151; X86-NEXT: calll __emutls_get_address152; X86-NEXT: addl $12, %esp153; X86-NEXT: .cfi_def_cfa_offset 4154; X86-NEXT: retl155entry:156 ret ptr @i4157}158 159define dso_local i32 @f9() {160; X86-LABEL: f9:161; X86: movl $__emutls_v.i5, (%esp)162; X86-NEXT: calll __emutls_get_address163; X86-NEXT: movl (%eax), %eax164; X86-NEXT: addl $12, %esp165; X86-NEXT: .cfi_def_cfa_offset 4166; X86-NEXT: retl167entry:168 %tmp1 = load i32, ptr @i5169 ret i32 %tmp1170}171 172define dso_local ptr @f10() {173; X86-LABEL: f10:174; X86: movl $__emutls_v.i5, (%esp)175; X86-NEXT: calll __emutls_get_address176; X86-NEXT: addl $12, %esp177; X86-NEXT: .cfi_def_cfa_offset 4178; X86-NEXT: retl179entry:180 ret ptr @i5181}182 183define dso_local i16 @f11() {184; X86-LABEL: f11:185; X86: movl $__emutls_v.s1, (%esp)186; X86-NEXT: calll __emutls_get_address187; X86-NEXT: movzwl (%eax), %eax188; X86-NEXT: addl $12, %esp189; X86-NEXT: .cfi_def_cfa_offset 4190; X86-NEXT: retl191entry:192 %tmp1 = load i16, ptr @s1193 ret i16 %tmp1194}195 196define dso_local i32 @f12() {197; X86-LABEL: f12:198; X86: movl $__emutls_v.s1, (%esp)199; X86-NEXT: calll __emutls_get_address200; X86-NEXT: movswl (%eax), %eax201; X86-NEXT: addl $12, %esp202; X86-NEXT: .cfi_def_cfa_offset 4203; X86-NEXT: retl204entry:205 %tmp1 = load i16, ptr @s1206 %tmp2 = sext i16 %tmp1 to i32207 ret i32 %tmp2208}209 210define dso_local i8 @f13() {211; X86-LABEL: f13:212; X86: movl $__emutls_v.b1, (%esp)213; X86-NEXT: calll __emutls_get_address214; X86-NEXT: movzbl (%eax), %eax215; X86-NEXT: addl $12, %esp216; X86-NEXT: .cfi_def_cfa_offset 4217; X86-NEXT: retl218entry:219 %tmp1 = load i8, ptr @b1220 ret i8 %tmp1221}222 223define dso_local i32 @f14() {224; X86-LABEL: f14:225; X86: movl $__emutls_v.b1, (%esp)226; X86-NEXT: calll __emutls_get_address227; X86-NEXT: movsbl (%eax), %eax228; X86-NEXT: addl $12, %esp229; X86-NEXT: .cfi_def_cfa_offset 4230; X86-NEXT: retl231entry:232 %tmp1 = load i8, ptr @b1233 %tmp2 = sext i8 %tmp1 to i32234 ret i32 %tmp2235}236 237;;;;;;;;;;;;;; 32-bit __emutls_v. and __emutls_t.238 239; X86-LABEL: __emutls_v.i1:240; X86-NEXT: .long 4241; X86-NEXT: .long 4242; X86-NEXT: .long 0243; X86-NEXT: .long __emutls_t.i1244 245; X86-LABEL: __emutls_t.i1:246; X86-NEXT: .long 15247 248; X86-NOT: __emutls_v.i2249 250; X86-LABEL: __emutls_v.i3:251; X86-NEXT: .long 4252; X86-NEXT: .long 4253; X86-NEXT: .long 0254; X86-NEXT: .long __emutls_t.i3255 256; X86-LABEL: __emutls_t.i3:257; X86-NEXT: .long 15258 259; X86-LABEL: __emutls_v.i4:260; X86-NEXT: .long 4261; X86-NEXT: .long 4262; X86-NEXT: .long 0263; X86-NEXT: .long __emutls_t.i4264 265; X86-LABEL: __emutls_t.i4:266; X86-NEXT: .long 15267 268; X86-NOT: __emutls_v.i5:269; X86: .hidden __emutls_v.i5270; X86-NOT: __emutls_v.i5:271 272; X86-LABEL: __emutls_v.s1:273; X86-NEXT: .long 2274; X86-NEXT: .long 2275; X86-NEXT: .long 0276; X86-NEXT: .long __emutls_t.s1277 278; X86-LABEL: __emutls_t.s1:279; X86-NEXT: .short 15280 281; X86-LABEL: __emutls_v.b1:282; X86-NEXT: .long 1283; X86-NEXT: .long 1284; X86-NEXT: .long 0285; X86-NEXT: .long 0286 287; X86-NOT: __emutls_t.b1288 289;;;;;;;;;;;;;; 64-bit __emutls_v. and __emutls_t.290 291; X64-LABEL: __emutls_v.i1:292; X64-NEXT: .quad 4293; X64-NEXT: .quad 4294; X64-NEXT: .quad 0295; X64-NEXT: .quad __emutls_t.i1296 297; X64-LABEL: __emutls_t.i1:298; X64-NEXT: .long 15299 300; X64-NOT: __emutls_v.i2301 302; X64-LABEL: __emutls_v.i3:303; X64-NEXT: .quad 4304; X64-NEXT: .quad 4305; X64-NEXT: .quad 0306; X64-NEXT: .quad __emutls_t.i3307 308; X64-LABEL: __emutls_t.i3:309; X64-NEXT: .long 15310 311; X64-LABEL: __emutls_v.i4:312; X64-NEXT: .quad 4313; X64-NEXT: .quad 4314; X64-NEXT: .quad 0315; X64-NEXT: .quad __emutls_t.i4316 317; X64-LABEL: __emutls_t.i4:318; X64-NEXT: .long 15319 320; X64-NOT: __emutls_v.i5:321; X64: .hidden __emutls_v.i5322; X64-NOT: __emutls_v.i5:323 324; X64-LABEL: __emutls_v.s1:325; X64-NEXT: .quad 2326; X64-NEXT: .quad 2327; X64-NEXT: .quad 0328; X64-NEXT: .quad __emutls_t.s1329 330; X64-LABEL: __emutls_t.s1:331; X64-NEXT: .short 15332 333; X64-LABEL: __emutls_v.b1:334; X64-NEXT: .quad 1335; X64-NEXT: .quad 1336; X64-NEXT: .quad 0337; X64-NEXT: .quad 0338 339; X64-NOT: __emutls_t.b1340