File: tls-shrink-wrapping.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (56 lines) | stat: -rw-r--r-- 2,175 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
; Testcase generated from the following code:
; extern __thread int i;
; void f();
; int g(void) {
;   if (i) {
;     i = 0;
;     f();
;   }
;   return i;
; }
; We want to make sure that TLS variables are not accessed before
; the stack frame is set up.

; RUN: llc < %s -relocation-model=pic | FileCheck %s

target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-freebsd11.0"

@i = external thread_local global i32, align 4

define i32 @g() #0 {
entry:
  %tmp = load i32, ptr @i, align 4
  %tobool = icmp eq i32 %tmp, 0
  br i1 %tobool, label %if.end, label %if.then

if.then:                                          ; preds = %entry
  store i32 0, ptr @i, align 4
  tail call void (...) @f() #2
  %.pre = load i32, ptr @i, align 4
  br label %if.end

if.end:                                           ; preds = %if.then, %entry
  %tmp1 = phi i32 [ 0, %entry ], [ %.pre, %if.then ]
  ret i32 %tmp1
}

; CHECK: g:                                      # @g
; CHECK-NEXT:         .cfi_startproc
; CHECK-NEXT: # %bb.0:                                 # %entry
; CHECK-NEXT:         pushq   %rbp
; CHECK-NEXT:         .cfi_def_cfa_offset 16
; CHECK-NEXT:         .cfi_offset %rbp, -16
; CHECK-NEXT:         movq    %rsp, %rbp
; CHECK-NEXT:         .cfi_def_cfa_register %rbp
; CHECK-NEXT:         pushq   %rbx
; CHECK-NEXT:         pushq   %rax
; CHECK-NEXT:         .cfi_offset %rbx, -24
; CHECK-NEXT:         data16
; CHECK-NEXT:         leaq    i@TLSGD(%rip), %rdi

declare void @f(...) #1

attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { nounwind }