• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s
2; The instructions addis,addi, bl are used to calculate the address of TLS
3; thread local variables. These TLS access code sequences are generated
4; repeatedly every time the thread local variable is accessed. By communicating
5; to Machine CSE that X2 is guaranteed to have the same value within the same
6; function call (so called Caller Preserved Physical Register), the redudant
7; TLS access code sequences are cleaned up.
8
9%"struct.CC::TT" = type { i64, i32 }
10%class.CC = type { %struct.SS }
11%struct.SS = type { void ()* }
12
13@_ZN2CC2ccE = external thread_local global %"struct.CC::TT", align 8
14
15define noalias i8* @_ZN2CC3funEv(%class.CC* %this) {
16; CHECK-LABEL: _ZN2CC3funEv:
17; CHECK:    mflr 0
18; CHECK-NEXT:    std 0, 16(1)
19; CHECK-NEXT:    stdu 1, -48(1)
20; CHECK-NEXT:    .cfi_def_cfa_offset 48
21; CHECK-NEXT:    .cfi_offset lr, 16
22; CHECK-NEXT:    .cfi_offset r30, -16
23; CHECK-NEXT:    ld 12, 0(3)
24; CHECK-NEXT:    std 30, 32(1)
25; CHECK-NEXT:    mr 30, 3
26; CHECK-NEXT:    std 2, 24(1)
27; CHECK-NEXT:    mtctr 12
28; CHECK-NEXT:    bctrl
29; CHECK-NEXT:    ld 2, 24(1)
30; CHECK-NEXT:    addis 3, 2, _ZN2CC2ccE@got@tlsgd@ha
31; CHECK-NEXT:    addi 3, 3, _ZN2CC2ccE@got@tlsgd@l
32; CHECK-NEXT:    bl __tls_get_addr(_ZN2CC2ccE@tlsgd)
33; CHECK-NEXT:    nop
34; CHECK-NEXT:    ld 4, 0(3)
35; CHECK-NEXT:    cmpldi 4, 0
36; CHECK-NEXT:    beq 0, .LBB0_2
37; CHECK:    addi 4, 3, 8
38; CHECK-NEXT:    mr 3, 30
39; CHECK-NEXT:    bl _ZN2CC3barEPi
40; CHECK-NEXT:    nop
41; CHECK:    ld 30, 32(1)
42; CHECK-NEXT:    li 3, 0
43; CHECK-NEXT:    addi 1, 1, 48
44; CHECK-NEXT:    ld 0, 16(1)
45; CHECK-NEXT:    mtlr 0
46; CHECK-NEXT:    blr
47entry:
48  %foo = getelementptr inbounds %class.CC, %class.CC* %this, i64 0, i32 0, i32 0
49  %0 = load void ()*, void ()** %foo, align 8
50  tail call void %0()
51  %1 = load i64, i64* getelementptr inbounds (%"struct.CC::TT", %"struct.CC::TT"* @_ZN2CC2ccE, i64 0, i32 0)
52  %tobool = icmp eq i64 %1, 0
53  br i1 %tobool, label %if.end, label %if.then
54
55if.then:
56  tail call void @_ZN2CC3barEPi(%class.CC* nonnull %this, i32* getelementptr inbounds (%"struct.CC::TT", %"struct.CC::TT"* @_ZN2CC2ccE, i64 0, i32 1))
57  br label %if.end
58
59if.end:
60  ret i8* null
61}
62
63declare void @_ZN2CC3barEPi(%class.CC*, i32*)
64