200 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 42; RUN: llc < %s -mtriple=i686 --relocation-model=pic -enable-tlsdesc | FileCheck %s --check-prefix=X863; RUN: llc < %s -mtriple=x86_64-pc-linux-gnux32 --relocation-model=pic -enable-tlsdesc | FileCheck %s --check-prefix=X324; RUN: llc < %s -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc | FileCheck %s --check-prefix=X645 6@x = thread_local global i32 0, align 47@y = internal thread_local global i32 1, align 48@z = external hidden thread_local global i32, align 49 10define ptr @f1() nounwind {11; X86-LABEL: f1:12; X86: # %bb.0:13; X86-NEXT: pushl %ebp14; X86-NEXT: pushl %ebx15; X86-NEXT: pushl %edi16; X86-NEXT: pushl %esi17; X86-NEXT: pushl %eax18; X86-NEXT: calll .L0$pb19; X86-NEXT: .L0$pb:20; X86-NEXT: popl %ebx21; X86-NEXT: .Ltmp0:22; X86-NEXT: addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb), %ebx23; X86-NEXT: #APP24; X86-NEXT: #NO_APP25; X86-NEXT: movl %eax, (%esp) # 4-byte Spill26; X86-NEXT: leal x@tlsdesc(%ebx), %eax27; X86-NEXT: calll *x@tlscall(%eax)28; X86-NEXT: addl %gs:0, %eax29; X86-NEXT: movl (%esp), %ebx # 4-byte Reload30; X86-NEXT: #APP31; X86-NEXT: #NO_APP32; X86-NEXT: addl $4, %esp33; X86-NEXT: popl %esi34; X86-NEXT: popl %edi35; X86-NEXT: popl %ebx36; X86-NEXT: popl %ebp37; X86-NEXT: retl38;39; X32-LABEL: f1:40; X32: # %bb.0:41; X32-NEXT: pushq %rax42; X32-NEXT: #APP43; X32-NEXT: #NO_APP44; X32-NEXT: leal x@tlsdesc(%rip), %eax45; X32-NEXT: callq *x@tlscall(%eax)46; X32-NEXT: # kill: def $eax killed $eax def $rax47; X32-NEXT: addl %fs:0, %eax48; X32-NEXT: #APP49; X32-NEXT: #NO_APP50; X32-NEXT: popq %rcx51; X32-NEXT: retq52;53; X64-LABEL: f1:54; X64: # %bb.0:55; X64-NEXT: pushq %rax56; X64-NEXT: #APP57; X64-NEXT: #NO_APP58; X64-NEXT: leaq x@tlsdesc(%rip), %rax59; X64-NEXT: callq *x@tlscall(%rax)60; X64-NEXT: addq %fs:0, %rax61; X64-NEXT: #APP62; X64-NEXT: #NO_APP63; X64-NEXT: popq %rcx64; X64-NEXT: retq65 %a = call { i32, i32, i32, i32, i32, i32 } asm sideeffect "", "=r,=r,=r,=r,=r,=r,~{dirflag},~{fpsr},~{flags}"()66 %b = call ptr @llvm.threadlocal.address.p0(ptr @x)67 %a.0 = extractvalue { i32, i32, i32, i32, i32, i32 } %a, 068 %a.1 = extractvalue { i32, i32, i32, i32, i32, i32 } %a, 169 %a.2 = extractvalue { i32, i32, i32, i32, i32, i32 } %a, 270 %a.3 = extractvalue { i32, i32, i32, i32, i32, i32 } %a, 371 %a.4 = extractvalue { i32, i32, i32, i32, i32, i32 } %a, 472 %a.5 = extractvalue { i32, i32, i32, i32, i32, i32 } %a, 573 call void asm sideeffect "", "r,r,r,r,r,r,~{dirflag},~{fpsr},~{flags}"(i32 %a.0, i32 %a.1, i32 %a.2, i32 %a.3, i32 %a.4, i32 %a.5)74 ret ptr %b75}76 77define i32 @f2() nounwind {78; X86-LABEL: f2:79; X86: # %bb.0:80; X86-NEXT: pushl %ebx81; X86-NEXT: calll .L1$pb82; X86-NEXT: .L1$pb:83; X86-NEXT: popl %ebx84; X86-NEXT: .Ltmp1:85; X86-NEXT: addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp1-.L1$pb), %ebx86; X86-NEXT: movl %gs:0, %ecx87; X86-NEXT: leal x@tlsdesc(%ebx), %eax88; X86-NEXT: calll *x@tlscall(%eax)89; X86-NEXT: movl (%eax,%ecx), %eax90; X86-NEXT: popl %ebx91; X86-NEXT: retl92;93; X32-LABEL: f2:94; X32: # %bb.0:95; X32-NEXT: pushq %rax96; X32-NEXT: movl %fs:0, %ecx97; X32-NEXT: leal x@tlsdesc(%rip), %eax98; X32-NEXT: callq *x@tlscall(%eax)99; X32-NEXT: movl (%eax,%ecx), %eax100; X32-NEXT: popq %rcx101; X32-NEXT: retq102;103; X64-LABEL: f2:104; X64: # %bb.0:105; X64-NEXT: pushq %rax106; X64-NEXT: movq %fs:0, %rcx107; X64-NEXT: leaq x@tlsdesc(%rip), %rax108; X64-NEXT: callq *x@tlscall(%rax)109; X64-NEXT: movl (%rax,%rcx), %eax110; X64-NEXT: popq %rcx111; X64-NEXT: retq112 %1 = tail call ptr @llvm.threadlocal.address.p0(ptr @x)113 %2 = load i32, ptr %1114 ret i32 %2115}116 117define ptr @f3() nounwind {118; X86-LABEL: f3:119; X86: # %bb.0:120; X86-NEXT: pushl %ebx121; X86-NEXT: calll .L2$pb122; X86-NEXT: .L2$pb:123; X86-NEXT: popl %ebx124; X86-NEXT: .Ltmp2:125; X86-NEXT: addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp2-.L2$pb), %ebx126; X86-NEXT: leal x@tlsdesc(%ebx), %eax127; X86-NEXT: calll *x@tlscall(%eax)128; X86-NEXT: addl %gs:0, %eax129; X86-NEXT: popl %ebx130; X86-NEXT: retl131;132; X32-LABEL: f3:133; X32: # %bb.0:134; X32-NEXT: pushq %rax135; X32-NEXT: leal x@tlsdesc(%rip), %eax136; X32-NEXT: callq *x@tlscall(%eax)137; X32-NEXT: # kill: def $eax killed $eax def $rax138; X32-NEXT: addl %fs:0, %eax139; X32-NEXT: popq %rcx140; X32-NEXT: retq141;142; X64-LABEL: f3:143; X64: # %bb.0:144; X64-NEXT: pushq %rax145; X64-NEXT: leaq x@tlsdesc(%rip), %rax146; X64-NEXT: callq *x@tlscall(%rax)147; X64-NEXT: addq %fs:0, %rax148; X64-NEXT: popq %rcx149; X64-NEXT: retq150 %1 = tail call ptr @llvm.threadlocal.address.p0(ptr @x)151 ret ptr %1152}153 154define i32 @f4() nounwind {155; X86-LABEL: f4:156; X86: # %bb.0:157; X86-NEXT: pushl %ebx158; X86-NEXT: calll .L3$pb159; X86-NEXT: .L3$pb:160; X86-NEXT: popl %ebx161; X86-NEXT: .Ltmp3:162; X86-NEXT: addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp3-.L3$pb), %ebx163; X86-NEXT: movl %gs:0, %edx164; X86-NEXT: leal _TLS_MODULE_BASE_@tlsdesc(%ebx), %eax165; X86-NEXT: calll *_TLS_MODULE_BASE_@tlscall(%eax)166; X86-NEXT: movl y@DTPOFF(%eax,%edx), %ecx167; X86-NEXT: addl z@DTPOFF(%eax,%edx), %ecx168; X86-NEXT: movl %ecx, %eax169; X86-NEXT: popl %ebx170; X86-NEXT: retl171;172; X32-LABEL: f4:173; X32: # %bb.0:174; X32-NEXT: pushq %rax175; X32-NEXT: movl %fs:0, %edx176; X32-NEXT: leal _TLS_MODULE_BASE_@tlsdesc(%rip), %eax177; X32-NEXT: callq *_TLS_MODULE_BASE_@tlscall(%eax)178; X32-NEXT: movl y@DTPOFF(%eax,%edx), %ecx179; X32-NEXT: addl z@DTPOFF(%eax,%edx), %ecx180; X32-NEXT: movl %ecx, %eax181; X32-NEXT: popq %rcx182; X32-NEXT: retq183;184; X64-LABEL: f4:185; X64: # %bb.0:186; X64-NEXT: pushq %rax187; X64-NEXT: movq %fs:0, %rdx188; X64-NEXT: leaq _TLS_MODULE_BASE_@tlsdesc(%rip), %rax189; X64-NEXT: callq *_TLS_MODULE_BASE_@tlscall(%rax)190; X64-NEXT: movl y@DTPOFF(%rax,%rdx), %ecx191; X64-NEXT: addl z@DTPOFF(%rax,%rdx), %ecx192; X64-NEXT: movl %ecx, %eax193; X64-NEXT: popq %rcx194; X64-NEXT: retq195 %1 = load i32, ptr @y, align 4196 %2 = load i32, ptr @z, align 4197 %3 = add nsw i32 %1, %2198 ret i32 %3199}200