1 /* GCC instrumentation plugin for ThreadSanitizer.
2 Copyright (C) 2011-2015 Free Software Foundation, Inc.
3 Contributed by Dmitry Vyukov <dvyukov@google.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
24 #include "coretypes.h"
34 #include "hard-reg-set.h"
37 #include "dominance.h"
39 #include "basic-block.h"
40 #include "tree-ssa-alias.h"
41 #include "internal-fn.h"
42 #include "gimple-expr.h"
46 #include "gimple-iterator.h"
47 #include "gimple-ssa.h"
49 #include "plugin-api.h"
53 #include "stringpool.h"
54 #include "tree-ssanames.h"
55 #include "tree-pass.h"
56 #include "tree-iterator.h"
57 #include "langhooks.h"
61 #include "diagnostic.h"
62 #include "tree-ssa-propagate.h"
67 /* Number of instrumented memory accesses in the current function. */
69 /* Builds the following decl
70 void __tsan_read/writeX (void *addr); */
73 get_memory_access_decl (bool is_write
, unsigned size
)
75 enum built_in_function fcode
;
78 fcode
= is_write
? BUILT_IN_TSAN_WRITE1
79 : BUILT_IN_TSAN_READ1
;
81 fcode
= is_write
? BUILT_IN_TSAN_WRITE2
82 : BUILT_IN_TSAN_READ2
;
84 fcode
= is_write
? BUILT_IN_TSAN_WRITE4
85 : BUILT_IN_TSAN_READ4
;
87 fcode
= is_write
? BUILT_IN_TSAN_WRITE8
88 : BUILT_IN_TSAN_READ8
;
90 fcode
= is_write
? BUILT_IN_TSAN_WRITE16
91 : BUILT_IN_TSAN_READ16
;
93 return builtin_decl_implicit (fcode
);
96 /* Check as to whether EXPR refers to a store to vptr. */
99 is_vptr_store (gimple stmt
, tree expr
, bool is_write
)
102 && gimple_assign_single_p (stmt
)
103 && TREE_CODE (expr
) == COMPONENT_REF
)
105 tree field
= TREE_OPERAND (expr
, 1);
106 if (TREE_CODE (field
) == FIELD_DECL
107 && DECL_VIRTUAL_P (field
))
108 return gimple_assign_rhs1 (stmt
);
113 /* Instruments EXPR if needed. If any instrumentation is inserted,
117 instrument_expr (gimple_stmt_iterator gsi
, tree expr
, bool is_write
)
119 tree base
, rhs
, expr_ptr
, builtin_decl
;
127 size
= int_size_in_bytes (TREE_TYPE (expr
));
131 HOST_WIDE_INT bitsize
, bitpos
;
134 int volatilep
= 0, unsignedp
= 0;
135 base
= get_inner_reference (expr
, &bitsize
, &bitpos
, &offset
,
136 &mode
, &unsignedp
, &volatilep
, false);
138 /* No need to instrument accesses to decls that don't escape,
139 they can't escape to other threads then. */
142 struct pt_solution pt
;
143 memset (&pt
, 0, sizeof (pt
));
145 pt
.ipa_escaped
= flag_ipa_pta
!= 0;
147 if (!pt_solution_includes (&pt
, base
))
149 if (!is_global_var (base
) && !may_be_aliased (base
))
153 if (TREE_READONLY (base
)
154 || (TREE_CODE (base
) == VAR_DECL
155 && DECL_HARD_REGISTER (base
)))
158 stmt
= gsi_stmt (gsi
);
159 loc
= gimple_location (stmt
);
160 rhs
= is_vptr_store (stmt
, expr
, is_write
);
163 if ((TREE_CODE (expr
) == COMPONENT_REF
164 && DECL_BIT_FIELD_TYPE (TREE_OPERAND (expr
, 1)))
165 || TREE_CODE (expr
) == BIT_FIELD_REF
)
167 base
= TREE_OPERAND (expr
, 0);
168 if (TREE_CODE (expr
) == COMPONENT_REF
)
170 expr
= TREE_OPERAND (expr
, 1);
171 if (is_write
&& DECL_BIT_FIELD_REPRESENTATIVE (expr
))
172 expr
= DECL_BIT_FIELD_REPRESENTATIVE (expr
);
173 if (!tree_fits_uhwi_p (DECL_FIELD_OFFSET (expr
))
174 || !tree_fits_uhwi_p (DECL_FIELD_BIT_OFFSET (expr
))
175 || !tree_fits_uhwi_p (DECL_SIZE (expr
)))
177 bitpos
= tree_to_uhwi (DECL_FIELD_OFFSET (expr
)) * BITS_PER_UNIT
178 + tree_to_uhwi (DECL_FIELD_BIT_OFFSET (expr
));
179 bitsize
= tree_to_uhwi (DECL_SIZE (expr
));
183 if (!tree_fits_uhwi_p (TREE_OPERAND (expr
, 2))
184 || !tree_fits_uhwi_p (TREE_OPERAND (expr
, 1)))
186 bitpos
= tree_to_uhwi (TREE_OPERAND (expr
, 2));
187 bitsize
= tree_to_uhwi (TREE_OPERAND (expr
, 1));
189 if (bitpos
< 0 || bitsize
<= 0)
191 size
= (bitpos
% BITS_PER_UNIT
+ bitsize
+ BITS_PER_UNIT
- 1)
193 align
= get_object_alignment (base
);
194 if (align
< BITS_PER_UNIT
)
196 bitpos
= bitpos
& ~(BITS_PER_UNIT
- 1);
197 if ((align
- 1) & bitpos
)
199 align
= (align
- 1) & bitpos
;
200 align
= align
& -align
;
202 gcc_checking_assert (is_gimple_addressable (base
));
203 expr
= build_fold_addr_expr (unshare_expr (base
));
204 if (!is_gimple_mem_ref_addr (expr
))
206 g
= gimple_build_assign (make_ssa_name (TREE_TYPE (expr
)), expr
);
207 expr
= gimple_assign_lhs (g
);
208 gimple_set_location (g
, loc
);
209 gimple_seq_add_stmt_without_update (&seq
, g
);
211 expr
= build2 (MEM_REF
, char_type_node
, expr
,
212 build_int_cst (TREE_TYPE (expr
), bitpos
/ BITS_PER_UNIT
));
213 expr_ptr
= build_fold_addr_expr (expr
);
215 /* We can't call build_fold_addr_expr on a VIEW_CONVERT_EXPR.
216 This can occur in Ada. */
217 else if (TREE_CODE (expr
) == VIEW_CONVERT_EXPR
)
219 align
= get_object_alignment (expr
);
220 if (align
< BITS_PER_UNIT
)
222 expr
= TREE_OPERAND (expr
, 0);
223 gcc_checking_assert (is_gimple_addressable (expr
));
224 expr_ptr
= build_fold_addr_expr (unshare_expr (expr
));
228 align
= get_object_alignment (expr
);
229 if (align
< BITS_PER_UNIT
)
231 gcc_checking_assert (is_gimple_addressable (expr
));
232 expr_ptr
= build_fold_addr_expr (unshare_expr (expr
));
234 if (!is_gimple_val (expr_ptr
))
236 g
= gimple_build_assign (make_ssa_name (TREE_TYPE (expr_ptr
)), expr_ptr
);
237 expr_ptr
= gimple_assign_lhs (g
);
238 gimple_set_location (g
, loc
);
239 gimple_seq_add_stmt_without_update (&seq
, g
);
241 if ((size
& (size
- 1)) != 0 || size
> 16
242 || align
< MIN (size
, 8) * BITS_PER_UNIT
)
244 builtin_decl
= builtin_decl_implicit (is_write
245 ? BUILT_IN_TSAN_WRITE_RANGE
246 : BUILT_IN_TSAN_READ_RANGE
);
247 g
= gimple_build_call (builtin_decl
, 2, expr_ptr
, size_int (size
));
249 else if (rhs
== NULL
)
250 g
= gimple_build_call (get_memory_access_decl (is_write
, size
),
254 builtin_decl
= builtin_decl_implicit (BUILT_IN_TSAN_VPTR_UPDATE
);
255 g
= gimple_build_call (builtin_decl
, 1, expr_ptr
);
257 gimple_set_location (g
, loc
);
258 gimple_seq_add_stmt_without_update (&seq
, g
);
259 /* Instrumentation for assignment of a function result
260 must be inserted after the call. Instrumentation for
261 reads of function arguments must be inserted before the call.
262 That's because the call can contain synchronization. */
263 if (is_gimple_call (stmt
) && is_write
)
265 /* If the call can throw, it must be the last stmt in
266 a basic block, so the instrumented stmts need to be
267 inserted in successor bbs. */
268 if (is_ctrl_altering_stmt (stmt
))
273 e
= find_fallthru_edge (bb
->succs
);
275 gsi_insert_seq_on_edge_immediate (e
, seq
);
278 gsi_insert_seq_after (&gsi
, seq
, GSI_NEW_STMT
);
281 gsi_insert_seq_before (&gsi
, seq
, GSI_SAME_STMT
);
286 /* Actions for sync/atomic builtin transformations. */
287 enum tsan_atomic_action
289 check_last
, add_seq_cst
, add_acquire
, weak_cas
, strong_cas
,
290 bool_cas
, val_cas
, lock_release
, fetch_op
, fetch_op_seq_cst
293 /* Table how to map sync/atomic builtins to their corresponding
295 static const struct tsan_map_atomic
297 enum built_in_function fcode
, tsan_fcode
;
298 enum tsan_atomic_action action
;
300 } tsan_atomic_table
[] =
302 #define TRANSFORM(fcode, tsan_fcode, action, code) \
303 { BUILT_IN_##fcode, BUILT_IN_##tsan_fcode, action, code }
304 #define CHECK_LAST(fcode, tsan_fcode) \
305 TRANSFORM (fcode, tsan_fcode, check_last, ERROR_MARK)
306 #define ADD_SEQ_CST(fcode, tsan_fcode) \
307 TRANSFORM (fcode, tsan_fcode, add_seq_cst, ERROR_MARK)
308 #define ADD_ACQUIRE(fcode, tsan_fcode) \
309 TRANSFORM (fcode, tsan_fcode, add_acquire, ERROR_MARK)
310 #define WEAK_CAS(fcode, tsan_fcode) \
311 TRANSFORM (fcode, tsan_fcode, weak_cas, ERROR_MARK)
312 #define STRONG_CAS(fcode, tsan_fcode) \
313 TRANSFORM (fcode, tsan_fcode, strong_cas, ERROR_MARK)
314 #define BOOL_CAS(fcode, tsan_fcode) \
315 TRANSFORM (fcode, tsan_fcode, bool_cas, ERROR_MARK)
316 #define VAL_CAS(fcode, tsan_fcode) \
317 TRANSFORM (fcode, tsan_fcode, val_cas, ERROR_MARK)
318 #define LOCK_RELEASE(fcode, tsan_fcode) \
319 TRANSFORM (fcode, tsan_fcode, lock_release, ERROR_MARK)
320 #define FETCH_OP(fcode, tsan_fcode, code) \
321 TRANSFORM (fcode, tsan_fcode, fetch_op, code)
322 #define FETCH_OPS(fcode, tsan_fcode, code) \
323 TRANSFORM (fcode, tsan_fcode, fetch_op_seq_cst, code)
325 CHECK_LAST (ATOMIC_LOAD_1
, TSAN_ATOMIC8_LOAD
),
326 CHECK_LAST (ATOMIC_LOAD_2
, TSAN_ATOMIC16_LOAD
),
327 CHECK_LAST (ATOMIC_LOAD_4
, TSAN_ATOMIC32_LOAD
),
328 CHECK_LAST (ATOMIC_LOAD_8
, TSAN_ATOMIC64_LOAD
),
329 CHECK_LAST (ATOMIC_LOAD_16
, TSAN_ATOMIC128_LOAD
),
330 CHECK_LAST (ATOMIC_STORE_1
, TSAN_ATOMIC8_STORE
),
331 CHECK_LAST (ATOMIC_STORE_2
, TSAN_ATOMIC16_STORE
),
332 CHECK_LAST (ATOMIC_STORE_4
, TSAN_ATOMIC32_STORE
),
333 CHECK_LAST (ATOMIC_STORE_8
, TSAN_ATOMIC64_STORE
),
334 CHECK_LAST (ATOMIC_STORE_16
, TSAN_ATOMIC128_STORE
),
335 CHECK_LAST (ATOMIC_EXCHANGE_1
, TSAN_ATOMIC8_EXCHANGE
),
336 CHECK_LAST (ATOMIC_EXCHANGE_2
, TSAN_ATOMIC16_EXCHANGE
),
337 CHECK_LAST (ATOMIC_EXCHANGE_4
, TSAN_ATOMIC32_EXCHANGE
),
338 CHECK_LAST (ATOMIC_EXCHANGE_8
, TSAN_ATOMIC64_EXCHANGE
),
339 CHECK_LAST (ATOMIC_EXCHANGE_16
, TSAN_ATOMIC128_EXCHANGE
),
340 CHECK_LAST (ATOMIC_FETCH_ADD_1
, TSAN_ATOMIC8_FETCH_ADD
),
341 CHECK_LAST (ATOMIC_FETCH_ADD_2
, TSAN_ATOMIC16_FETCH_ADD
),
342 CHECK_LAST (ATOMIC_FETCH_ADD_4
, TSAN_ATOMIC32_FETCH_ADD
),
343 CHECK_LAST (ATOMIC_FETCH_ADD_8
, TSAN_ATOMIC64_FETCH_ADD
),
344 CHECK_LAST (ATOMIC_FETCH_ADD_16
, TSAN_ATOMIC128_FETCH_ADD
),
345 CHECK_LAST (ATOMIC_FETCH_SUB_1
, TSAN_ATOMIC8_FETCH_SUB
),
346 CHECK_LAST (ATOMIC_FETCH_SUB_2
, TSAN_ATOMIC16_FETCH_SUB
),
347 CHECK_LAST (ATOMIC_FETCH_SUB_4
, TSAN_ATOMIC32_FETCH_SUB
),
348 CHECK_LAST (ATOMIC_FETCH_SUB_8
, TSAN_ATOMIC64_FETCH_SUB
),
349 CHECK_LAST (ATOMIC_FETCH_SUB_16
, TSAN_ATOMIC128_FETCH_SUB
),
350 CHECK_LAST (ATOMIC_FETCH_AND_1
, TSAN_ATOMIC8_FETCH_AND
),
351 CHECK_LAST (ATOMIC_FETCH_AND_2
, TSAN_ATOMIC16_FETCH_AND
),
352 CHECK_LAST (ATOMIC_FETCH_AND_4
, TSAN_ATOMIC32_FETCH_AND
),
353 CHECK_LAST (ATOMIC_FETCH_AND_8
, TSAN_ATOMIC64_FETCH_AND
),
354 CHECK_LAST (ATOMIC_FETCH_AND_16
, TSAN_ATOMIC128_FETCH_AND
),
355 CHECK_LAST (ATOMIC_FETCH_OR_1
, TSAN_ATOMIC8_FETCH_OR
),
356 CHECK_LAST (ATOMIC_FETCH_OR_2
, TSAN_ATOMIC16_FETCH_OR
),
357 CHECK_LAST (ATOMIC_FETCH_OR_4
, TSAN_ATOMIC32_FETCH_OR
),
358 CHECK_LAST (ATOMIC_FETCH_OR_8
, TSAN_ATOMIC64_FETCH_OR
),
359 CHECK_LAST (ATOMIC_FETCH_OR_16
, TSAN_ATOMIC128_FETCH_OR
),
360 CHECK_LAST (ATOMIC_FETCH_XOR_1
, TSAN_ATOMIC8_FETCH_XOR
),
361 CHECK_LAST (ATOMIC_FETCH_XOR_2
, TSAN_ATOMIC16_FETCH_XOR
),
362 CHECK_LAST (ATOMIC_FETCH_XOR_4
, TSAN_ATOMIC32_FETCH_XOR
),
363 CHECK_LAST (ATOMIC_FETCH_XOR_8
, TSAN_ATOMIC64_FETCH_XOR
),
364 CHECK_LAST (ATOMIC_FETCH_XOR_16
, TSAN_ATOMIC128_FETCH_XOR
),
365 CHECK_LAST (ATOMIC_FETCH_NAND_1
, TSAN_ATOMIC8_FETCH_NAND
),
366 CHECK_LAST (ATOMIC_FETCH_NAND_2
, TSAN_ATOMIC16_FETCH_NAND
),
367 CHECK_LAST (ATOMIC_FETCH_NAND_4
, TSAN_ATOMIC32_FETCH_NAND
),
368 CHECK_LAST (ATOMIC_FETCH_NAND_8
, TSAN_ATOMIC64_FETCH_NAND
),
369 CHECK_LAST (ATOMIC_FETCH_NAND_16
, TSAN_ATOMIC128_FETCH_NAND
),
371 CHECK_LAST (ATOMIC_THREAD_FENCE
, TSAN_ATOMIC_THREAD_FENCE
),
372 CHECK_LAST (ATOMIC_SIGNAL_FENCE
, TSAN_ATOMIC_SIGNAL_FENCE
),
374 FETCH_OP (ATOMIC_ADD_FETCH_1
, TSAN_ATOMIC8_FETCH_ADD
, PLUS_EXPR
),
375 FETCH_OP (ATOMIC_ADD_FETCH_2
, TSAN_ATOMIC16_FETCH_ADD
, PLUS_EXPR
),
376 FETCH_OP (ATOMIC_ADD_FETCH_4
, TSAN_ATOMIC32_FETCH_ADD
, PLUS_EXPR
),
377 FETCH_OP (ATOMIC_ADD_FETCH_8
, TSAN_ATOMIC64_FETCH_ADD
, PLUS_EXPR
),
378 FETCH_OP (ATOMIC_ADD_FETCH_16
, TSAN_ATOMIC128_FETCH_ADD
, PLUS_EXPR
),
379 FETCH_OP (ATOMIC_SUB_FETCH_1
, TSAN_ATOMIC8_FETCH_SUB
, MINUS_EXPR
),
380 FETCH_OP (ATOMIC_SUB_FETCH_2
, TSAN_ATOMIC16_FETCH_SUB
, MINUS_EXPR
),
381 FETCH_OP (ATOMIC_SUB_FETCH_4
, TSAN_ATOMIC32_FETCH_SUB
, MINUS_EXPR
),
382 FETCH_OP (ATOMIC_SUB_FETCH_8
, TSAN_ATOMIC64_FETCH_SUB
, MINUS_EXPR
),
383 FETCH_OP (ATOMIC_SUB_FETCH_16
, TSAN_ATOMIC128_FETCH_SUB
, MINUS_EXPR
),
384 FETCH_OP (ATOMIC_AND_FETCH_1
, TSAN_ATOMIC8_FETCH_AND
, BIT_AND_EXPR
),
385 FETCH_OP (ATOMIC_AND_FETCH_2
, TSAN_ATOMIC16_FETCH_AND
, BIT_AND_EXPR
),
386 FETCH_OP (ATOMIC_AND_FETCH_4
, TSAN_ATOMIC32_FETCH_AND
, BIT_AND_EXPR
),
387 FETCH_OP (ATOMIC_AND_FETCH_8
, TSAN_ATOMIC64_FETCH_AND
, BIT_AND_EXPR
),
388 FETCH_OP (ATOMIC_AND_FETCH_16
, TSAN_ATOMIC128_FETCH_AND
, BIT_AND_EXPR
),
389 FETCH_OP (ATOMIC_OR_FETCH_1
, TSAN_ATOMIC8_FETCH_OR
, BIT_IOR_EXPR
),
390 FETCH_OP (ATOMIC_OR_FETCH_2
, TSAN_ATOMIC16_FETCH_OR
, BIT_IOR_EXPR
),
391 FETCH_OP (ATOMIC_OR_FETCH_4
, TSAN_ATOMIC32_FETCH_OR
, BIT_IOR_EXPR
),
392 FETCH_OP (ATOMIC_OR_FETCH_8
, TSAN_ATOMIC64_FETCH_OR
, BIT_IOR_EXPR
),
393 FETCH_OP (ATOMIC_OR_FETCH_16
, TSAN_ATOMIC128_FETCH_OR
, BIT_IOR_EXPR
),
394 FETCH_OP (ATOMIC_XOR_FETCH_1
, TSAN_ATOMIC8_FETCH_XOR
, BIT_XOR_EXPR
),
395 FETCH_OP (ATOMIC_XOR_FETCH_2
, TSAN_ATOMIC16_FETCH_XOR
, BIT_XOR_EXPR
),
396 FETCH_OP (ATOMIC_XOR_FETCH_4
, TSAN_ATOMIC32_FETCH_XOR
, BIT_XOR_EXPR
),
397 FETCH_OP (ATOMIC_XOR_FETCH_8
, TSAN_ATOMIC64_FETCH_XOR
, BIT_XOR_EXPR
),
398 FETCH_OP (ATOMIC_XOR_FETCH_16
, TSAN_ATOMIC128_FETCH_XOR
, BIT_XOR_EXPR
),
399 FETCH_OP (ATOMIC_NAND_FETCH_1
, TSAN_ATOMIC8_FETCH_NAND
, BIT_NOT_EXPR
),
400 FETCH_OP (ATOMIC_NAND_FETCH_2
, TSAN_ATOMIC16_FETCH_NAND
, BIT_NOT_EXPR
),
401 FETCH_OP (ATOMIC_NAND_FETCH_4
, TSAN_ATOMIC32_FETCH_NAND
, BIT_NOT_EXPR
),
402 FETCH_OP (ATOMIC_NAND_FETCH_8
, TSAN_ATOMIC64_FETCH_NAND
, BIT_NOT_EXPR
),
403 FETCH_OP (ATOMIC_NAND_FETCH_16
, TSAN_ATOMIC128_FETCH_NAND
, BIT_NOT_EXPR
),
405 ADD_ACQUIRE (SYNC_LOCK_TEST_AND_SET_1
, TSAN_ATOMIC8_EXCHANGE
),
406 ADD_ACQUIRE (SYNC_LOCK_TEST_AND_SET_2
, TSAN_ATOMIC16_EXCHANGE
),
407 ADD_ACQUIRE (SYNC_LOCK_TEST_AND_SET_4
, TSAN_ATOMIC32_EXCHANGE
),
408 ADD_ACQUIRE (SYNC_LOCK_TEST_AND_SET_8
, TSAN_ATOMIC64_EXCHANGE
),
409 ADD_ACQUIRE (SYNC_LOCK_TEST_AND_SET_16
, TSAN_ATOMIC128_EXCHANGE
),
411 ADD_SEQ_CST (SYNC_FETCH_AND_ADD_1
, TSAN_ATOMIC8_FETCH_ADD
),
412 ADD_SEQ_CST (SYNC_FETCH_AND_ADD_2
, TSAN_ATOMIC16_FETCH_ADD
),
413 ADD_SEQ_CST (SYNC_FETCH_AND_ADD_4
, TSAN_ATOMIC32_FETCH_ADD
),
414 ADD_SEQ_CST (SYNC_FETCH_AND_ADD_8
, TSAN_ATOMIC64_FETCH_ADD
),
415 ADD_SEQ_CST (SYNC_FETCH_AND_ADD_16
, TSAN_ATOMIC128_FETCH_ADD
),
416 ADD_SEQ_CST (SYNC_FETCH_AND_SUB_1
, TSAN_ATOMIC8_FETCH_SUB
),
417 ADD_SEQ_CST (SYNC_FETCH_AND_SUB_2
, TSAN_ATOMIC16_FETCH_SUB
),
418 ADD_SEQ_CST (SYNC_FETCH_AND_SUB_4
, TSAN_ATOMIC32_FETCH_SUB
),
419 ADD_SEQ_CST (SYNC_FETCH_AND_SUB_8
, TSAN_ATOMIC64_FETCH_SUB
),
420 ADD_SEQ_CST (SYNC_FETCH_AND_SUB_16
, TSAN_ATOMIC128_FETCH_SUB
),
421 ADD_SEQ_CST (SYNC_FETCH_AND_AND_1
, TSAN_ATOMIC8_FETCH_AND
),
422 ADD_SEQ_CST (SYNC_FETCH_AND_AND_2
, TSAN_ATOMIC16_FETCH_AND
),
423 ADD_SEQ_CST (SYNC_FETCH_AND_AND_4
, TSAN_ATOMIC32_FETCH_AND
),
424 ADD_SEQ_CST (SYNC_FETCH_AND_AND_8
, TSAN_ATOMIC64_FETCH_AND
),
425 ADD_SEQ_CST (SYNC_FETCH_AND_AND_16
, TSAN_ATOMIC128_FETCH_AND
),
426 ADD_SEQ_CST (SYNC_FETCH_AND_OR_1
, TSAN_ATOMIC8_FETCH_OR
),
427 ADD_SEQ_CST (SYNC_FETCH_AND_OR_2
, TSAN_ATOMIC16_FETCH_OR
),
428 ADD_SEQ_CST (SYNC_FETCH_AND_OR_4
, TSAN_ATOMIC32_FETCH_OR
),
429 ADD_SEQ_CST (SYNC_FETCH_AND_OR_8
, TSAN_ATOMIC64_FETCH_OR
),
430 ADD_SEQ_CST (SYNC_FETCH_AND_OR_16
, TSAN_ATOMIC128_FETCH_OR
),
431 ADD_SEQ_CST (SYNC_FETCH_AND_XOR_1
, TSAN_ATOMIC8_FETCH_XOR
),
432 ADD_SEQ_CST (SYNC_FETCH_AND_XOR_2
, TSAN_ATOMIC16_FETCH_XOR
),
433 ADD_SEQ_CST (SYNC_FETCH_AND_XOR_4
, TSAN_ATOMIC32_FETCH_XOR
),
434 ADD_SEQ_CST (SYNC_FETCH_AND_XOR_8
, TSAN_ATOMIC64_FETCH_XOR
),
435 ADD_SEQ_CST (SYNC_FETCH_AND_XOR_16
, TSAN_ATOMIC128_FETCH_XOR
),
436 ADD_SEQ_CST (SYNC_FETCH_AND_NAND_1
, TSAN_ATOMIC8_FETCH_NAND
),
437 ADD_SEQ_CST (SYNC_FETCH_AND_NAND_2
, TSAN_ATOMIC16_FETCH_NAND
),
438 ADD_SEQ_CST (SYNC_FETCH_AND_NAND_4
, TSAN_ATOMIC32_FETCH_NAND
),
439 ADD_SEQ_CST (SYNC_FETCH_AND_NAND_8
, TSAN_ATOMIC64_FETCH_NAND
),
440 ADD_SEQ_CST (SYNC_FETCH_AND_NAND_16
, TSAN_ATOMIC128_FETCH_NAND
),
442 ADD_SEQ_CST (SYNC_SYNCHRONIZE
, TSAN_ATOMIC_THREAD_FENCE
),
444 FETCH_OPS (SYNC_ADD_AND_FETCH_1
, TSAN_ATOMIC8_FETCH_ADD
, PLUS_EXPR
),
445 FETCH_OPS (SYNC_ADD_AND_FETCH_2
, TSAN_ATOMIC16_FETCH_ADD
, PLUS_EXPR
),
446 FETCH_OPS (SYNC_ADD_AND_FETCH_4
, TSAN_ATOMIC32_FETCH_ADD
, PLUS_EXPR
),
447 FETCH_OPS (SYNC_ADD_AND_FETCH_8
, TSAN_ATOMIC64_FETCH_ADD
, PLUS_EXPR
),
448 FETCH_OPS (SYNC_ADD_AND_FETCH_16
, TSAN_ATOMIC128_FETCH_ADD
, PLUS_EXPR
),
449 FETCH_OPS (SYNC_SUB_AND_FETCH_1
, TSAN_ATOMIC8_FETCH_SUB
, MINUS_EXPR
),
450 FETCH_OPS (SYNC_SUB_AND_FETCH_2
, TSAN_ATOMIC16_FETCH_SUB
, MINUS_EXPR
),
451 FETCH_OPS (SYNC_SUB_AND_FETCH_4
, TSAN_ATOMIC32_FETCH_SUB
, MINUS_EXPR
),
452 FETCH_OPS (SYNC_SUB_AND_FETCH_8
, TSAN_ATOMIC64_FETCH_SUB
, MINUS_EXPR
),
453 FETCH_OPS (SYNC_SUB_AND_FETCH_16
, TSAN_ATOMIC128_FETCH_SUB
, MINUS_EXPR
),
454 FETCH_OPS (SYNC_AND_AND_FETCH_1
, TSAN_ATOMIC8_FETCH_AND
, BIT_AND_EXPR
),
455 FETCH_OPS (SYNC_AND_AND_FETCH_2
, TSAN_ATOMIC16_FETCH_AND
, BIT_AND_EXPR
),
456 FETCH_OPS (SYNC_AND_AND_FETCH_4
, TSAN_ATOMIC32_FETCH_AND
, BIT_AND_EXPR
),
457 FETCH_OPS (SYNC_AND_AND_FETCH_8
, TSAN_ATOMIC64_FETCH_AND
, BIT_AND_EXPR
),
458 FETCH_OPS (SYNC_AND_AND_FETCH_16
, TSAN_ATOMIC128_FETCH_AND
, BIT_AND_EXPR
),
459 FETCH_OPS (SYNC_OR_AND_FETCH_1
, TSAN_ATOMIC8_FETCH_OR
, BIT_IOR_EXPR
),
460 FETCH_OPS (SYNC_OR_AND_FETCH_2
, TSAN_ATOMIC16_FETCH_OR
, BIT_IOR_EXPR
),
461 FETCH_OPS (SYNC_OR_AND_FETCH_4
, TSAN_ATOMIC32_FETCH_OR
, BIT_IOR_EXPR
),
462 FETCH_OPS (SYNC_OR_AND_FETCH_8
, TSAN_ATOMIC64_FETCH_OR
, BIT_IOR_EXPR
),
463 FETCH_OPS (SYNC_OR_AND_FETCH_16
, TSAN_ATOMIC128_FETCH_OR
, BIT_IOR_EXPR
),
464 FETCH_OPS (SYNC_XOR_AND_FETCH_1
, TSAN_ATOMIC8_FETCH_XOR
, BIT_XOR_EXPR
),
465 FETCH_OPS (SYNC_XOR_AND_FETCH_2
, TSAN_ATOMIC16_FETCH_XOR
, BIT_XOR_EXPR
),
466 FETCH_OPS (SYNC_XOR_AND_FETCH_4
, TSAN_ATOMIC32_FETCH_XOR
, BIT_XOR_EXPR
),
467 FETCH_OPS (SYNC_XOR_AND_FETCH_8
, TSAN_ATOMIC64_FETCH_XOR
, BIT_XOR_EXPR
),
468 FETCH_OPS (SYNC_XOR_AND_FETCH_16
, TSAN_ATOMIC128_FETCH_XOR
, BIT_XOR_EXPR
),
469 FETCH_OPS (SYNC_NAND_AND_FETCH_1
, TSAN_ATOMIC8_FETCH_NAND
, BIT_NOT_EXPR
),
470 FETCH_OPS (SYNC_NAND_AND_FETCH_2
, TSAN_ATOMIC16_FETCH_NAND
, BIT_NOT_EXPR
),
471 FETCH_OPS (SYNC_NAND_AND_FETCH_4
, TSAN_ATOMIC32_FETCH_NAND
, BIT_NOT_EXPR
),
472 FETCH_OPS (SYNC_NAND_AND_FETCH_8
, TSAN_ATOMIC64_FETCH_NAND
, BIT_NOT_EXPR
),
473 FETCH_OPS (SYNC_NAND_AND_FETCH_16
, TSAN_ATOMIC128_FETCH_NAND
, BIT_NOT_EXPR
),
475 WEAK_CAS (ATOMIC_COMPARE_EXCHANGE_1
, TSAN_ATOMIC8_COMPARE_EXCHANGE_WEAK
),
476 WEAK_CAS (ATOMIC_COMPARE_EXCHANGE_2
, TSAN_ATOMIC16_COMPARE_EXCHANGE_WEAK
),
477 WEAK_CAS (ATOMIC_COMPARE_EXCHANGE_4
, TSAN_ATOMIC32_COMPARE_EXCHANGE_WEAK
),
478 WEAK_CAS (ATOMIC_COMPARE_EXCHANGE_8
, TSAN_ATOMIC64_COMPARE_EXCHANGE_WEAK
),
479 WEAK_CAS (ATOMIC_COMPARE_EXCHANGE_16
, TSAN_ATOMIC128_COMPARE_EXCHANGE_WEAK
),
481 STRONG_CAS (ATOMIC_COMPARE_EXCHANGE_1
, TSAN_ATOMIC8_COMPARE_EXCHANGE_STRONG
),
482 STRONG_CAS (ATOMIC_COMPARE_EXCHANGE_2
,
483 TSAN_ATOMIC16_COMPARE_EXCHANGE_STRONG
),
484 STRONG_CAS (ATOMIC_COMPARE_EXCHANGE_4
,
485 TSAN_ATOMIC32_COMPARE_EXCHANGE_STRONG
),
486 STRONG_CAS (ATOMIC_COMPARE_EXCHANGE_8
,
487 TSAN_ATOMIC64_COMPARE_EXCHANGE_STRONG
),
488 STRONG_CAS (ATOMIC_COMPARE_EXCHANGE_16
,
489 TSAN_ATOMIC128_COMPARE_EXCHANGE_STRONG
),
491 BOOL_CAS (SYNC_BOOL_COMPARE_AND_SWAP_1
,
492 TSAN_ATOMIC8_COMPARE_EXCHANGE_STRONG
),
493 BOOL_CAS (SYNC_BOOL_COMPARE_AND_SWAP_2
,
494 TSAN_ATOMIC16_COMPARE_EXCHANGE_STRONG
),
495 BOOL_CAS (SYNC_BOOL_COMPARE_AND_SWAP_4
,
496 TSAN_ATOMIC32_COMPARE_EXCHANGE_STRONG
),
497 BOOL_CAS (SYNC_BOOL_COMPARE_AND_SWAP_8
,
498 TSAN_ATOMIC64_COMPARE_EXCHANGE_STRONG
),
499 BOOL_CAS (SYNC_BOOL_COMPARE_AND_SWAP_16
,
500 TSAN_ATOMIC128_COMPARE_EXCHANGE_STRONG
),
502 VAL_CAS (SYNC_VAL_COMPARE_AND_SWAP_1
, TSAN_ATOMIC8_COMPARE_EXCHANGE_STRONG
),
503 VAL_CAS (SYNC_VAL_COMPARE_AND_SWAP_2
, TSAN_ATOMIC16_COMPARE_EXCHANGE_STRONG
),
504 VAL_CAS (SYNC_VAL_COMPARE_AND_SWAP_4
, TSAN_ATOMIC32_COMPARE_EXCHANGE_STRONG
),
505 VAL_CAS (SYNC_VAL_COMPARE_AND_SWAP_8
, TSAN_ATOMIC64_COMPARE_EXCHANGE_STRONG
),
506 VAL_CAS (SYNC_VAL_COMPARE_AND_SWAP_16
,
507 TSAN_ATOMIC128_COMPARE_EXCHANGE_STRONG
),
509 LOCK_RELEASE (SYNC_LOCK_RELEASE_1
, TSAN_ATOMIC8_STORE
),
510 LOCK_RELEASE (SYNC_LOCK_RELEASE_2
, TSAN_ATOMIC16_STORE
),
511 LOCK_RELEASE (SYNC_LOCK_RELEASE_4
, TSAN_ATOMIC32_STORE
),
512 LOCK_RELEASE (SYNC_LOCK_RELEASE_8
, TSAN_ATOMIC64_STORE
),
513 LOCK_RELEASE (SYNC_LOCK_RELEASE_16
, TSAN_ATOMIC128_STORE
)
516 /* Instrument an atomic builtin. */
519 instrument_builtin_call (gimple_stmt_iterator
*gsi
)
521 gimple stmt
= gsi_stmt (*gsi
), g
;
522 tree callee
= gimple_call_fndecl (stmt
), last_arg
, args
[6], t
, lhs
;
523 enum built_in_function fcode
= DECL_FUNCTION_CODE (callee
);
524 unsigned int i
, num
= gimple_call_num_args (stmt
), j
;
525 for (j
= 0; j
< 6 && j
< num
; j
++)
526 args
[j
] = gimple_call_arg (stmt
, j
);
527 for (i
= 0; i
< ARRAY_SIZE (tsan_atomic_table
); i
++)
528 if (fcode
!= tsan_atomic_table
[i
].fcode
)
532 tree decl
= builtin_decl_implicit (tsan_atomic_table
[i
].tsan_fcode
);
533 if (decl
== NULL_TREE
)
535 switch (tsan_atomic_table
[i
].action
)
539 last_arg
= gimple_call_arg (stmt
, num
- 1);
540 if (!tree_fits_uhwi_p (last_arg
)
541 || tree_to_uhwi (last_arg
) > MEMMODEL_SEQ_CST
)
543 gimple_call_set_fndecl (stmt
, decl
);
545 if (tsan_atomic_table
[i
].action
== fetch_op
)
547 args
[1] = gimple_call_arg (stmt
, 1);
553 case fetch_op_seq_cst
:
554 gcc_assert (num
<= 2);
555 for (j
= 0; j
< num
; j
++)
556 args
[j
] = gimple_call_arg (stmt
, j
);
559 args
[num
] = build_int_cst (NULL_TREE
,
560 tsan_atomic_table
[i
].action
564 update_gimple_call (gsi
, decl
, num
+ 1, args
[0], args
[1], args
[2]);
565 stmt
= gsi_stmt (*gsi
);
566 if (tsan_atomic_table
[i
].action
== fetch_op_seq_cst
)
569 lhs
= gimple_call_lhs (stmt
);
570 if (lhs
== NULL_TREE
)
572 if (!useless_type_conversion_p (TREE_TYPE (lhs
),
573 TREE_TYPE (args
[1])))
575 tree var
= make_ssa_name (TREE_TYPE (lhs
));
576 g
= gimple_build_assign (var
, NOP_EXPR
, args
[1]);
577 gsi_insert_after (gsi
, g
, GSI_NEW_STMT
);
580 gimple_call_set_lhs (stmt
, make_ssa_name (TREE_TYPE (lhs
)));
581 /* BIT_NOT_EXPR stands for NAND. */
582 if (tsan_atomic_table
[i
].code
== BIT_NOT_EXPR
)
584 tree var
= make_ssa_name (TREE_TYPE (lhs
));
585 g
= gimple_build_assign (var
, BIT_AND_EXPR
,
586 gimple_call_lhs (stmt
), args
[1]);
587 gsi_insert_after (gsi
, g
, GSI_NEW_STMT
);
588 g
= gimple_build_assign (lhs
, BIT_NOT_EXPR
, var
);
591 g
= gimple_build_assign (lhs
, tsan_atomic_table
[i
].code
,
592 gimple_call_lhs (stmt
), args
[1]);
594 gsi_insert_after (gsi
, g
, GSI_NEW_STMT
);
598 if (!integer_nonzerop (gimple_call_arg (stmt
, 3)))
602 gcc_assert (num
== 6);
603 for (j
= 0; j
< 6; j
++)
604 args
[j
] = gimple_call_arg (stmt
, j
);
605 if (!tree_fits_uhwi_p (args
[4])
606 || tree_to_uhwi (args
[4]) > MEMMODEL_SEQ_CST
)
608 if (!tree_fits_uhwi_p (args
[5])
609 || tree_to_uhwi (args
[5]) > MEMMODEL_SEQ_CST
)
611 update_gimple_call (gsi
, decl
, 5, args
[0], args
[1], args
[2],
616 gcc_assert (num
== 3);
617 for (j
= 0; j
< 3; j
++)
618 args
[j
] = gimple_call_arg (stmt
, j
);
619 t
= TYPE_ARG_TYPES (TREE_TYPE (decl
));
620 t
= TREE_VALUE (TREE_CHAIN (TREE_CHAIN (t
)));
621 t
= create_tmp_var (t
);
622 mark_addressable (t
);
623 if (!useless_type_conversion_p (TREE_TYPE (t
),
624 TREE_TYPE (args
[1])))
626 g
= gimple_build_assign (make_ssa_name (TREE_TYPE (t
)),
628 gsi_insert_before (gsi
, g
, GSI_SAME_STMT
);
629 args
[1] = gimple_assign_lhs (g
);
631 g
= gimple_build_assign (t
, args
[1]);
632 gsi_insert_before (gsi
, g
, GSI_SAME_STMT
);
633 lhs
= gimple_call_lhs (stmt
);
634 update_gimple_call (gsi
, decl
, 5, args
[0],
635 build_fold_addr_expr (t
), args
[2],
636 build_int_cst (NULL_TREE
,
638 build_int_cst (NULL_TREE
,
640 if (tsan_atomic_table
[i
].action
== val_cas
&& lhs
)
643 stmt
= gsi_stmt (*gsi
);
644 g
= gimple_build_assign (make_ssa_name (TREE_TYPE (t
)), t
);
645 gsi_insert_after (gsi
, g
, GSI_NEW_STMT
);
646 t
= make_ssa_name (TREE_TYPE (TREE_TYPE (decl
)), stmt
);
647 cond
= build2 (NE_EXPR
, boolean_type_node
, t
,
648 build_int_cst (TREE_TYPE (t
), 0));
649 g
= gimple_build_assign (lhs
, COND_EXPR
, cond
, args
[1],
650 gimple_assign_lhs (g
));
651 gimple_call_set_lhs (stmt
, t
);
653 gsi_insert_after (gsi
, g
, GSI_NEW_STMT
);
657 gcc_assert (num
== 1);
658 t
= TYPE_ARG_TYPES (TREE_TYPE (decl
));
659 t
= TREE_VALUE (TREE_CHAIN (t
));
660 update_gimple_call (gsi
, decl
, 3, gimple_call_arg (stmt
, 0),
661 build_int_cst (t
, 0),
662 build_int_cst (NULL_TREE
,
671 /* Instruments the gimple pointed to by GSI. Return
672 true if func entry/exit should be instrumented. */
675 instrument_gimple (gimple_stmt_iterator
*gsi
)
679 bool instrumented
= false;
681 stmt
= gsi_stmt (*gsi
);
682 if (is_gimple_call (stmt
)
683 && (gimple_call_fndecl (stmt
)
684 != builtin_decl_implicit (BUILT_IN_TSAN_INIT
)))
686 if (gimple_call_builtin_p (stmt
, BUILT_IN_NORMAL
))
687 instrument_builtin_call (gsi
);
690 else if (is_gimple_assign (stmt
)
691 && !gimple_clobber_p (stmt
))
693 if (gimple_store_p (stmt
))
695 lhs
= gimple_assign_lhs (stmt
);
696 instrumented
= instrument_expr (*gsi
, lhs
, true);
698 if (gimple_assign_load_p (stmt
))
700 rhs
= gimple_assign_rhs1 (stmt
);
701 instrumented
= instrument_expr (*gsi
, rhs
, false);
707 /* Replace TSAN_FUNC_EXIT internal call with function exit tsan builtin. */
710 replace_func_exit (gimple stmt
)
712 tree builtin_decl
= builtin_decl_implicit (BUILT_IN_TSAN_FUNC_EXIT
);
713 gimple g
= gimple_build_call (builtin_decl
, 0);
714 gimple_set_location (g
, cfun
->function_end_locus
);
715 gimple_stmt_iterator gsi
= gsi_for_stmt (stmt
);
716 gsi_replace (&gsi
, g
, true);
719 /* Instrument function exit. Used when TSAN_FUNC_EXIT does not exist. */
722 instrument_func_exit (void)
726 gimple_stmt_iterator gsi
;
732 /* Find all function exits. */
733 exit_bb
= EXIT_BLOCK_PTR_FOR_FN (cfun
);
734 FOR_EACH_EDGE (e
, ei
, exit_bb
->preds
)
736 gsi
= gsi_last_bb (e
->src
);
737 stmt
= gsi_stmt (gsi
);
738 gcc_assert (gimple_code (stmt
) == GIMPLE_RETURN
739 || gimple_call_builtin_p (stmt
, BUILT_IN_RETURN
));
740 loc
= gimple_location (stmt
);
741 builtin_decl
= builtin_decl_implicit (BUILT_IN_TSAN_FUNC_EXIT
);
742 g
= gimple_build_call (builtin_decl
, 0);
743 gimple_set_location (g
, loc
);
744 gsi_insert_before (&gsi
, g
, GSI_SAME_STMT
);
748 /* Instruments all interesting memory accesses in the current function.
749 Return true if func entry/exit should be instrumented. */
752 instrument_memory_accesses (void)
755 gimple_stmt_iterator gsi
;
756 bool fentry_exit_instrument
= false;
757 bool func_exit_seen
= false;
758 auto_vec
<gimple
> tsan_func_exits
;
760 FOR_EACH_BB_FN (bb
, cfun
)
761 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
763 gimple stmt
= gsi_stmt (gsi
);
764 if (is_gimple_call (stmt
)
765 && gimple_call_internal_p (stmt
)
766 && gimple_call_internal_fn (stmt
) == IFN_TSAN_FUNC_EXIT
)
768 if (fentry_exit_instrument
)
769 replace_func_exit (stmt
);
771 tsan_func_exits
.safe_push (stmt
);
772 func_exit_seen
= true;
775 fentry_exit_instrument
|= instrument_gimple (&gsi
);
779 FOR_EACH_VEC_ELT (tsan_func_exits
, i
, stmt
)
780 if (fentry_exit_instrument
)
781 replace_func_exit (stmt
);
784 gsi
= gsi_for_stmt (stmt
);
785 gsi_remove (&gsi
, true);
787 if (fentry_exit_instrument
&& !func_exit_seen
)
788 instrument_func_exit ();
789 return fentry_exit_instrument
;
792 /* Instruments function entry. */
795 instrument_func_entry (void)
797 tree ret_addr
, builtin_decl
;
799 gimple_seq seq
= NULL
;
801 builtin_decl
= builtin_decl_implicit (BUILT_IN_RETURN_ADDRESS
);
802 g
= gimple_build_call (builtin_decl
, 1, integer_zero_node
);
803 ret_addr
= make_ssa_name (ptr_type_node
);
804 gimple_call_set_lhs (g
, ret_addr
);
805 gimple_set_location (g
, cfun
->function_start_locus
);
806 gimple_seq_add_stmt_without_update (&seq
, g
);
808 builtin_decl
= builtin_decl_implicit (BUILT_IN_TSAN_FUNC_ENTRY
);
809 g
= gimple_build_call (builtin_decl
, 1, ret_addr
);
810 gimple_set_location (g
, cfun
->function_start_locus
);
811 gimple_seq_add_stmt_without_update (&seq
, g
);
813 edge e
= single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun
));
814 gsi_insert_seq_on_edge_immediate (e
, seq
);
817 /* ThreadSanitizer instrumentation pass. */
822 initialize_sanitizer_builtins ();
823 if (instrument_memory_accesses ())
824 instrument_func_entry ();
828 /* Inserts __tsan_init () into the list of CTORs. */
831 tsan_finish_file (void)
833 tree ctor_statements
= NULL_TREE
;
835 initialize_sanitizer_builtins ();
836 tree init_decl
= builtin_decl_implicit (BUILT_IN_TSAN_INIT
);
837 append_to_statement_list (build_call_expr (init_decl
, 0),
839 cgraph_build_static_cdtor ('I', ctor_statements
,
840 MAX_RESERVED_INIT_PRIORITY
- 1);
843 /* The pass descriptor. */
847 const pass_data pass_data_tsan
=
849 GIMPLE_PASS
, /* type */
851 OPTGROUP_NONE
, /* optinfo_flags */
853 ( PROP_ssa
| PROP_cfg
), /* properties_required */
854 0, /* properties_provided */
855 0, /* properties_destroyed */
856 0, /* todo_flags_start */
857 TODO_update_ssa
, /* todo_flags_finish */
860 class pass_tsan
: public gimple_opt_pass
863 pass_tsan (gcc::context
*ctxt
)
864 : gimple_opt_pass (pass_data_tsan
, ctxt
)
867 /* opt_pass methods: */
868 opt_pass
* clone () { return new pass_tsan (m_ctxt
); }
869 virtual bool gate (function
*)
871 return (flag_sanitize
& SANITIZE_THREAD
) != 0;
874 virtual unsigned int execute (function
*) { return tsan_pass (); }
876 }; // class pass_tsan
881 make_pass_tsan (gcc::context
*ctxt
)
883 return new pass_tsan (ctxt
);
888 const pass_data pass_data_tsan_O0
=
890 GIMPLE_PASS
, /* type */
892 OPTGROUP_NONE
, /* optinfo_flags */
894 ( PROP_ssa
| PROP_cfg
), /* properties_required */
895 0, /* properties_provided */
896 0, /* properties_destroyed */
897 0, /* todo_flags_start */
898 TODO_update_ssa
, /* todo_flags_finish */
901 class pass_tsan_O0
: public gimple_opt_pass
904 pass_tsan_O0 (gcc::context
*ctxt
)
905 : gimple_opt_pass (pass_data_tsan_O0
, ctxt
)
908 /* opt_pass methods: */
909 virtual bool gate (function
*)
911 return (flag_sanitize
& SANITIZE_THREAD
) != 0 && !optimize
;
914 virtual unsigned int execute (function
*) { return tsan_pass (); }
916 }; // class pass_tsan_O0
921 make_pass_tsan_O0 (gcc::context
*ctxt
)
923 return new pass_tsan_O0 (ctxt
);