brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 95dd434 Raw
60 lines · plain
1; RUN: llc < %s -mtriple=x86_64-linux-gnu -relocation-model=pic | FileCheck  %s2 3@x = internal thread_local global i32 0, align 44@y = internal thread_local global i32 0, align 45 6; get_x and get_y are here to prevent x and y to be optimized away as 07 8define ptr @get_x() {9entry:10  ret ptr @x11; FIXME: This function uses a single thread-local variable,12; so we might want to fall back to general-dynamic here.13; CHECK-LABEL:       get_x:14; CHECK:       leaq x@TLSLD(%rip), %rdi15; CHECK-NEXT:  callq __tls_get_addr@PLT16; CHECK:       x@DTPOFF17}18 19define ptr @get_y() {20entry:21  ret ptr @y22}23 24define i32 @f(i32 %i) {25entry:26  %cmp = icmp eq i32 %i, 127  br i1 %cmp, label %return, label %if.else28; This bb does not access TLS, so should not call __tls_get_addr.29; CHECK-LABEL:       f:30; CHECK-NOT:   __tls_get_addr31; CHECK:       je32 33 34if.else:35  %0 = load i32, ptr @x, align 436  %cmp1 = icmp eq i32 %i, 237  br i1 %cmp1, label %if.then2, label %return38; Now we call __tls_get_addr.39; CHECK:       # %if.else40; CHECK:       leaq x@TLSLD(%rip), %rdi41; CHECK-NEXT:  callq __tls_get_addr@PLT42; CHECK:       x@DTPOFF43 44 45if.then2:46  %1 = load i32, ptr @y, align 447  %add = add nsw i32 %1, %048  br label %return49; This accesses TLS, but is dominated by the previous block,50; so should not have to call __tls_get_addr again.51; CHECK:       # %if.then252; CHECK-NOT:   __tls_get_addr53; CHECK:       y@DTPOFF54 55 56return:57  %retval.0 = phi i32 [ %add, %if.then2 ], [ 5, %entry ], [ %0, %if.else ]58  ret i32 %retval.059}60