1 // RUN: %clang++ -std=gnu++11 -O2 -g %s -o %t
2 // RUN: %dexter --fail-lt 1.0 -w \
3 // RUN: --binary %t --debugger 'lldb' -v -- %s
4 // RUN: %clang++ -std=gnu++11 -O0 -g %s -o %t
5 // RUN: %dexter --fail-lt 1.0 -w \
6 // RUN: --binary %t --debugger 'lldb' -- %s
9 // Currently getting intermittent failures on darwin.
10 // UNSUPPORTED: system-windows, system-darwin
12 //// Check that the debugging experience with __attribute__((optnone)) at O2
13 //// matches O0. Test simple template functions performing simple arithmetic
14 //// vector operations and trivial loops.
16 typedef int int4
__attribute__((ext_vector_type(4)));
17 template<typename T
> struct TypeTraits
{};
20 struct TypeTraits
<int4
> {
21 static const unsigned NumElements
= 4;
22 static const unsigned UnusedField
= 0xDEADBEEFU
;
23 static unsigned MysteryNumber
;
25 unsigned TypeTraits
<int4
>::MysteryNumber
= 3U;
28 __attribute__((optnone
))
30 T tmp
= x
+ y
; // DexLabel('break_0')
32 return tmp
; // DexLabel('break_1')
34 // DexLimitSteps('1', '1', from_line=ref('break_0'), to_line=ref('break_1'))
35 //// FIXME: gdb can print this but lldb cannot. Perhaps PR42920?
36 // \DexExpectWatchValue('TypeTraits<int __attribute__((ext_vector_type(4)))>::NumElements', 4, on_line=ref('break_0'))
37 // \DexExpectWatchValue('TypeTraits<int __attribute__((ext_vector_type(4)))>::UnusedField', 0xdeadbeef, on_line=ref('break_0'))
38 // DexExpectWatchValue('x[0]', 1, on_line=ref('break_0'))
39 // DexExpectWatchValue('x[1]', 2, on_line=ref('break_0'))
40 // DexExpectWatchValue('x[2]', 3, on_line=ref('break_0'))
41 // DexExpectWatchValue('x[3]', 4, on_line=ref('break_0'))
42 // DexExpectWatchValue('y[0]', 5, on_line=ref('break_0'))
43 // DexExpectWatchValue('y[1]', 6, on_line=ref('break_0'))
44 // DexExpectWatchValue('y[2]', 7, on_line=ref('break_0'))
45 // DexExpectWatchValue('y[3]', 8, on_line=ref('break_0'))
46 // DexExpectWatchValue('tmp[0]', 6, on_line=ref('break_1'))
47 // DexExpectWatchValue('tmp[1]', 8, on_line=ref('break_1'))
48 // DexExpectWatchValue('tmp[2]', 10, on_line=ref('break_1'))
49 // DexExpectWatchValue('tmp[3]', 12, on_line=ref('break_1'))
50 // DexExpectWatchValue('tmp2[0]', 11, on_line=ref('break_1'))
51 // DexExpectWatchValue('tmp2[1]', 14, on_line=ref('break_1'))
52 // DexExpectWatchValue('tmp2[2]', 17, on_line=ref('break_1'))
53 // DexExpectWatchValue('tmp2[3]', 20, on_line=ref('break_1'))
56 __attribute__((optnone
))
59 int break_2
= 0; // DexLabel('break_2')
60 for (unsigned i
= 0; i
!= TypeTraits
<T
>::NumElements
; ++i
) {
61 tmp
<<= 1; // DexLabel('break_3')
65 tmp
[0] >>= TypeTraits
<T
>::MysteryNumber
;
66 return tmp
; // DexLabel('break_5')
68 // DexLimitSteps('1', '1', on_line=ref('break_2'))
69 // DexExpectWatchValue('x[0]', 6, on_line=ref('break_2'))
70 // DexExpectWatchValue('x[1]', 8, on_line=ref('break_2'))
71 // DexExpectWatchValue('x[2]', 10, on_line=ref('break_2'))
72 // DexExpectWatchValue('x[3]', 12, on_line=ref('break_2'))
73 // DexExpectWatchValue('y[0]', 5, on_line=ref('break_2'))
74 // DexExpectWatchValue('y[1]', 6, on_line=ref('break_2'))
75 // DexExpectWatchValue('y[2]', 7, on_line=ref('break_2'))
76 // DexExpectWatchValue('y[3]', 8, on_line=ref('break_2'))
77 // DexExpectWatchValue('tmp[0]', 6, on_line=ref('break_2'))
78 // DexExpectWatchValue('tmp[1]', 8, on_line=ref('break_2'))
79 // DexExpectWatchValue('tmp[2]', 10, on_line=ref('break_2'))
80 // DexExpectWatchValue('tmp[3]', 12, on_line=ref('break_2'))
81 // DexLimitSteps('i', 3, from_line=ref('break_3'), to_line=ref('break_5'))
82 // DexExpectWatchValue('tmp[0]', 63, on_line=ref('break_3'))
83 // DexExpectWatchValue('tmp[1]', 94, on_line=ref('break_3'))
84 // DexExpectWatchValue('tmp[2]', 95, on_line=ref('break_3'))
85 // DexExpectWatchValue('tmp[3]', 120, on_line=ref('break_3'))
86 // DexExpectWatchValue('tmp[0]', 15, on_line=ref('break_5'))
89 __attribute__((optnone
))
92 for (unsigned i
=0; i
!= TypeTraits
<T
>::NumElements
; ++i
)
93 result
[i
] = InVec
[i
]; // DexLabel('break_6')
94 return result
; // DexLabel('break_7')
96 // DexLimitSteps('i', '3', from_line=ref('break_6'), to_line=ref('break_7'))
97 // DexExpectWatchValue('InVec[0]', 15, from_line=ref('break_6'), to_line=ref('break_7'))
98 // DexExpectWatchValue('InVec[1]', 190, from_line=ref('break_6'), to_line=ref('break_7'))
99 // DexExpectWatchValue('InVec[2]', 191, from_line=ref('break_6'), to_line=ref('break_7'))
100 // DexExpectWatchValue('InVec[3]', 248, from_line=ref('break_6'), to_line=ref('break_7'))
101 // DexExpectWatchValue('result[0]', 15, from_line=ref('break_6'), to_line=ref('break_7'))
102 // DexExpectWatchValue('result[1]', 190, from_line=ref('break_6'), to_line=ref('break_7'))
103 // DexExpectWatchValue('result[2]', 191, from_line=ref('break_6'), to_line=ref('break_7'))
104 // DexExpectWatchValue('result[3]', 248, on_line=ref('break_7'))
107 __attribute__((optnone
))
109 for (unsigned i
=0; i
!= TypeTraits
<T
>::NumElements
; ++i
)
110 x
[i
] = (x
[i
] > y
[i
])? x
[i
] : y
[i
] + TypeTraits
<T
>::MysteryNumber
; // DexLabel('break_11')
111 return x
; // DexLabel('break_12')
113 // DexLimitSteps('1', '1', from_line=ref('break_11'), to_line=ref('break_12'))
114 //// FIXME: lldb won't print this but gdb unexpectedly says it's optimized out, even at O0.
115 // \DexExpectWatchValue('TypeTraits<int __attribute__((ext_vector_type(4)))>::MysteryNumber', 3, on_line=ref('break_11'))
116 // DexExpectWatchValue('i', 0, 1, 2, 3, on_line=ref('break_11'))
117 // DexExpectWatchValue('x[0]', 1, 8, from_line=ref('break_11'), to_line=ref('break_12'))
118 // DexExpectWatchValue('x[1]', 2, 9, from_line=ref('break_11'), to_line=ref('break_12'))
119 // DexExpectWatchValue('x[2]', 3, 10, from_line=ref('break_11'), to_line=ref('break_12'))
120 // DexExpectWatchValue('x[3]', 4, 11, from_line=ref('break_11'), to_line=ref('break_12'))
121 // DexExpectWatchValue('y[0]', 5, from_line=ref('break_11'), to_line=ref('break_12'))
122 // DexExpectWatchValue('y[1]', 6, from_line=ref('break_11'), to_line=ref('break_12'))
123 // DexExpectWatchValue('y[2]', 7, from_line=ref('break_11'), to_line=ref('break_12'))
124 // DexExpectWatchValue('y[3]', 8, from_line=ref('break_11'), to_line=ref('break_12'))
127 int4 a
= (int4
){1,2,3,4};
128 int4 b
= (int4
){5,6,7,8};
130 int4 tmp
= test1(a
,b
);