| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=mipsel < %s | FileCheck -check-prefix=CHECK-PIC %s | 
|  | 2 | ; RUN: llc -march=mipsel -relocation-model=static < %s | FileCheck -check-prefix=CHECK-NONPIC %s | 
|  | 3 |  | 
|  | 4 | @external_gd = external thread_local global i32 | 
|  | 5 | @internal_gd = internal thread_local global i32 42 | 
|  | 6 |  | 
|  | 7 | @external_ld = external thread_local(localdynamic) global i32 | 
|  | 8 | @internal_ld = internal thread_local(localdynamic) global i32 42 | 
|  | 9 |  | 
|  | 10 | @external_ie = external thread_local(initialexec) global i32 | 
|  | 11 | @internal_ie = internal thread_local(initialexec) global i32 42 | 
|  | 12 |  | 
|  | 13 | @external_le = external thread_local(localexec) global i32 | 
|  | 14 | @internal_le = internal thread_local(localexec) global i32 42 | 
|  | 15 |  | 
|  | 16 | ; ----- no model specified ----- | 
|  | 17 |  | 
|  | 18 | define i32* @f1() { | 
|  | 19 | entry: | 
|  | 20 | ret i32* @external_gd | 
|  | 21 |  | 
|  | 22 | ; Non-PIC code can use initial-exec, PIC code has to use general dynamic. | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 23 | ; CHECK-NONPIC-LABEL:   f1: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 24 | ; CHECK-NONPIC:   %gottprel | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 25 | ; CHECK-PIC-LABEL:      f1: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 26 | ; CHECK-PIC:      %tlsgd | 
|  | 27 | } | 
|  | 28 |  | 
|  | 29 | define i32* @f2() { | 
|  | 30 | entry: | 
|  | 31 | ret i32* @internal_gd | 
|  | 32 |  | 
|  | 33 | ; Non-PIC code can use local exec, PIC code can use local dynamic. | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 34 | ; CHECK-NONPIC-LABEL:   f2: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 35 | ; CHECK-NONPIC:   %tprel_hi | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 36 | ; CHECK-PIC-LABEL:      f2: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 37 | ; CHECK-PIC:      %tlsldm | 
|  | 38 | } | 
|  | 39 |  | 
|  | 40 |  | 
|  | 41 | ; ----- localdynamic specified ----- | 
|  | 42 |  | 
|  | 43 | define i32* @f3() { | 
|  | 44 | entry: | 
|  | 45 | ret i32* @external_ld | 
|  | 46 |  | 
|  | 47 | ; Non-PIC code can use initial exec, PIC should use local dynamic. | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 48 | ; CHECK-NONPIC-LABEL:   f3: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 49 | ; CHECK-NONPIC:   %gottprel | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 50 | ; CHECK-PIC-LABEL:      f3: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 51 | ; CHECK-PIC:      %tlsldm | 
|  | 52 | } | 
|  | 53 |  | 
|  | 54 | define i32* @f4() { | 
|  | 55 | entry: | 
|  | 56 | ret i32* @internal_ld | 
|  | 57 |  | 
|  | 58 | ; Non-PIC code can use local exec, PIC code can use local dynamic. | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 59 | ; CHECK-NONPIC-LABEL:   f4: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 60 | ; CHECK-NONPIC:   %tprel_hi | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 61 | ; CHECK-PIC-LABEL:      f4: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 62 | ; CHECK-PIC:      %tlsldm | 
|  | 63 | } | 
|  | 64 |  | 
|  | 65 |  | 
|  | 66 | ; ----- initialexec specified ----- | 
|  | 67 |  | 
|  | 68 | define i32* @f5() { | 
|  | 69 | entry: | 
|  | 70 | ret i32* @external_ie | 
|  | 71 |  | 
|  | 72 | ; Non-PIC and PIC code will use initial exec as specified. | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 73 | ; CHECK-NONPIC-LABEL:   f5: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 74 | ; CHECK-NONPIC:   %gottprel | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 75 | ; CHECK-PIC-LABEL:      f5: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 76 | ; CHECK-PIC:      %gottprel | 
|  | 77 | } | 
|  | 78 |  | 
|  | 79 | define i32* @f6() { | 
|  | 80 | entry: | 
|  | 81 | ret i32* @internal_ie | 
|  | 82 |  | 
|  | 83 | ; Non-PIC code can use local exec, PIC code use initial exec as specified. | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 84 | ; CHECK-NONPIC-LABEL:   f6: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 85 | ; CHECK-NONPIC:   %tprel_hi | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 86 | ; CHECK-PIC-LABEL:      f6: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 87 | ; CHECK-PIC:      %gottprel | 
|  | 88 | } | 
|  | 89 |  | 
|  | 90 |  | 
|  | 91 | ; ----- localexec specified ----- | 
|  | 92 |  | 
|  | 93 | define i32* @f7() { | 
|  | 94 | entry: | 
|  | 95 | ret i32* @external_le | 
|  | 96 |  | 
|  | 97 | ; Non-PIC and PIC code will use local exec as specified. | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 98 | ; CHECK-NONPIC-LABEL:   f7: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 99 | ; CHECK-NONPIC:   %tprel_hi | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 100 | ; CHECK-PIC-LABEL:      f7: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 101 | ; CHECK-PIC:      %tprel_hi | 
|  | 102 | } | 
|  | 103 |  | 
|  | 104 | define i32* @f8() { | 
|  | 105 | entry: | 
|  | 106 | ret i32* @internal_le | 
|  | 107 |  | 
|  | 108 | ; Non-PIC and PIC code will use local exec as specified. | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 109 | ; CHECK-NONPIC-LABEL:   f8: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 110 | ; CHECK-NONPIC:   %tprel_hi | 
| Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 111 | ; CHECK-PIC-LABEL:      f8: | 
| Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 112 | ; CHECK-PIC:      %tprel_hi | 
|  | 113 | } |