2013-02-14 Richard Biener <rguenther@suse.de>
PR lto/50494
* varasm.c (output_constant_def_1): Get the decl representing
the constant as argument.
(output_constant_def): Wrap output_constant_def_1.
(make_decl_rtl): Use output_constant_def_1 with the decl
representing the constant.
(build_constant_desc): Optionally re-use a decl already
representing the constant.
(tree_output_constant_def): Adjust.
From-SVN: r196050
* g++.dg/asan/dejagnu-gtest.h: Add multiple inclusion guards.
* asan_globals_test-wrapper.cc: New file.
* g++.dg/asan/asan_test.C: Use asan_globals_test-wrapper.cc
instead of asan_globals_test.cc as dg-additional-sources.
Include asan_mem_test.cc, asan_str_test.cc and asan_oob_test.cc.
* g++.dg/asan/asan_test_utils.h: Synced from upstream. Include
"sanitizer_test_utils.h" instead of
"sanitizer_common/tests/sanitizer_test_utils.h".
* g++.dg/asan/asan_str_test.cc: New file, synced from upstream.
* g++.dg/asan/asan_mem_test.cc: New file, synced from upstream.
* g++.dg/asan/asan_oob_test.cc: New file, synced from upstream.
* g++.dg/asan/asan_globals_test.cc: Synced from upstream.
* g++.dg/asan/asan_test.cc: Synced from upstream.
* g++.dg/asan/sanitizer_test_utils.h: New file, synced from upstream.
From-SVN: r196045
It appeared that in my previous patch, a stupid thinko can lead to a
crash when instrumenting some builtin functionsK. Fixed thus.
Bootstrapped and tested against trunk on x86_64-unknown-linux-gnu.
gcc/
* asan.c (instrument_builtin_call): Really put the length of the
second source argument into src1_len.
gcc/testsuite/
* c-c++-common/asan/memcmp-2.c: New test.
From-SVN: r196044
2013-02-13 Marc Glisse <marc.glisse@inria.fr>
PR libstdc++/56111
* include/std/complex (complex): Undefine.
* include/c_compatibility/complex.h (complex): Only undefine if
<complex> has been included.
* testsuite/26_numerics/complex/56111.cc: New testcase.
From-SVN: r196034
2013-02-13 François Dumont <fdumont@gcc.gnu.org>
* include/bits/hashtable_policy.h (_Hash_code_base): Restore
default constructor protected.
* include/bits/hashtable.h: static assert that _Hash_code_base has
a default constructor available through inheritance.
From-SVN: r196030
* asan.c (create_cond_insert_point): Add create_then_fallthru_edge
argument. If it is false, don't create edge from then_bb to
fallthru_bb.
(insert_if_then_before_iter): Pass true to it.
(build_check_stmt): Pass false to it.
(transform_statements): Flush hash table only on extended basic
block boundaries, rather than at the beginning of every bb.
Don't flush hash table on nonfreeing_call_p calls.
* tree-flow.h (nonfreeing_call_p): New prototype.
* tree-ssa-phiopt.c (nonfreeing_call_p): No longer static.
From-SVN: r196029
Make sure mv12-aux.C has same directives as mv12.C. mv12-aux.C should not
compile for non-x86 targets.
2013-02-13 Sriraman Tallam <tmsriram@google.com>
* g++.dg/ext/mv12-aux.C: Add directives to match mv12.C.
From-SVN: r196026
PR c++/56302
* semantics.c (finish_asm_stmt): If input constraints allow
neither register nor memory, try maybe_constant_value to get
a constant if possible.
* g++.dg/torture/pr56302.C: New test.
* g++.dg/cpp0x/constexpr-56302.C: New test.
* c-c++-common/pr56302.c: New test.
From-SVN: r196018
* config/i386/i386.c (ix86_asan_shadow_offset): Revert last change.
* asan/asan_mapping.h (SHADOW_OFFSET): Set to (1ULL << 44) on x86-64.
From-SVN: r196017
2013-02-13 Richard Biener <rguenther@suse.de>
* loop-init.c (loop_optimizer_init): Clear loop state when
re-initializing preserved loops.
* loop-unswitch.c (unswitch_single_loop): Return whether
we unswitched the loop. Do not verify loop state here.
(unswitch_loops): When we unswitched a loop discover new
loops.
From-SVN: r196010
Like what Address Sanitizer does in LLVM, this patch avoids instrumented
duplicated memory accesses in the same basic blocks.
The approach taken is very conservative, to keep the pass simple, for
a start.
A memory access is considered to be a pair made of an expression tree
representing the beginning of the memory region that is accessed and
a the size of the access, in byte. For now that size is either 1, 2,
4, 8 or 16 bytes.
The patch builds a hash table of the memory accesses that have been
instrumented in the current basic block. Then it walks the gimple
statements of the current basic block. For each statement, it tests
if the memory regions it references have already been instrumented.
If not, the statement is instrumented and each memory references that
are actually instrumented are added to the hash table. When a memory
region is accessed (usually through builtin functions like memset),
then what gets added to the hash table is actually two memory
accesses: one for the beginning of the region, and the other for the
its end.
When the patch crosses a function call that is not a built-in function
that we ought to instrument, the hash table is cleared, because that
function call can possibly e.g free some memory that was instrumented.
Likewise, when a new basic block is visited, the hash table is
cleared. I guess we could be smarter than just unconditionally
clearing the hash table in this later case, but this is what asan@llvm
does, and for now, I thought starting in a conservative manner might
have some value.
The hash table is destroyed at the end of the pass.
Bootstrapped and tested against trunk on x86-64-unknown-linux-gnu.
gcc/
* Makefile.in (asan.o): Add new dependency on hash-table.h
* asan.c (struct asan_mem_ref, struct mem_ref_hasher): New types.
(asan_mem_ref_init, asan_mem_ref_get_end, get_mem_ref_hash_table)
(has_stmt_been_instrumented_p, empty_mem_ref_hash_table)
(free_mem_ref_resources, has_mem_ref_been_instrumented)
(has_stmt_been_instrumented_p, update_mem_ref_hash_table)
(get_mem_ref_of_assignment): New functions.
(get_mem_refs_of_builtin_call): Extract from
instrument_builtin_call and tweak a little bit to make it fit with
the new signature.
(instrument_builtin_call): Use the new
get_mem_refs_of_builtin_call. Use gimple_call_builtin_p instead
of is_gimple_builtin_call.
(instrument_derefs, instrument_mem_region_access): Insert the
instrumented memory reference into the hash table.
(maybe_instrument_assignment): Renamed instrument_assignment into
this, and change it to advance the iterator when instrumentation
actually happened and return true in that case. This makes it
homogeneous with maybe_instrument_assignment, and thus give a
chance to callers to be more 'regular'.
(transform_statements): Clear the memory reference hash table
whenever we enter a new BB, when we cross a function call, or when
we are done transforming statements. Use
maybe_instrument_assignment instead of instrumentation. No more
need to special case maybe_instrument_assignment and advance the
iterator after calling it; it's now handled just like
maybe_instrument_call. Update comment.
gcc/testsuite/
* c-c++-common/asan/no-redundant-instrumentation-1.c: New test.
* testsuite/c-c++-common/asan/no-redundant-instrumentation-2.c: Likewise.
* testsuite/c-c++-common/asan/no-redundant-instrumentation-3.c: Likewise.
* testsuite/c-c++-common/asan/inc.c: Likewise.
From-SVN: r196008
2013-02-12 Vladimir Makarov <vmakarov@redhat.com>
PR inline-asm/56148
* lra-constraints.c (process_alt_operands): Match early clobber
operand with itself. Check conflicts with earlyclobner only if
the operand is not reloaded. Prefer to reload conflicting operand
if earlyclobber and matching operands are the same.
2013-02-12 Vladimir Makarov <vmakarov@redhat.com>
PR inline-asm/56148
* gcc.target/i386/pr56148.c: New test.
From-SVN: r195988
2013-02-12 Richard Biener <rguenther@suse.de>
PR lto/56297
* lto-streamer-out.c (write_symbol): Do not output symbols
for hard register variables.
* gcc.dg/lto/pr56297_0.c: New testcase.
* gcc.dg/lto/pr56297_0.c: Likewise.
From-SVN: r195979
2013-02-12 Richard Biener <rguenther@suse.de>
PR lto/56295
* gimple-streamer-in.c (input_gimple_stmt): Strip MEM_REFs off
decls again if possible.
From-SVN: r195976
PR rtl-optimization/56151
* optabs.c (add_equal_note): Don't return 0 if target is a MEM,
equal to op0 or op1, and last_insn pattern is CODE operation
with MEM dest and one of the operands matches that MEM.
* gcc.target/i386/pr56151.c: New test.
Co-Authored-By: Steven Bosscher <steven@gcc.gnu.org>
From-SVN: r195972