platform/upstream/linaro-gcc.git
5 years agoEnable build-tunable asan shadow scale size 85/210385/3
Mikhail Kashkarov [Fri, 28 Jun 2019 18:31:32 +0000 (21:31 +0300)]
Enable build-tunable asan shadow scale size

Use the following for the project config (3 is default):

  %define asan_shadow_scale 3
  Macros:
  asan_shadow_scale 3
  :Macros

+ backport https://reviews.llvm.org/D39471 for x86_64 shadow offset
+ backport https://reviews.llvm.org/D39472 for minimum redzone size
+ backport https://reviews.llvm.org/D39473 for internal alloc min alignment
+ backport https://reviews.llvm.org/D39474 to avoid assert failure for non-default shadow scale

Change-Id: I23b231f03d6ab47c6b4264f8c7837eb1197f4cc4

5 years ago * asan.c (asan_emit_stack_protection): Use full-sized mask to align 83/210383/3
ebotcazou [Fri, 15 Feb 2019 21:40:24 +0000 (21:40 +0000)]
* asan.c (asan_emit_stack_protection): Use full-sized mask to align
the base address on 64-bit strict-alignment platforms.

(cherry picked from 724165bd22886d1fa486513c1b695302b307726e)

Change-Id: I52f5266e8336b7959b655226ae8619afc35b2692
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@268949 138bc75d-0d04-0410-961f-82ee72b054a4

5 years ago * asan.c (asan_expand_mark_ifn): Take into account the alignment of 82/210382/3
ebotcazou [Tue, 12 Feb 2019 12:23:08 +0000 (12:23 +0000)]
* asan.c (asan_expand_mark_ifn): Take into account the alignment of
the object to pick the size of stores on strict-alignment platforms.

* config/sparc/sparc.md (*movsi_insn): Minor tweak.
(*movdi_insn_sp32): Likewise.
(*movdi_insn_sp64): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@268792 138bc75d-0d04-0410-961f-82ee72b054a4

(backported 3f00a89f9cdb0f2838ce0d853ef3bf6ff6f5a3ad without config/sparc fixes)

Change-Id: Id53952131b13fe5eba6b6de1f6d40531833d19fd

5 years ago PR sanitizer/88333 84/210384/3
jakub [Wed, 5 Dec 2018 08:26:06 +0000 (08:26 +0000)]
PR sanitizer/88333
* cfgexpand.c (expand_stack_vars): If asan_vec is empty, start with
aligning frame offset to ASAN_RED_ZONE_SIZE bytes.

* c-c++-common/asan/pr88333.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266817 138bc75d-0d04-0410-961f-82ee72b054a4

(backported db93a9789e3993801a493fcde11da7f08f212f6e)

Change-Id: Ie0c2c8f000777190e316c4051e2e781a5be823ef

5 years ago PR sanitizer/88291 81/210381/3
jakub [Sun, 2 Dec 2018 12:39:26 +0000 (12:39 +0000)]
PR sanitizer/88291
* asan.c (asan_clear_shadow): Move assert that len is multiple of 4
to the start of the function.
(asan_emit_stack_protection): When emitting clearing sequence for
epilogue, align offset down to ASAN_RED_ZONE_SIZE granularity,
add last_size_aligned which is last_size padded to multiples of
ASAN_RED_ZONE_SIZE and emit asan_clear_shadow always on 4 byte
boundaries.

* c-c++-common/asan/pr88291.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266721 138bc75d-0d04-0410-961f-82ee72b054a4

(cherry picked b0d945ba743397d845ab6bc3c3834241f28bb91f)

Change-Id: I8a86e9d61617253e8439ca2c5659a2436604d30b

5 years ago PR sanitizer/88289 80/210380/3
jakub [Sat, 1 Dec 2018 07:31:56 +0000 (07:31 +0000)]
PR sanitizer/88289
* asan.c (asan_redzone_buffer::flush_redzone_payload): Fix up
an off-by-one for BYTES_BIG_ENDIAN.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266708 138bc75d-0d04-0410-961f-82ee72b054a4

(cherry picked ef0c2db0d6a9d324bca1f4d2d4478034a63d54a7)

Change-Id: Ied661ed605dc4d060c78e5c6db31763fd35e77e1

5 years agoMake red zone size more flexible for stack variables (PR sanitizer/81715). 79/210379/3
marxin [Fri, 30 Nov 2018 14:25:15 +0000 (14:25 +0000)]
Make red zone size more flexible for stack variables (PR sanitizer/81715).

2018-11-30  Martin Liska  <mliska@suse.cz>

PR sanitizer/81715
* asan.c (asan_shadow_cst): Remove, partially transform
into flush_redzone_payload.
(RZ_BUFFER_SIZE): New.
(struct asan_redzone_buffer): New.
(asan_redzone_buffer::emit_redzone_byte): Likewise.
(asan_redzone_buffer::flush_redzone_payload): Likewise.
(asan_redzone_buffer::flush_if_full): Likewise.
(asan_emit_stack_protection): Use asan_redzone_buffer class
that is responsible for proper aligned stores and flushing
of shadow memory payload.
* asan.h (ASAN_MIN_RED_ZONE_SIZE): New.
(asan_var_and_redzone_size): Likewise.
* cfgexpand.c (expand_stack_vars): Use smaller alignment
(ASAN_MIN_RED_ZONE_SIZE) in order to make shadow memory
for automatic variables more compact.
2018-11-30  Martin Liska  <mliska@suse.cz>

PR sanitizer/81715
* c-c++-common/asan/asan-stack-small.c: New test.

(backported 57e4ba18100)

Change-Id: I58d73faf84206c26d8459b265e98c97cc242ea4a
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266664 138bc75d-0d04-0410-961f-82ee72b054a4

5 years agoASAN: emit line information of stack variables. 77/210377/3
marxin [Tue, 9 Oct 2018 08:34:52 +0000 (08:34 +0000)]
ASAN: emit line information of stack variables.

2018-10-09  Martin Liska  <mliska@suse.cz>

* asan.c (asan_emit_stack_protection): If a stack variable
is located in a same file as current function, then emit
line info into variable definition string.
2018-10-09  Martin Liska  <mliska@suse.cz>

* c-c++-common/asan/pr64820.c: Add line number to scanned
pattern.
* c-c++-common/asan/use-after-return-1.c: Likewise.
* g++.dg/asan/function-argument-1.C (main): Likewise.
* g++.dg/asan/function-argument-2.C (main): Likewise.
* g++.dg/asan/function-argument-3.C (main): Likewise.
* g++.dg/asan/use-after-scope-1.C (main): Likewise.
* g++.dg/asan/use-after-scope-2.C (main): Likewise.
* g++.dg/asan/use-after-scope-types-1.C (main): Likewise.
* g++.dg/asan/use-after-scope-types-2.C (main): Likewise.
* g++.dg/asan/use-after-scope-types-3.C (main): Likewise.
* g++.dg/asan/use-after-scope-types-4.C (main): Likewise.
* g++.dg/asan/use-after-scope-types-5.C (main): Likewise.
* gcc.dg/asan/pr78541.c (main): Likewise.
* gcc.dg/asan/use-after-scope-1.c (main): Likewise.
* gcc.dg/asan/use-after-scope-10.c (main): Likewise.
* gcc.dg/asan/use-after-scope-2.c (main): Likewise.
* gcc.dg/asan/use-after-scope-3.c (main): Likewise.
* gcc.dg/asan/use-after-scope-5.c (main): Likewise.
* gcc.dg/asan/use-after-scope-9.c (main): Likewise.

(backported 1db5adee4f01d05f3f1b9c09c04b9b772ace6859 without
  * g++.dg/asan/function-argument-1.C
  * g++.dg/asan/function-argument-2.C
  * g++.dg/asan/function-argument-3.C
  * gcc.dg/asan/pr78541.c
  * gcc.dg/asan/use-after-scope-10.c
test)

Change-Id: I03162f42275c2f3c0b92c6bfb397dbc91229a917
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@264951 138bc75d-0d04-0410-961f-82ee72b054a4

5 years agoAdd gcc_assert about stack alignment (PR sanitizer/82517). 76/210376/3
marxin [Tue, 9 Jan 2018 11:47:26 +0000 (11:47 +0000)]
Add gcc_assert about stack alignment (PR sanitizer/82517).

2018-01-09  Martin Liska  <mliska@suse.cz>

PR sanitizer/82517
* asan.c (shadow_mem_size): Add gcc_assert.

(cherry picked from e56a070cadd948b81a5b769e17c8c1162829de27)

Change-Id: I0f97457dfc30b6afbde93ff53e2b5d923946a122
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@256378 138bc75d-0d04-0410-961f-82ee72b054a4

5 years agoMake stack epilogue more efficient 78/210378/3
marxin [Mon, 3 Jul 2017 09:26:31 +0000 (09:26 +0000)]
Make stack epilogue more efficient

2017-07-03  Martin Liska  <mliska@suse.cz>

* asan.c (asan_emit_stack_protection): Unpoison just red zones
and shadow memory of auto variables which are subject of
use-after-scope sanitization.
(asan_expand_mark_ifn): Add do set only when is_poison.

(cherry picked 355c17620ce)

Change-Id: Ib36a512acb3e0dcb9e7dbfbd9a55661694e7e749
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249900 138bc75d-0d04-0410-961f-82ee72b054a4

5 years agoAdd binary annotations support (based on annobin plugin) 00/210400/3
Mikhail Kashkarov [Tue, 9 Jul 2019 19:40:49 +0000 (22:40 +0300)]
Add binary annotations support (based on annobin plugin)

Change-Id: Ib3571622cd090992ce42305b7c5985fd322322d4

5 years ago* gcc.dg/pr83623.c: Add additional options on hppa*-&-hpux* and arm*-*-*. 73/207473/1 accepted/tizen/base/20190613.220236 submit/tizen_base/20190605.111927
Dongkyun Son [Wed, 5 Jun 2019 06:56:45 +0000 (15:56 +0900)]
* gcc.dg/pr83623.c: Add additional options on hppa*-&-hpux* and arm*-*-*.

(includes 5839d47d0d65a35fa4791220ef57f50912ca40d5)

Change-Id: Icd2eab553e9fd30d4317301a93b2d5e2c56a27e4
Signed-off-by: Dongkyun Son <dongkyun.s@samsung.com>
5 years agoPR middle-end/83623 82/207282/2
jakub [Sun, 31 Dec 2017 23:50:32 +0000 (23:50 +0000)]
PR middle-end/83623
* expmed.c (expand_shift_1): For 2-byte rotates by BITS_PER_UNIT,
check for bswap in mode rather than HImode and use that in expand_unop
too.

* gcc.dg/pr83623.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@256051 138bc75d-0d04-0410-961f-82ee72b054a4

(cherry picked from commit 2876a3f3bbe119fb2fd0c1f414fa5048367b2ff8)

Change-Id: I9adfbbc9525351281742494c6872bca70da2e373

5 years agopackaging: add release information to pkgversion string. 69/159269/3 accepted/tizen/base/20190604.220502 submit/tizen_base/20190508.064126 submit/tizen_base/20190530.232927
Dongkyun Son [Wed, 8 Nov 2017 01:49:50 +0000 (10:49 +0900)]
packaging: add release information to pkgversion string.

gcc (Tizen/Linaro GCC %{version} %{gcc_release} %{release}) BASEVER DATESTAMP
%{release} can provide more information(revision, build count).

Change-Id: I73e4da88ebcee0269c6875b6ef40d5690dc4de67
Signed-off-by: Dongkyun Son <dongkyun.s@samsung.com>
5 years agoCherry pick libsanitizer patch (https://reviews.llvm.org/D54856). 31/202431/1 accepted/tizen/base/20190402.084601 submit/tizen_base/20190329.012305
marxin [Thu, 27 Dec 2018 09:47:20 +0000 (09:47 +0000)]
Cherry pick libsanitizer patch (https://reviews.llvm.org/D54856).

2018-12-27  Martin Liska  <mliska@suse.cz>

  PR sanitizer/86229
* asan/asan_errors.cc (ErrorAllocTypeMismatch::Print): Cherry
pick rL350085.
* asan/asan_errors.h (struct ErrorAllocTypeMismatch): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@267432 138bc75d-0d04-0410-961f-82ee72b054a4

(cherry picked from commit 27e7ab5c4e8aa2c89a5e9b91d1b4eb60a435b14f)

Change-Id: I016920774a6215f7a638cab88f268baeff049601

5 years ago[asan] Add __libc_siglongjmp/__libc_longjmp interceptors 31/196431/3 accepted/tizen/base/20190308.035726 submit/tizen_base/20190225.004849
Mikhail Kashkarov [Thu, 27 Dec 2018 09:42:37 +0000 (12:42 +0300)]
[asan] Add __libc_siglongjmp/__libc_longjmp interceptors

Change-Id: Ic247cb33f17743fa597b3a74baf7cf31c075165d

5 years agolibsanitizer: fix SVACE warnings. 04/196004/6 submit/tizen_base/20190221.133303
Andrey Drobyshev [Tue, 18 Dec 2018 12:44:59 +0000 (15:44 +0300)]
libsanitizer: fix SVACE warnings.

  * lsan_thread.cc: return value of a function '__lsan::CurrentThreadContext'
    is dereferenced without checking.
  * sanitizer_libc.cc: casting a signed value which has type 'char' to a
    bigger unsigned integer type 'unsigned int' while initializing a
    variable.
  * sanitizer_libignore.cc: constructor may not initialize class members of
    '__sanitizer::LibIgnore'.
  * sanitizer_printf.cc: 'minimal_num_length' with type 'u8', is promoted to
    type 'int' 32b in 'minimal_num_length - pos', then sign-extended to type
    'unsigned long' 64b.
  * sanitizer_symbolizer_posix_libcdep.cc: after having been compared to NULL
    value, pointer (...)->path is passed as 1st parameter in call to function
    '__sanitizer::LLVMSymbolizer::LLVMSymbolizer', where it is dereferenced.

Change-Id: I9ebcd68362d68be8d738f4b9d5eaad3fae796f6a
Signed-off-by: Andrey Drobyshev <a.drobyshev@samsung.com>
5 years agolibsanitizer: add filtering of sleep intervals for BackgroundThread. 86/194286/5
Andrey Drobyshev [Fri, 30 Nov 2018 15:30:55 +0000 (18:30 +0300)]
libsanitizer: add filtering of sleep intervals for BackgroundThread.

Previously sleep interval length of BackgroundThread was determined by a
hardcoded value, thus limiting time resolution of dependent tools, such
as Heap Profiler.  This commit implements simple algorithm which remembers
last several sleeps (namely 2), their durations and whether or not they
were followed by some interesting events (i.e. delivery of some memory
usage statistics).  Then it tries to predict an optimal sleep length for
the next time, changing it dynamically.

Change-Id: I6fc3865cbf4b9e8c5dd6ad4222eac2085a612b51
Signed-off-by: Andrey Drobyshev <a.drobyshev@samsung.com>
5 years agolibsanitizer: re-implement heap profiler. 25/191225/14
Dmitriy Evgenevich Gonzha [Wed, 14 Mar 2018 10:47:05 +0000 (13:47 +0300)]
libsanitizer: re-implement heap profiler.

In the previos heap profiler implementation HeapProfile instance was
created every time BackgroundThread wanted to collect statistical data.
This commit simply applies the singleton pattern: now there's only one
HeapProfile object which can both decide wether it's time to collect the
statistics and print profiling data.

Signed-off-by: Andrey Drobyshev <a.drobyshev@samsung.com>
Change-Id: I8dfa245d826c52749564346a2cd50788c5d91124

5 years agoaarch64 - Set the mode for the unspec in speculation_tracker insn. 75/198475/3 accepted/tizen/base/20190208.061719 submit/tizen_base/20190206.160957
rearnsha [Tue, 6 Nov 2018 17:18:37 +0000 (17:18 +0000)]
aarch64 - Set the mode for the unspec in speculation_tracker insn.

The speculation tracker insn in my recent patch set for CVE-2017-5753
was missing a mode on the UNSPEC.  Although this didn't break the
build, it did cause an unnecessary warning from the MD parsing
mechanism that I missed at the time.  It's a trivial fix, as follows:

* config/aarch64/aarch64.md (speculation_tracker): Set the mode for
the UNSPEC.

(backported 1ce555a208bf8e3422eadd9c1e3eb0b1b120a81b)

Change-Id: I525ae85eeafc2e9f42b365957abdb7b494a286c2
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@265849 138bc75d-0d04-0410-961f-82ee72b054a4

5 years agoAlthough there's no fundamental reason why shrink wrapping and 76/198476/3
rearnsha [Fri, 2 Nov 2018 13:36:31 +0000 (13:36 +0000)]
Although there's no fundamental reason why shrink wrapping and
speculation tracking are incompatible, a phase-ordering requirement
(we need to do speculation tracking before the final basic block
clean-up) means that the shrink wrapping pass can undo some of the
changes the speculation tracking pass makes.  The result is that the
tracking, while still safe is less comprehensive than we really want.

So to keep things simple, and because the tracking code is quite
expensive anyway, it seems best to just disable that pass when we are
tracking speculative execution.

 * config/aarch64/aarch64.c (aarch64_override_options): Disable
 shrink-wrapping when -mtrack-speculation.

(backported 3024ac6836fa5a0f8ab539a0823bfb609aef0e93)

Change-Id: I894aa3562b8ddfc951e2eb33c15bd9d79c423c0f
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@265747 138bc75d-0d04-0410-961f-82ee72b054a4

5 years agoPR target/86951 arm - Handle speculation barriers on pre-armv7 CPUs 74/198474/3
rearnsha [Thu, 23 Aug 2018 09:47:34 +0000 (09:47 +0000)]
PR target/86951 arm - Handle speculation barriers on pre-armv7 CPUs

The AArch32 instruction sets prior to Armv7 do not define the ISB and
DSB instructions that are needed to form a speculation barrier.  While
I do not know of any instances of cores based on those instruction
sets being vulnerable to speculative side channel attacks it is
possible to run code built for those ISAs on more recent hardware
where they would become vulnerable.

This patch works around this by using a library call added to libgcc.
That code can then take any platform-specific actions necessary to
ensure safety.

For the moment I've only handled two cases: the library code being
built for armv7 or later anyway and running on Linux.

On Linux we can handle this by calling the kernel function that will
flush a small amount of cache.  Such a sequence ends with a ISB+DSB
sequence if running on an Armv7 or later CPU.

gcc:

PR target/86951
* config/arm/arm-protos.h (arm_emit_speculation_barrier): New
prototype.
* config/arm/arm.c (speculation_barrier_libfunc): New static
variable.
(arm_init_libfuncs): Initialize it.
(arm_emit_speculation_barrier): New function.
* config/arm/arm.md (speculation_barrier): Call
arm_emit_speculation_barrier for architectures that do not have
DSB or ISB.
(speculation_barrier_insn): Only match on Armv7 or later.

libgcc:

PR target/86951
* config/arm/lib1funcs.asm (speculation_barrier): New function.
* config/arm/t-arm (LIB1ASMFUNCS): Add it to list of functions
to build.

(backported a7852b351bded1c6885e36e3ba70c298afcd1699)

Change-Id: I4b77551dad3effbe49b06ff8bdd20daae69869e3
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263806 138bc75d-0d04-0410-961f-82ee72b054a4

5 years agox86 - add speculation_barrier pattern 73/198473/3
rearnsha [Wed, 1 Aug 2018 08:16:38 +0000 (08:16 +0000)]
x86 - add speculation_barrier pattern

This patch adds a speculation barrier for x86, based on my
understanding of the required mitigation for that CPU, which is to use
an lfence instruction.

This patch needs some review by an x86 expert and if adjustments are
needed, I'd appreciate it if they could be picked up by the port
maintainer.  This is supposed to serve as an example of how to deploy
the new __builtin_speculation_safe_value() intrinsic on this
architecture.

* config/i386/i386.md (unspecv): Add UNSPECV_SPECULATION_BARRIER.
(speculation_barrier): New insn.

(backported 5812770a029b1a49b72cabf08b2f202d2d00dc69)

Change-Id: I94d1aacb04c9288a0fbeb38109aeb80a59ca47e6
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263196 138bc75d-0d04-0410-961f-82ee72b054a4

5 years ago * targhooks.c (default_have_speculation_safe_value): Add 72/198472/3
ian [Tue, 31 Jul 2018 20:51:06 +0000 (20:51 +0000)]
* targhooks.c (default_have_speculation_safe_value): Add
ATTRIBUTE_UNUSED.

(backported 30929ff6997501127e0d09e4917eef3f42d33899)

Change-Id: I59da0b5a1f07516058eacb291a436e80fc2d52d5
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263180 138bc75d-0d04-0410-961f-82ee72b054a4

5 years agotarghooks - provide an alternative hook for targets that never execute speculatively 71/198471/3
rearnsha [Tue, 31 Jul 2018 17:36:36 +0000 (17:36 +0000)]
targhooks - provide an alternative hook for targets that never execute speculatively

This hook adds an alternative implementation for the target hook
TARGET_HAVE_SPECULATION_SAFE_VALUE; it can be used by targets that have no
CPU implementations that execute code speculatively.  All that is needed for
such targets now is to add:

 #undef TARGET_HAVE_SPECULATION_SAFE_VALUE
 #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed.

to where you have your other target hooks and you're done.

gcc:
* targhooks.h (speculation_safe_value_not_needed): New prototype.
* targhooks.c (speculation_safe_value_not_needed): New function.
* target.def (have_speculation_safe_value): Update documentation.
* doc/tm.texi: Regenerated.

(backported 3e3448a9ae57194db317a72e68a3266a4cbdb39d)

Change-Id: I4532e9bc21029d5e452868dbe95c25a41d1f4a5c
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263175 138bc75d-0d04-0410-961f-82ee72b054a4

5 years agoAArch64 - use CSDB based sequences if speculation tracking is enabled 70/198470/3
rearnsha [Tue, 31 Jul 2018 17:36:26 +0000 (17:36 +0000)]
AArch64 - use CSDB based sequences if speculation tracking is enabled

In this final patch, now that we can track speculation through conditional
branches, we can use this information to use a less expensive CSDB based
speculation barrier.

* config/aarch64/iterators.md (ALLI_TI): New iterator.
* config/aarch64/aarch64.md (despeculate_copy<ALLI_TI:mode>): New
expand.
(despeculate_copy<ALLI:mode>_insn): New insn.
(despeculate_copyti_insn): New insn.
(despeculate_simple<ALLI:mode>): New insn
(despeculate_simpleti): New insn.
* config/aarch64/aarch64.c (aarch64_speculation_safe_value): New
function.
(TARGET_SPECULATION_SAFE_VALUE): Redefine to
aarch64_speculation_safe_value.
(aarch64_print_operand): Handle const0_rtx in modifier 'H'.

(backported ce52014acef8b301ede901792f9d25035cb727bf)

Change-Id: I0ea1ea8e425820a71d252d239ffb53a82162302c
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263174 138bc75d-0d04-0410-961f-82ee72b054a4

5 years agoAArch64 - new pass to add conditional-branch speculation tracking 69/198469/3
rearnsha [Tue, 31 Jul 2018 17:36:18 +0000 (17:36 +0000)]
AArch64 - new pass to add conditional-branch speculation tracking

This patch is the main part of the speculation tracking code.  It adds
a new target-specific pass that is run just before the final branch
reorg pass (so that it can clean up any new edge insertions we make).
The pass is only run with -mtrack-speculation is passed on the command
line.

One thing that did come to light as part of this was that the stack pointer
register was not being permitted in comparision instructions.  We rely on
that for moving the tracking state between SP and the scratch register at
function call boundaries.

* config/aarch64/aarch64-speculation.cc: New file.
* config/aarch64/aarch64-passes.def (pass_track_speculation): Add before
pass_reorder_blocks.
* config/aarch64/aarch64-protos.h (make_pass_track_speculation): Add
prototype.
* config/aarch64/aarch64.c (aarch64_conditional_register_usage): Fix
X14 and X15 when tracking speculation.
* config/aarch64/aarch64.md (register name constants): Add
SPECULATION_TRACKER_REGNUM and SPECULATION_SCRATCH_REGNUM.
(unspec): Add UNSPEC_SPECULATION_TRACKER.
(speculation_barrier): New insn attribute.
(cmp<mode>): Allow SP in comparisons.
(speculation_tracker): New insn.
(speculation_barrier): Add speculation_barrier attribute.
* config/aarch64/t-aarch64: Add make rule for aarch64-speculation.o.
* config.gcc (aarch64*-*-*): Add aarch64-speculation.o to extra_objs.
* doc/invoke.texi (AArch64 Options): Document -mtrack-speculation.

(backported b19562a81626f3e6adc5a5d4a185b36548539a4f)

Change-Id: Icece830281b0131f2a151bb43aa1aa3f94463836
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263173 138bc75d-0d04-0410-961f-82ee72b054a4

5 years agoAArch64 - disable CB[N]Z TB[N]Z when tracking speculation 68/198468/2
rearnsha [Tue, 31 Jul 2018 17:36:09 +0000 (17:36 +0000)]
AArch64 - disable CB[N]Z TB[N]Z when tracking speculation

The CB[N]Z and TB[N]Z instructions do not expose the comparison through
the condition code flags.  This makes it impossible to track speculative
execution through such a branch.  We can handle this relatively easily
by simply disabling the patterns in this case.

A side effect of this is that the split patterns for the atomic operations
need to also avoid generating these instructions.  They mostly have simple
fall-backs for this already.

* config/aarch64/aarch64.md (cb<optab><mode>1): Disable when
aarch64_track_speculation is true.
(tb<optab><mode>1): Likewise.
* config/aarch64/aarch64.c (aarch64_split_compare_regs): Do not
generate CB[N]Z when tracking speculation.
(aarch64_split_compare_and_swap): Likewise.
(aarch64_split_atomic_op): Likewise.

(backported eaf891585b16ef84046ae73a01bb1c7189c682e9)

Change-Id: I0d0a090ef7bcf074b9e4d6ee115e71faa157962f
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263172 138bc75d-0d04-0410-961f-82ee72b054a4

5 years agoAArch64 - Add new option -mtrack-speculation 67/198467/2
rearnsha [Tue, 31 Jul 2018 17:36:00 +0000 (17:36 +0000)]
AArch64 - Add new option -mtrack-speculation

This patch doesn't do anything useful, it simply adds a new command-line
option -mtrack-speculation to AArch64.  Subsequent patches build on this.

* config/aarch64/aarch64.opt (mtrack-speculation): New target option.

(backported 97eb2b8649e777da576598448d9d68afcfe69b54)

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263171 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: I70cf2047662fa73e3d7090d62392210bac872591

5 years agoAArch64 - add speculation barrier 66/198466/2
rearnsha [Tue, 31 Jul 2018 17:35:50 +0000 (17:35 +0000)]
AArch64 - add speculation barrier

Similar to Arm, this adds an unconditional speculation barrier for AArch64.

* config/aarch64.md (unspecv): Add UNSPECV_SPECULAION_BARRIER.
(speculation_barrier): New insn.

(backported f9d2906f0b6803c42b2200da5e32e331930fc306)

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263170 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: Ic9a1826c24f8597033716cec3d02de12fdb57dba

5 years agoArm - add speculation_barrier pattern 65/198465/2
rearnsha [Tue, 31 Jul 2018 17:35:41 +0000 (17:35 +0000)]
Arm - add speculation_barrier pattern

This patch defines a speculation barrier for AArch32.

* config/arm/unspecs.md (unspecv): Add VUNSPEC_SPECULATION_BARRIER.
* config/arm/arm.md (speculation_barrier): New expand.
(speculation_barrier_insn): New pattern.

(backported be626997e0edc646c17e9e1eadabf97152e82eeb)

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263169 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: I5f587e22dd1a92440a6a208e2baca189427557da

5 years agoAdd __builtin_speculation_safe_value 64/198464/2
rearnsha [Tue, 31 Jul 2018 17:35:32 +0000 (17:35 +0000)]
Add __builtin_speculation_safe_value

This patch defines a new intrinsic function
__builtin_speculation_safe_value.  A generic default implementation is
defined which will attempt to use the backend pattern
"speculation_safe_barrier".  If this pattern is not defined, or if it
is not available, then the compiler will emit a warning, but
compilation will continue.

Note that the test spec-barrier-1.c will currently fail on all
targets.  This is deliberate, the failure will go away when
appropriate action is taken for each target backend.

gcc:
* builtin-types.def (BT_FN_PTR_PTR_VAR): New function type.
(BT_FN_I1_I1_VAR, BT_FN_I2_I2_VAR, BT_FN_I4_I4_VAR): Likewise.
(BT_FN_I8_I8_VAR, BT_FN_I16_I16_VAR): Likewise.
* builtin-attrs.def (ATTR_NOVOPS_NOTHROW_LEAF_LIST): New attribute
list.
* builtins.def (BUILT_IN_SPECULATION_SAFE_VALUE_N): New builtin.
(BUILT_IN_SPECULATION_SAFE_VALUE_PTR): New internal builtin.
(BUILT_IN_SPECULATION_SAFE_VALUE_1): Likewise.
(BUILT_IN_SPECULATION_SAFE_VALUE_2): Likewise.
(BUILT_IN_SPECULATION_SAFE_VALUE_4): Likewise.
(BUILT_IN_SPECULATION_SAFE_VALUE_8): Likewise.
(BUILT_IN_SPECULATION_SAFE_VALUE_16): Likewise.
* builtins.c (expand_speculation_safe_value): New function.
(expand_builtin): Call it.
* doc/cpp.texi: Document predefine __HAVE_SPECULATION_SAFE_VALUE.
* doc/extend.texi: Document __builtin_speculation_safe_value.
* doc/md.texi: Document "speculation_barrier" pattern.
* doc/tm.texi.in: Pull in TARGET_SPECULATION_SAFE_VALUE and
TARGET_HAVE_SPECULATION_SAFE_VALUE.
* doc/tm.texi: Regenerated.
* target.def (have_speculation_safe_value, speculation_safe_value): New
hooks.
* targhooks.c (default_have_speculation_safe_value): New function.
(default_speculation_safe_value): New function.
* targhooks.h (default_have_speculation_safe_value): Add prototype.
(default_speculation_safe_value): Add prototype.

c-family:
* c-common.c (speculation_safe_resolve_call): New function.
(speculation_safe_resolve_params): New function.
(speculation_safe_resolve_return): New function.
(resolve_overloaded_builtin): Handle __builtin_speculation_safe_value.
* c-cppbuiltin.c (c_cpp_builtins): Add pre-define for
__HAVE_SPECULATION_SAFE_VALUE.

testsuite:
* c-c++-common/spec-barrier-1.c: New test.
* c-c++-common/spec-barrier-2.c: New test.
* gcc.dg/spec-barrier-3.c: New test.

(backported 123081efd41261af8830d6c796a9b12435806bac)

Change-Id: I1d0e777c8e098f5a1d30aa5fa3090c8ce6b3dbee
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263168 138bc75d-0d04-0410-961f-82ee72b054a4

5 years ago[AArch64] Emit tighter strong atomic compare-exchange loop when comparing against... 63/198463/2
ktkachov [Fri, 2 Jun 2017 14:41:52 +0000 (14:41 +0000)]
[AArch64] Emit tighter strong atomic compare-exchange loop when comparing against zero

* config/aarch64/aarch64.c (aarch64_split_compare_and_swap):
Emit CBNZ inside loop when doing a strong exchange and comparing
against zero.  Generate the CC flags after the loop.

* gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c: New test.

(backported c5dcf8e544c5e98f1160ec390111b28d11d73b68)

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248832 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: I5204c56a8d3c11b0fde6697007d601cbafdb3ccf

5 years ago[ARM] PR rtl-optimization/68664 Implement TARGET_SCHED_CAN_SPECULATE_INSN hook 61/198461/5
ktkachov [Tue, 14 Feb 2017 10:33:50 +0000 (10:33 +0000)]
[ARM] PR rtl-optimization/68664 Implement TARGET_SCHED_CAN_SPECULATE_INSN hook

PR rtl-optimization/68664
* config/arm/arm.c (arm_sched_can_speculate_insn):
New function.  Declare prototype.
(TARGET_SCHED_CAN_SPECULATE_INSN): Define.

(backported a705f613f2fe0ff13b18fdf92af1dc5574c963d3)

Change-Id: I1eb8f369ebf3d85662df78e9da62cf0be35d8b5a
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@245425 138bc75d-0d04-0410-961f-82ee72b054a4

5 years ago[AArch64] Use new target pass registration framework for FMA steering pass 62/198462/1
ktkachov [Mon, 17 Oct 2016 16:37:38 +0000 (16:37 +0000)]
[AArch64] Use new target pass registration framework for FMA steering pass

* config/aarch64/aarch64.c: Delete inclusion of
cortex-a57-fma-steering.h.
(aarch64_override_options): Delete call
to aarch64_register_fma_steering.
* config/aarch64/aarch64-protos.h (make_pass_fma_steering): Declare.
* config/aarch64/cortex-a57-fma-steering.h: Delete.
* config/aarch64/aarch64-passes.def: New file.
* config/aarch64/cortex-a57-fma-steering.c
(aarch64_register_fma_steering): Delete definition.
(make_pass_fma_steering): Remove static qualifier.
* config/aarch64/t-aarch64 (PASSES_EXTRA): New directive.
(cortex-a57-fma-steering.o): Remove dependency on
cortex-a57-fma-steering.h.

(backported e8ebfb45f2e320c6a1e810c9d7ca1c40e2b26e6b)

Change-Id: I608f6d880296473c76c203e387c96791be9e50f2
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241248 138bc75d-0d04-0410-961f-82ee72b054a4

5 years ago[ESan] Fix typo for the testsuite. 66/189266/4 accepted/tizen/base/20190201.061404 submit/tizen_base/20190122.032226
Denis Khalikov [Fri, 14 Sep 2018 10:43:20 +0000 (13:43 +0300)]
[ESan] Fix typo for the testsuite.

Change-Id: I4fc5c6f0978b4be6aa286c42e06b34c687574a6c

5 years ago[LSan] Export a LSan API for use it third party 08/195608/5
Vyacheslav Cherkashin [Wed, 12 Dec 2018 15:11:52 +0000 (18:11 +0300)]
[LSan] Export a LSan API for use it third party

This API is needed to use LSan in conjunction with SWAP

Change-Id: Iff1ceaca9242a889b0b68f672302f8a0b3808411
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
5 years ago[LSan] Add dynamic loading support for LSan library 50/192250/6
Vyacheslav Cherkashin [Wed, 31 Oct 2018 14:52:22 +0000 (17:52 +0300)]
[LSan] Add dynamic loading support for LSan library

The LSan library has very big static TLS section

Problem:
  - LSan library could not be loaded dynamically because it had a very
    big static TLS section.
        AllocatorCache: ~15KB for 32bit
                        ~53KB for 64bit
Solution:
  - Store in the TLS section only a pointer to the AllocatorCache and
    dynamically allocate memory for it.

Change-Id: I6e90e6682e277c90825938f5732867b6564d62b4
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
5 years ago[LSan] Factor lsan allocator cache accesses into a function 49/192249/5
Francis Ricci [Thu, 25 Oct 2018 11:26:37 +0000 (14:26 +0300)]
[LSan] Factor lsan allocator cache accesses into a function

Summary:
This patch is the first step towards allows us to move away from using
__thread for the allocator cache on darwin,
which is requiring for building lsan for darwin on ios version 7
and on iossim i386.

This will be followed by patches to move the function into OS-specific files.

Reviewers: kubamracek, kcc

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D29994

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298537 91177308-0d34-0410-b5e6-96231b3b80d8

Backport:
  http://llvm.org/git/compiler-rt 65ede46c

Change-Id: Icd528cc4e96c63489c7d25cbb3af100a32d4a26f
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
5 years ago[LSan] Report the missing linker only when the linker is actually missing. 48/192248/4
Alex Shlyapnikov [Mon, 15 May 2017 23:11:01 +0000 (23:11 +0000)]
[LSan] Report the missing linker only when the linker is actually missing.

Reviewers: eugenis

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D33218

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@303129 91177308-0d34-0410-b5e6-96231b3b80d8

Backport:
  http://llvm.org/git/compiler-rt 4ba4036

Change-Id: I1c01e8679206af77fcd971a8fed5b8dde0e42b15

6 years agoMove asan/pr80659.c to gcc/testsuite folder 14/192014/1 accepted/tizen/base/20181109.114837 submit/tizen_base/20181105.081624
Mikhail Kashkarov [Fri, 26 Oct 2018 19:06:18 +0000 (22:06 +0300)]
Move asan/pr80659.c to gcc/testsuite folder

Fix testcase placement after e2cd7f1b

Change-Id: Idd0d622ca66573c5a8005d139fbbff033bc8abe3

6 years agopackaging: set %arm(armv7l and armv7hl) to esan_arch 89/191589/3
Dongkyun Son [Fri, 19 Oct 2018 01:40:34 +0000 (10:40 +0900)]
packaging: set %arm(armv7l and armv7hl) to esan_arch

Change-Id: I5afa3a89fe3dbffc71a4883f02ef6ac95fe8eeb4
Signed-off-by: Dongkyun Son <dongkyun.s@samsung.com>
6 years agopackaging: Enable gcc build with mthumb-fp 53/188053/3
Denis Khalikov [Wed, 22 Aug 2018 10:48:13 +0000 (13:48 +0300)]
packaging: Enable gcc build with mthumb-fp

Change-Id: Ib433b7163a1541134ed7bbf4b446a70fb5a2f34a

6 years agoSwitch off -Wswitch-unreachable by default (move to Wextra) 84/191684/1
Slava Barinov [Mon, 22 Oct 2018 08:16:29 +0000 (11:16 +0300)]
Switch off -Wswitch-unreachable by default (move to Wextra)

Change-Id: I17f651eadbea96d8a48a72d0be7b345955383b2f
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
6 years ago[Sanitizers] Disable use-after-scope by default. 01/190801/2
Denis Khalikov [Fri, 5 Oct 2018 08:57:28 +0000 (11:57 +0300)]
[Sanitizers] Disable use-after-scope by default.

So, until the patch "Speed up use-after-scope (v2): rewrite into SSA"
is not implemented, we set use-after-scope disabled by default.

Change-Id: Ia84ce0652ce68bc7c269d72a2a4613cb0806bcf4

6 years agoInitialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST (PR sanitizer/80879). 85/189285/2
marxin [Mon, 19 Jun 2017 13:27:48 +0000 (13:27 +0000)]
Initialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST (PR sanitizer/80879).

2017-06-19  Martin Liska  <mliska@suse.cz>

PR sanitizer/80879
* gimplify.c (gimplify_switch_expr):
Initialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST.
2017-06-19  Martin Liska  <mliska@suse.cz>

PR sanitizer/80879
* gcc.dg/asan/use-after-scope-switch-4.c: New test.

upstream hash: dfbe80905a8674b4b1be4bf9181e824b37ffa33a
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249368 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: I64057623544d67381f52230ba75a9fa804eb6eb2

6 years agoAdd pretty printer for ASAN_MARK and add a helper fn 53/190553/2
marxin [Tue, 13 Dec 2016 09:14:47 +0000 (09:14 +0000)]
Add pretty printer for ASAN_MARK and add a helper fn

        * asan.c (asan_mark_poison_p): Remove.
        (asan_mark_p): New function.
        (transform_statements): Use the function.
        (asan_expand_mark_ifn): Do not use masked enum.
        * asan.h (enum asan_mark_flags): Declare it via a macro.
        * gimple-pretty-print.c (dump_gimple_call_args): Dump first
        argument of ASAN_MARK.
        * gimplify.c (build_asan_poison_call_expr): Use new enum values.
        (asan_poison_variable): Likewise.
        * gcc.dg/asan/use-after-scope-goto-1.c: Update first argument of
        scanned pattern ASAN_MARK.
        * gcc.dg/asan/use-after-scope-goto-2.c: Likewise.
        * gcc.dg/asan/use-after-scope-switch-1.c: Likewise.
        * gcc.dg/asan/use-after-scope-switch-2.c: Likewise.
        * gcc.dg/asan/use-after-scope-switch-3.c: Likewise.

Change-Id: Ife3e6037a03ec2b25a15d45bb301f43b750e6649
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243597138bc75d-0d04-0410-961f-82ee72b054a4

6 years agoPR sanitizer/80659 46/190546/3
mpolacek [Wed, 17 May 2017 09:59:20 +0000 (09:59 +0000)]
PR sanitizer/80659

  * c-decl.c (build_compound_literal): Set DECL_ARTIFICIAL and
  DECL_IGNORED_P even for non-static compound literals.
  * gcc.dg/asan/pr80659.c: New test.

Change-Id: I7565aba65e49836947e0faf2eb5ea668b46a0d87
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248143138bc75d-0d04-0410-961f-82ee72b054a4

6 years agoFix PR sanitizer/78270 (part 2) 84/189284/2
marxin [Wed, 16 Nov 2016 11:56:58 +0000 (11:56 +0000)]
Fix PR sanitizer/78270 (part 2)

PR sanitizer/78270
* gimplify.c (gimplify_switch_expr): Always save previous
gimplify_ctxp->live_switch_vars.
PR sanitizer/78270
* gcc.dg/asan/pr78270.c: Update comment style.
* gcc.dg/asan/pr78270-2.c: New test.

upstream hash: 904e262bdb88c2cf1eefeb4997c8d4ed2a888d55
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242485 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: I760170bff746390269035dd2c10afff960d06445

6 years agoCreate live_switch_vars conditionally (PR sanitizer/78270) 83/189283/2
marxin [Thu, 10 Nov 2016 11:21:03 +0000 (11:21 +0000)]
Create live_switch_vars conditionally (PR sanitizer/78270)

PR sanitizer/78270
* gcc.dg/asan/pr78270.c: New test.
PR sanitizer/78270
* gimplify.c (gimplify_switch_expr): Create live_switch_vars
only when SWITCH_BODY is a BIND_EXPR.

upstream hash: 65dc25166f86f75a85141e56344f482d41f3b024
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242036 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: I8bc4e10c86602e72321af171755f7c54e6bd164c

6 years agouse-after-scope fallout 82/189282/2
marxin [Tue, 8 Nov 2016 12:28:33 +0000 (12:28 +0000)]
use-after-scope fallout

PR testsuite/78242
* g++.dg/asan/use-after-scope-4.C: New test.
* g++.dg/asan/use-after-scope-types-4.C: Update scanned pattern.
* gcc.dg/asan/use-after-scope-8.c: Remove.
PR testsuite/78242
* dbgcnt.def: Add new debug counter asan_use_after_scope.
* gimplify.c (gimplify_decl_expr): Do not sanitize vars
with a value expr.  Do not add artificial variables to
live_switch_vars.  Use the debug counter.
(gimplify_target_expr): Use the debug counter.
* internal-fn.def: Remove ECF_TM_PURE from ASAN_MARK builtin.
* sanitizer.def: Set ATTR_NOTHROW_LEAF_LIST to
BUILT_IN_ASAN_CLOBBER_N and BUILT_IN_ASAN_UNCLOBBER_N.

upstream hash: d71fcb4d6c78c38912a87df7e0aa09407b691f79
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241961 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: I9e5609ee7f9015cfd0951ad8aedd1437d90dca9d

6 years agoIntroduce tests for -fsanitize-address-use-after-scope 81/189281/2
marxin [Mon, 7 Nov 2016 10:25:18 +0000 (10:25 +0000)]
Introduce tests for -fsanitize-address-use-after-scope

* c-c++-common/asan/force-inline-opt0-1.c: Disable
-f-sanitize-address-use-after-scope.
* c-c++-common/asan/inc.c: Change number of expected ASAN_CHECK
internal fn calls.
* g++.dg/asan/use-after-scope-1.C: New test.
* g++.dg/asan/use-after-scope-2.C: Likewise.
* g++.dg/asan/use-after-scope-3.C: Likewise.
* g++.dg/asan/use-after-scope-types-1.C: Likewise.
* g++.dg/asan/use-after-scope-types-2.C: Likewise.
* g++.dg/asan/use-after-scope-types-3.C: Likewise.
* g++.dg/asan/use-after-scope-types-4.C: Likewise.
* g++.dg/asan/use-after-scope-types-5.C: Likewise.
* g++.dg/asan/use-after-scope-types.h: Likewise.
* gcc.dg/asan/use-after-scope-1.c: Likewise.
* gcc.dg/asan/use-after-scope-2.c: Likewise.
* gcc.dg/asan/use-after-scope-3.c: Likewise.
* gcc.dg/asan/use-after-scope-4.c: Likewise.
* gcc.dg/asan/use-after-scope-5.c: Likewise.
* gcc.dg/asan/use-after-scope-6.c: Likewise.
* gcc.dg/asan/use-after-scope-7.c: Likewise.
* gcc.dg/asan/use-after-scope-8.c: Likewise.
* gcc.dg/asan/use-after-scope-9.c: Likewise.
* gcc.dg/asan/use-after-scope-switch-1.c: Likewise.
* gcc.dg/asan/use-after-scope-switch-2.c: Likewise.
* gcc.dg/asan/use-after-scope-switch-3.c: Likewise.
* gcc.dg/asan/use-after-scope-goto-1.c: Likewise.
* gcc.dg/asan/use-after-scope-goto-2.c: Likewise.

upstream hash: ea86011c3ffb79f3a8ce8f1ffe0f89abfb8d7ace
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241897 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: Ibab662fa2a192a856c195377cb08796bcad7112f

6 years agoIntroduce -fsanitize-address-use-after-scope 80/189280/2
marxin [Mon, 7 Nov 2016 10:23:38 +0000 (10:23 +0000)]
Introduce -fsanitize-address-use-after-scope

* c-warn.c (warn_for_unused_label): Save all labels used
in goto or in &label.
* asan.c (enum asan_check_flags): Move the enum to header file.
(asan_init_shadow_ptr_types): Make type creation more generic.
(shadow_mem_size): New function.
(asan_emit_stack_protection): Use newly added ASAN_SHADOW_GRANULARITY.
Rewritten stack unpoisoning code.
(build_shadow_mem_access): Add new argument return_address.
(instrument_derefs): Instrument local variables if use after scope
sanitization is enabled.
(asan_store_shadow_bytes): New function.
(asan_expand_mark_ifn): Likewise.
(asan_sanitize_stack_p): Moved from asan_sanitize_stack_p.
* asan.h (enum asan_mark_flags): Moved here from asan.c
(asan_protect_stack_decl): Protect all declaration that need
to live in memory.
(asan_sanitize_use_after_scope): New function.
(asan_no_sanitize_address_p): Likewise.
* cfgexpand.c (partition_stack_vars): Consider
asan_sanitize_use_after_scope in condition.
(expand_stack_vars): Likewise.
* common.opt (-fsanitize-address-use-after-scope): New option.
* doc/invoke.texi (use-after-scope-direct-emission-threshold):
Explain the parameter.
* flag-types.h (enum sanitize_code): Define SANITIZE_USE_AFTER_SCOPE.
* gimplify.c (build_asan_poison_call_expr): New function.
(asan_poison_variable): Likewise.
(gimplify_bind_expr): Generate poisoning/unpoisoning for local
variables that have address taken.
(gimplify_decl_expr): Likewise.
(gimplify_target_expr): Likewise for C++ temporaries.
(sort_by_decl_uid): New function.
(gimplify_expr): Unpoison all variables for a label we can jump
from outside of a scope.
(gimplify_switch_expr): Unpoison variables defined in the switch
context.
(gimplify_function_tree): Clear asan_poisoned_variables.
(asan_poison_variables): New function.
(warn_switch_unreachable_r): Handle IFN_ASAN_MARK.
* internal-fn.c (expand_ASAN_MARK): New function.
* internal-fn.def (ASAN_MARK): Declare.
* opts.c (finish_options): Handle -fstack-reuse if
-fsanitize-address-use-after-scope is enabled.
(common_handle_option): Enable address sanitization if
-fsanitize-address-use-after-scope is enabled.
* params.def (PARAM_USE_AFTER_SCOPE_DIRECT_EMISSION_THRESHOLD):
New parameter.
* params.h: Likewise.
* sancov.c (pass_sanopt::execute): Handle IFN_ASAN_MARK.
* sanitizer.def: Define __asan_poison_stack_memory and
__asan_unpoison_stack_memory functions.
* asan.c (asan_mark_poison_p): New function.
(transform_statements): Handle asan_mark_poison_p calls.
* gimple.c (nonfreeing_call_p): Handle IFN_ASAN_MARK.

With fixes for tizen linaro-gcc by Dmitriy Gonzha

Change-Id: Ia39cbdfadac97f339dceb973872e15ee0d67ea19
upstream hash: 629b6abce95170a3ee8417479e82615fa1e4b67e
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241896 138bc75d-0d04-0410-961f-82ee72b054a4

6 years agoImplement -Wimplicit-fallthrough. 79/189279/2
mpolacek [Mon, 26 Sep 2016 09:42:50 +0000 (09:42 +0000)]
Implement -Wimplicit-fallthrough.

With fixes for tizen linaro-gcc by Dmitriy Gonzha.
Not fully implement implicit-fallthrough. Some tests are fail.
Because of possible errors turned off from -Wextra and renamed to
"-Wimplicit-fallthrough-disabled".
Required for -fsanitize-address-use-after-scope

Change-Id: I088b82dce350c017ecb3933c1cba3b2b01dde3f7
upstream hash: 3c77f69c50d3377491c917808fbfc4b9787acd6f
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240485 138bc75d-0d04-0410-961f-82ee72b054a4

6 years ago PR c/7652 78/189278/2
mpolacek [Fri, 12 Aug 2016 10:30:47 +0000 (10:30 +0000)]
PR c/7652
gcc/
* alias.c (find_base_value): Adjust fall through comment.
* cfgexpand.c (expand_debug_expr): Likewise.
* combine.c (find_split_point): Likewise.
(expand_compound_operation): Likewise.  Add FALLTHRU.
(make_compound_operation): Adjust fall through comment.
(canon_reg_for_combine): Add FALLTHRU.
(force_to_mode): Adjust fall through comment.
(simplify_shift_const_1): Likewise.
(simplify_comparison): Likewise.
* config/aarch64/aarch64-builtins.c (aarch64_simd_expand_args): Add
FALLTHRU.
* config/aarch64/predicates.md: Likewise.
* config/i386/i386.c (function_arg_advance_32): Likewise.
(ix86_gimplify_va_arg): Likewise.
(print_reg): Likewise.
(ix86_print_operand): Likewise.
(ix86_build_const_vector): Likewise.
(ix86_expand_branch): Likewise.
(ix86_sched_init_global): Adjust fall through comment.
(ix86_expand_args_builtin): Add FALLTHRU.
(ix86_expand_builtin): Likewise.
(ix86_expand_vector_init_one_var): Likewise.
* config/rs6000/rs6000.c (rs6000_emit_vector_compare_inner): Likewise.
(rs6000_adjust_cost): Likewise.
(insn_must_be_first_in_group): Likewise.
* config/rs6000/rs6000.md: Likewise.  Adjust fall through comment.
* dbxout.c (dbxout_symbol): Adjust fall through comment.
* df-scan.c (df_uses_record): Likewise.
* dojump.c (do_jump): Add FALLTHRU.
* dwarf2out.c (mem_loc_descriptor): Likewise.  Adjust fall through
comment.
(resolve_args_picking_1): Adjust fall through comment.
(loc_list_from_tree_1): Likewise.
* expmed.c (make_tree): Likewise.
* expr.c (expand_expr_real_2): Add FALLTHRU.
(expand_expr_real_1): Likewise.  Adjust fall through comment.
* fold-const.c (const_binop): Adjust fall through comment.
(fold_truth_not_expr): Likewise.
(fold_cond_expr_with_comparison): Add FALLTHRU.
(fold_binary_loc): Likewise.
(contains_label_1): Adjust fall through comment.
(multiple_of_p): Likewise.
* gcov-tool.c (process_args): Add FALLTHRU.
* genattrtab.c (check_attr_test): Likewise.
(write_test_expr): Likewise.
* genconfig.c (walk_insn_part): Likewise.
* genpreds.c (validate_exp): Adjust fall through comment.
(needs_variable): Likewise.
* gensupport.c (get_alternatives_number): Add FALLTHRU.
(subst_dup): Likewise.
* gimple-pretty-print.c (dump_gimple_assign): Likewise.
* gimplify.c (gimplify_addr_expr): Adjust fall through comment.
(gimplify_scan_omp_clauses): Add FALLTHRU.
(goa_stabilize_expr): Likewise.
* graphite-isl-ast-to-gimple.c (substitute_ssa_name): Adjust fall
through comment.
* hsa-gen.c (get_address_from_value): Likewise.
* ipa-icf.c (sem_function::hash_stmt): Likewise.
* ira.c (ira_setup_alts): Add FALLTHRU.
* lra-eliminations.c (lra_eliminate_regs_1): Adjust fall through
comment.
* lto-streamer-out.c (lto_output_tree_ref): Add FALLTHRU.
* opts.c (common_handle_option): Likewise.
* read-rtl.c (read_rtx_code): Likewise.
* real.c (round_for_format): Likewise.
* recog.c (asm_operand_ok): Likewise.
* reginfo.c (reg_scan_mark_refs): Adjust fall through comment.
* reload1.c (set_label_offsets): Likewise.
(eliminate_regs_1): Likewise.
(reload_reg_reaches_end_p): Likewise.
* rtlanal.c (commutative_operand_precedence): Add FALLTHRU.
(rtx_cost): Likewise.
* sched-rgn.c (is_exception_free): Likewise.
* simplify-rtx.c (simplify_rtx): Adjust fall through comment.
* stor-layout.c (int_mode_for_mode): Likewise.
* toplev.c (print_to_asm_out_file): Likewise.
(print_to_stderr): Likewise.
* tree-cfg.c (gimple_verify_flow_info): Likewise.
* tree-chrec.c (chrec_fold_plus_1): Add FALLTHRU.
(chrec_fold_multiply): Likewise.
(evolution_function_is_invariant_rec_p): Likewise.
(for_each_scev_op): Likewise.
* tree-data-ref.c (siv_subscript_p): Likewise.
(get_references_in_stmt): Likewise.
* tree.c (find_placeholder_in_expr): Adjust fall through comment.
(substitute_in_expr): Likewise.
(type_cache_hasher::equal): Likewise.
(walk_type_fields): Likewise.
* var-tracking.c (adjust_mems): Add FALLTHRU.
(set_dv_changed): Adjust fall through comment.
* varasm.c (default_function_section): Add FALLTHRU.
gcc/c-family/
* c-common.c (scalar_to_vector): Adjust fall through comment.
* c-opts.c (c_common_handle_option): Likewise.
* c-pragma.c (handle_pragma_pack): Add FALLTHRU.
* c-pretty-print.c (c_pretty_printer::postfix_expression): Adjust
fall through comment.
* cilk.c (extract_free_variables): Add FALLTHRU.
gcc/c/
* c-parser.c (c_parser_external_declaration): Add FALLTHRU.
(c_parser_postfix_expression): Likewise.
* c-typeck.c (build_unary_op): Adjust fall through comment.
(c_mark_addressable): Likewise.
gcc/cp/
* call.c (add_builtin_candidate): Add FALLTHRU.
(build_integral_nontype_arg_conv): Adjust fall through comment.
(build_new_op_1): Add FALLTHRU.
(convert_like_real): Adjust fall through comment.
* class.c (fixed_type_or_null): Likewise.
* constexpr.c (cxx_eval_constant_expression): Likewise.
(potential_constant_expression_1): Likewise.  Add FALLTHRU.
* cp-gimplify.c (cp_gimplify_expr): Adjust fall through comment.
(cp_fold): Add FALLTHRU.
* cvt.c (build_expr_type_conversion): Adjust fall through comment.
* cxx-pretty-print.c (pp_cxx_unqualified_id): Add FALLTHRU.
(pp_cxx_qualified_id): Likewise.
(cxx_pretty_printer::constant): Adjust fall through comment.
(cxx_pretty_printer::primary_expression): Add FALLTHRU.
(pp_cxx_pm_expression): Adjust fall through comment.
(cxx_pretty_printer::expression): Add FALLTHRU.
(cxx_pretty_printer::declaration_specifiers): Reformat code.
(pp_cxx_type_specifier_seq): Adjust fall through comment.
(pp_cxx_ptr_operator): Likewise.  Add FALLTHRU.
* error.c (dump_type): Adjust fall through comment.
(dump_decl): Likewise.
* mangle.c (write_type): Likewise.
* method.c (synthesized_method_walk): Add FALLTHRU.
* name-lookup.c (arg_assoc_type): Likewise.
* parser.c (cp_lexer_print_token): Adjust fall through comment.
(cp_parser_primary_expression): Add FALLTHRU.
(cp_parser_operator): Likewise.
* pt.c (find_parameter_packs_r): Likewise.
(tsubst_aggr_type): Adjust fall through comment.
* semantics.c (finish_omp_clauses): Add FALLTHRU.
* tree.c (lvalue_kind): Likewise.
gcc/fortran/
* decl.c (match_attr_spec): Add FALLTHRU.
* primary.c (match_arg_list_function): Likewise.
* resolve.c (resolve_operator): Adjust fall through comment.
(fixup_charlen): Add FALLTHRU.
(resolve_allocate_expr): Adjust fall through comment.
* trans-array.c (gfc_conv_ss_startstride): Add FALLTHRU.
* trans-intrinsic.c (gfc_conv_intrinsic_len): Adjust fall through
comment.
gcc/java/
* expr.c (java_truthvalue_conversion): Adjust fall through comment.
* jcf-io.c (verify_constant_pool): Likewise.
* typeck.c (promote_type): Likewise.
gcc/objc/
* objc-encoding.c (encode_type): Add FALLTHRU.
libcpp/
* lex.c (search_line_fast): Add FALLTHRU.
(_cpp_lex_direct): Likewise.
(cpp_token_val_index): Adjust fall through comment.
* macro.c (parse_params): Add FALLTHRU.
* pch.c (count_defs): Adjust fall through comment.
(write_defs): Likewise.
libiberty/
* cp-demangle.c (d_print_mod): Add FALLTHRU.

upstream hash: e3533433b8efa642ea08f2704b1dd7b7f741fbc3
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239410 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: I4ebe40df8514b8ec4a6d5c701b2b672107fcc40c

6 years ago * tree.h (TYPE_ALIGN, DECL_ALIGN): Return shifted amount. 77/189277/2
matz [Mon, 18 Apr 2016 20:36:27 +0000 (20:36 +0000)]
* tree.h (TYPE_ALIGN, DECL_ALIGN): Return shifted amount.
(SET_TYPE_ALIGN, SET_DECL_ALIGN): New.
* tree-core.h (tree_type_common.align): Use bit-field.
(tree_type_common.spare): New.
(tree_decl_common.off_align): Make smaller.
(tree_decl_common.align): Use bit-field.

* expr.c (expand_expr_addr_expr_1): Use SET_TYPE_ALIGN.
* omp-low.c (install_var_field): Use SET_DECL_ALIGN.
(scan_sharing_clauses): Ditto.
(finish_taskreg_scan): Use SET_DECL_ALIGN and SET_TYPE_ALIGN.
(omp_finish_file): Ditto.
* stor-layout.c (do_type_align): Use SET_DECL_ALIGN.
(layout_decl): Ditto.
(relayout_decl): Ditto.
(finalize_record_size): Use SET_TYPE_ALIGN.
(finalize_type_size): Ditto.
(finish_builtin_struct): Ditto.
(layout_type): Ditto.
(initialize_sizetypes): Ditto.
* targhooks.c (std_gimplify_va_arg_expr): Use SET_TYPE_ALIGN.
* tree-nested.c (insert_field_into_struct): Use SET_TYPE_ALIGN.
(lookup_field_for_decl): Use SET_DECL_ALIGN.
(get_chain_field): Ditto.
(get_trampoline_type): Ditto.
(get_nl_goto_field): Ditto.
* tree-streamer-in.c (unpack_ts_decl_common_value_fields): Use
SET_DECL_ALIGN.
(unpack_ts_type_common_value_fields): Use SET_TYPE_ALIGN.
* gimple-expr.c (copy_var_decl): Use SET_DECL_ALIGN.
* tree.c (make_node_stat): Use SET_DECL_ALIGN and SET_TYPE_ALIGN.
(build_qualified_type): Use SET_TYPE_ALIGN.
(build_aligned_type, build_range_type_1): Ditto.
(build_atomic_base): Ditto.
(build_common_tree_nodes): Ditto.
* cfgexpand.c (align_local_variable): Use SET_DECL_ALIGN.
(expand_one_stack_var_at): Ditto.
* coverage.c (build_var): Use SET_DECL_ALIGN.
* except.c (init_eh): Ditto.
* function.c (assign_parm_setup_block): Ditto.
* symtab.c (increase_alignment_1): Ditto.
* tree-ssa-ccp.c (fold_builtin_alloca_with_align): Ditto.
* tree-vect-stmts.c (ensure_base_align): Ditto.
* varasm.c (align_variable): Ditto.
(assemble_variable): Ditto.
(build_constant_desc): Ditto.
(output_constant_def_contents): Ditto.

* config/arm/arm.c (arm_relayout_function): Use SET_DECL_ALIGN.
* config/avr/avr.c (avr_adjust_type_node): Use SET_TYPE_ALIGN.
* config/mips/mips.c (mips_std_gimplify_va_arg_expr): Ditto.
* config/msp430/msp430.c (msp430_gimplify_va_arg_expr): Ditto.
* config/spu/spu.c (spu_build_builtin_va_list): Use SET_DECL_ALIGN.

ada/
* gcc-interface/decl.c (gnat_to_gnu_entity): Use SET_TYPE_ALIGN.
(gnat_to_gnu_field): Ditto.
(components_to_record): Ditto.
(create_variant_part_from): Ditto.
(copy_and_substitute_in_size): Ditto.
(substitute_in_type): Ditto.
* gcc-interface/utils.c (make_aligning_type): Use SET_TYPE_ALIGN.
(make_packable_type): Ditto.
(maybe_pad_type): Ditto.
(finish_fat_pointer_type): Ditto.
(finish_record_type): Ditto and use SET_DECL_ALIGN.
(rest_of_record_type_compilation): Use SET_TYPE_ALIGN.
(create_field_decl): Use SET_DECL_ALIGN.

c-family/
* c-common.c (handle_aligned_attribute): Use SET_TYPE_ALIGN
and SET_DECL_ALIGN.

c/
* c-decl.c (merge_decls): Use SET_DECL_ALIGN and SET_TYPE_ALIGN.
(grokdeclarator, parser_xref_tag, finish_enum): Use SET_TYPE_ALIGN.

cp/
* class.c (build_vtable): Use SET_DECL_ALIGN and SET_TYPE_ALIGN.
(layout_class_type): Ditto.
(build_base_field): Use SET_DECL_ALIGN.
(fixup_attribute_variants): Use SET_TYPE_ALIGN.
* decl.c (duplicate_decls): Use SET_DECL_ALIGN.
(record_unknown_type): Use SET_TYPE_ALIGN.
(cxx_init_decl_processing): Ditto.
(copy_type_enum): Ditto.
(grokfndecl): Use SET_DECL_ALIGN.
(copy_type_enum): Use SET_TYPE_ALIGN.
* pt.c (instantiate_class_template_1): Use SET_TYPE_ALIGN.
(tsubst): Ditto.
* tree.c (cp_build_qualified_type_real): Use SET_TYPE_ALIGN.
* lambda.c (maybe_add_lambda_conv_op): Use SET_DECL_ALIGN.
* method.c (implicitly_declare_fn): Use SET_DECL_ALIGN.
* rtti.c (emit_tinfo_decl): Ditto.

fortran/
* trans-io.c (gfc_build_io_library_fndecls): Use SET_TYPE_ALIGN.
* trans-common.c (build_common_decl): Use SET_DECL_ALIGN.
* trans-types.c (gfc_add_field_to_struct): Use SET_DECL_ALIGN.

go/
* go-gcc.cc (Gcc_backend::implicit_variable): Use SET_DECL_ALIGN.

java/
* class.c (add_method_1): Use SET_DECL_ALIGN.
(make_class_data): Ditto.
(emit_register_classes_in_jcr_section): Ditto.
* typeck.c (build_java_array_type): Ditto.

objc/
* objc-act.c (objc_build_struct): Use SET_DECL_ALIGN.

libcc1/
* plugin.cc (plugin_finish_record_or_union): Use SET_TYPE_ALIGN.

upstream hash: 5d4b30ea56c1733a9149b59105b9645c115cc123
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235172 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: Ia135e37556ac5bc0e2db4cc2a940d8d31e243ade

6 years agoC/C++: Simplify handling of location information for OpenACC routine directives 76/189276/2
tschwinge [Thu, 4 Aug 2016 13:35:19 +0000 (13:35 +0000)]
C/C++: Simplify handling of location information for OpenACC routine directives

gcc/c/
* c-parser.c (struct oacc_routine_data): New.
(c_parser_declaration_or_fndef, c_parser_oacc_routine): Use it.
Simplify code.
(c_finish_oacc_routine): Likewise.  Don't attach clauses to "omp
declare target" attribute.
gcc/cp/
* parser.h (struct cp_omp_declare_simd_data): New.
(struct cp_parser): Use it for oacc_routine member.
* parser.c (cp_ensure_no_oacc_routine, cp_parser_oacc_routine)
(cp_parser_late_parsing_oacc_routine, cp_finalize_oacc_routine):
Use it.  Simplify code.
(cp_parser_new): Initialize all members pointing to special
parsing data structures.
(cp_parser_cilk_simd_fn_vector_attrs): Initialize
parser->cilk_simd_fn_info->clauses.
(cp_parser_omp_declare_simd): Initialize
parser->omp_declare_simd->clauses.
(cp_parser_late_parsing_omp_declare_simd): Simplify code.

upstream hash: 5f429ee2993ea1795d88c5589251c500e6e9062a
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239127 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: I6e8b2ad2102b50798fd0fb7b373e6c4ccb17acd7

6 years ago PR middle-end/71476 75/189275/2
mpolacek [Mon, 13 Jun 2016 08:57:02 +0000 (08:57 +0000)]
PR middle-end/71476
* gimplify.c (maybe_warn_switch_unreachable): Factored out of
gimplify_switch_expr.
(warn_switch_unreachable_r): New function.

* c-c++-common/Wswitch-unreachable-4.c: New test.
* gcc.dg/Wswitch-unreachable-2.c: New test.
* g++.dg/tm/jump1.C: Move dg-warning.

upstream hash: 1a54d3bee5c40687c53b2680d0b110f23a193713
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237367 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: Ie8bc6fb965fdb08c7e76ee02fe01eec4707336b0

6 years ago * gimplify.c (gimplify_switch_expr): Also handle GIMPLE_TRY. 74/189274/2
mpolacek [Tue, 31 May 2016 14:55:05 +0000 (14:55 +0000)]
* gimplify.c (gimplify_switch_expr): Also handle GIMPLE_TRY.

* c-c++-common/Wswitch-unreachable-3.c: New test.
* g++.dg/warn/Wswitch-unreachable-1.C: New test.

upstream hash: 4ff7bd215d121cbec262600e2b4bcbff93b8affb
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@236924 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: Ic1e69ef6931e9f4051060cc37bd33c9a86ad2df3

6 years ago PR c/71249 73/189273/2
mpolacek [Tue, 24 May 2016 16:22:31 +0000 (16:22 +0000)]
PR c/71249
* gimplify.c (gimplify_switch_expr): Look into the innermost lexical
scope.

* c-c++-common/Wswitch-unreachable-2.c: New test.

upstream hash: 6ef0143d8a1ce423db0ae0da55760b4fb82f3bdf
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@236649 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: I1270c2aea4e4561f72a9801607bcdfc5edab9a03

6 years ago PR c/49859 72/189272/2
mpolacek [Mon, 23 May 2016 15:37:09 +0000 (15:37 +0000)]
PR c/49859
* common.opt (Wswitch-unreachable): New option.
* doc/invoke.texi: Document -Wswitch-unreachable.
* gimplify.c (gimplify_switch_expr): Implement the -Wswitch-unreachable warning.

* c-c++-common/Wswitch-unreachable-1.c: New test.
* gcc.dg/Wswitch-unreachable-1.c: New test.
* c-c++-common/goacc/sb-2.c (void foo): Add dg-warning.
* g++.dg/cpp0x/lambda/lambda-switch.C (main): Likewise.
* g++.dg/gomp/block-10.C: Likewise.
* gcc.dg/gomp/block-10.c: Likewise.
* g++.dg/gomp/block-9.C: Likewise.
* gcc.dg/gomp/block-9.c: Likewise.
* g++.dg/gomp/target-1.C: Likewise.
* g++.dg/gomp/target-2.C: Likewise.
* gcc.dg/gomp/target-1.c: Likewise.
* gcc.dg/gomp/target-2.c: Likewise.
* g++.dg/gomp/taskgroup-1.C: Likewise.
* gcc.dg/gomp/taskgroup-1.c: Likewise.
* gcc.dg/gomp/teams-1.c: Likewise.
* g++.dg/gomp/teams-1.C: Likewise.
* g++.dg/overload/error3.C: Likewise.
* g++.dg/tm/jump1.C: Likewise.
* g++.dg/torture/pr40335.C: Likewise.
* gcc.dg/c99-vla-jump-5.c: Likewise.
* gcc.dg/switch-warn-1.c: Likewise.
* gcc.dg/Wjump-misses-init-1.c: Use -Wno-switch-unreachable.
* gcc.dg/nested-func-1.c: Likewise.
* gcc.dg/pr67784-4.c: Likewise.

upstream hash: 1398da0f786e120bb0b407e84f412aa9fc6d80ee
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@236597 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: I8f3be300f4bbb9695c6a4257cf47851241c19fe7

6 years ago PR c/67784 71/189271/2
mpolacek [Tue, 26 Apr 2016 14:59:40 +0000 (14:59 +0000)]
PR c/67784
* c-parser.c (c_parser_maybe_reclassify_token): New function factored out of ...
(c_parser_for_statement): ... here.
(c_parser_if_statement): Use it.
(c_parser_switch_statement): Use it.
(c_parser_while_statement): Use it.

* gcc.dg/pr67784-3.c: New test.
* gcc.dg/pr67784-4.c: New test.
* gcc.dg/pr67784-5.c: New test.

upstream hash: fa20ebd39e4a6947f82bdc0f6ab7f68acd65bca8
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235446 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: I3f6bb239a239135d2e498842b6de8390fc9eeaa5

6 years ago[THUMB2] Frame pointer for arm with THUMB2 mode. 52/188052/2 accepted/tizen/base/20181102.125713 submit/tizen_base/20181018.065945 submit/tizen_base/20181101.054916
Denis Khalikov [Thu, 30 Aug 2018 15:57:41 +0000 (18:57 +0300)]
[THUMB2] Frame pointer for arm with THUMB2 mode.

Set frame pointer to the predictable location in the stack frame
for arm with THUMB2 mode.

Denis Khalikov  <d.khalikov@partner.samsung.com>

  * config/arm/arm.c (arm_emit_multi_reg_pop_no_return): New function.
  (arm_compute_initial_elimination_offset): Add support for
  TARGET_THUMB_STACK_UNWIND.
  (arm_expand_prologue): Emit function prologue related to
  TARGET_THUMB_STACK_UNWIND.
  (thumb2_expand_return): Emit function epilogue related to
  TARGET_THUMB_STACK_UNWIND.
  (arm_expand_epilogue): Emit function epilogue related to
  TARGET_THUMB_STACK_UNWIND.
  * config/arm/arm.h (TARGET_THUMB_STACK_UNWIND): New define.
  (INITIAL_ELIMINATION_OFFSET): Add support for
  TARGET_THUMB_STACK_UNWIND.
  * config/arm/arm.opt: Add compile-time option THUMB_FP.
  * gcc/testsuite/c-c++-common/asan/fast-unwind-thumb.c: New tests.

Change-Id: I45a68a1216f3115c5199e5cea14c344fabe11fc1

6 years ago[ASan] Add support for lsan background leak checking thread. 01/160901/4 accepted/tizen_5.0_base tizen_5.0_base accepted/tizen/5.0/base/20181101.090602 accepted/tizen/base/20180924.142600 submit/tizen_5.0_base/20181101.000001 submit/tizen_base/20180921.104459
Michail Kashkarov [Wed, 15 Nov 2017 17:50:30 +0000 (20:50 +0300)]
[ASan] Add support for lsan background leak checking thread.

Change-Id: I61dbebdecd0f608736e8a1649595868cc119a8e4

6 years ago[LSan] Add new experimental option for checking long-running processes. 80/159380/9
Michail Kashkarov [Thu, 19 Oct 2017 19:02:41 +0000 (22:02 +0300)]
[LSan] Add new experimental option for checking long-running processes.

New LSan option: leak_check_interval_s:
Spawns a background thread at startup which periodically do recoverable
leak check with given interval.

Report files (if log_path option != stderr|stdout) are appended with
prefix "in-progress" and for the DoLeakCheck() call at exit -
are restores back.

System daemons can be leak sanitized right after system startup by adding
"Environment=LSAN_OPTIONS=...:leak_check_interval_s=60"
field in the systemd service file for leak checking every 60 seconds.

Change-Id: Ia78044ec45092f0de96818bd0114d4c7a49cb7e1

6 years ago[Test] Switch off cilkplus testing 98/185298/2 accepted/tizen/base/20180908.052105 submit/tizen_base/20180906.130734
Slava Barinov [Fri, 27 Jul 2018 09:13:41 +0000 (12:13 +0300)]
[Test] Switch off cilkplus testing

Intel-only proprietary cilkplus is not needed in Tizen and is not support, we
don't need to run the tests.

      gcc/testsuite/g++.dg/dg.exp: remove cilk-plus.exp running

Change-Id: Iccb0153f76ec0eceb7afade0dbf5e43d3c9dd6b3
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
6 years agopackaging: Add macroses to test linaro-gcc on target device 14/188014/3
Mikhail Kashkarov [Thu, 30 Aug 2018 09:20:25 +0000 (12:20 +0300)]
packaging: Add macroses to test linaro-gcc on target device

- run_tests_on_device:
  1. Turn on linaro-gcc tests.
  2. Do not remove 'obj/' directory.
  3. Skip configure/make commands in the %build stage.

- exit_on_make_finish:
  Exit right after "make BOOT_CFLAGS=..." step.

Change-Id: I77a85befa7756922963b63488aaf8cdc431fec0f

6 years ago[Sanitizers] GCC fails to build libasan with -mthumb and -fno-omit-frame-pointer 88/187288/1
Denis Khalikov [Tue, 21 Aug 2018 13:17:34 +0000 (16:17 +0300)]
[Sanitizers] GCC fails to build libasan with -mthumb and -fno-omit-frame-pointer

GCC does not allow to have frame pointer register as a clobber register
for inline assembler, when flag -fno-omit-frame-pointer is added.
By default, arm with mthumb mode uses r7 as a frame pointer register.

https://reviews.llvm.org/D50180

Change-Id: I5f5a3c695353ba2fe4195fd6054aedb7ee11e1af

6 years agoRepair collecting files for testresults rpm package. 99/184099/2 accepted/tizen/base/20180720.112000 submit/tizen_base/20180719.091532
Mikhail Kashkarov [Fri, 13 Jul 2018 14:05:21 +0000 (17:05 +0300)]
Repair collecting files for testresults rpm package.

Different .log files with the same name from gmp/mpfr are overwriting on copy,
put the in the separate directories.

Change-Id: I77761f1ff589252b4e8816dc12e9025d360fc5a0

6 years agopackaging: Add -Wformat options to disable warnings and tests FAIL. 98/179398/2
Mikhail Kashkarov [Thu, 17 May 2018 13:32:19 +0000 (16:32 +0300)]
packaging: Add -Wformat options to disable warnings and tests FAIL.

"-Wformat-..." options generate warnings like:

  cc1: warning: -Wformat-security ignored without -Wformat [-Wformat-security]

that makes a lot of unexpected failures in testsuite while checking produced
output (FAIL: .. test for excess errors) and also results comparison is messed
up for the new tests.
Insert -Wformat if it's missing.

Change-Id: Ia61f256b1f8c3fe5b3ee3c02d363eb901c68adbe

6 years ago[ASan] Add FORTIFY_SOURCE interceptors 80/162380/5
Denis Khalikov [Wed, 29 Nov 2017 11:21:07 +0000 (14:21 +0300)]
[ASan] Add FORTIFY_SOURCE interceptors

List of interceptors:
__strcat_chk,
__strncat_chk,
__strcpy_chk,
__strncpy_chk.
__poll_chk,
__ppoll_chk,
__read_chk,
__recv_chk,
__recvfrom_chk,
__pread_chk,
__pread64_chk.
__getgroups_chk,
__getcwd_chk,
__realpath_chk,
__confstr_chk.
__mbstowcs_chk,
__mbsrtowcs_chk,
__mbsnrtowcs_chk,
__wcstombs_chk,
__wcsrtombs_chk,
__wcsnrtombs_chk,
__wcrtomb_chk,
__ttyname_r_chk.

Change-Id: I16ef4d2d80089b96e5c51ea5160b706b35f9ce18

6 years ago[asan] Use linker initialization for the allocator 47/182747/2
Kuba Mracek [Fri, 22 Jun 2018 12:56:46 +0000 (15:56 +0300)]
[asan] Use linker initialization for the allocator

This saves ~2 MB of dirty memory footprint. Can be a big deal on mobile devices especially when running multiple processes with ASan.

Differential Revision: https://reviews.llvm.org/D40627

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320660 91177308-0d34-0410-b5e6-96231b3b80d8

Change-Id: I409b9dc7f73e13248987dd38d96a074ffc2ff044

6 years ago[Sanitizers] Move cached allocator_may_return_null flag to sanitizer_allocator 46/182746/2
Alex Shlyapnikov [Fri, 22 Jun 2018 12:33:11 +0000 (15:33 +0300)]
[Sanitizers] Move cached allocator_may_return_null flag to sanitizer_allocator

Summary:
Move cached allocator_may_return_null flag to sanitizer_allocator.cc and
provide API to consolidate and unify the behavior of all specific allocators.

Make all sanitizers using CombinedAllocator to follow
AllocatorReturnNullOrDieOnOOM() rules to behave the same way when OOM
happens.

When OOM happens, turn allocator_out_of_memory flag on regardless of
allocator_may_return_null flag value (it used to not to be set when
allocator_may_return_null == true).

release_to_os_interval_ms and rss_limit_exceeded will likely be moved to
sanitizer_allocator.cc too (later).

Reviewers: eugenis

Subscribers: srhines, kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D34310

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@305858 91177308-0d34-0410-b5e6-96231b3b80d8

Change-Id: I29ae28a1f9c569d69666936111e307c3aecf9314

6 years ago[Sanitizer] Remove CombinedAllocator::Allocate's 'cleared' parameter 45/182745/2
Alex Shlyapnikov [Fri, 22 Jun 2018 12:30:32 +0000 (15:30 +0300)]
[Sanitizer] Remove CombinedAllocator::Allocate's 'cleared' parameter

Summary:
CombinedAllocator::Allocate cleared parameter is not used anywhere and
seem to be obsolete.

Reviewers: eugenis

Subscribers: llvm-commits, kubamracek

Differential Revision: https://reviews.llvm.org/D34289

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@305590 91177308-0d34-0410-b5e6-96231b3b80d8

Change-Id: I57958f6ea291bb31027070f93ad652598c69d1fe

6 years ago[ASan] Move rss_limit_is_exceeded_ flag to ASan. 44/182744/2
Alex Shlyapnikov [Fri, 22 Jun 2018 12:27:29 +0000 (15:27 +0300)]
[ASan] Move rss_limit_is_exceeded_ flag to ASan.

Summary:
Move the OOM decision based on RSS limits out of generic allocator to
ASan allocator, where it makes more sense at the moment.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D34180

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@305342 91177308-0d34-0410-b5e6-96231b3b80d8

Change-Id: I2c7ccdfbfd420b74cbc5c96a50933bace9b88ccf

6 years agoCorrected D27428: Do not use the alignment-rounded-up size with secondary 43/182743/2
Kostya Kortchinsky [Fri, 22 Jun 2018 12:26:11 +0000 (15:26 +0300)]
Corrected D27428: Do not use the alignment-rounded-up size with secondary

Summary:
I atually had an integer overflow on 32-bit with D27428 that didn't reproduce
locally, as the test servers would manage allocate addresses in the 0xffffxxxx
range, which led to some issues when rounding addresses.

At this point, I feel that Scudo could benefit from having its own combined
allocator, as we don't get any benefit from the current one, but have to work
around some hurdles (alignment checks, rounding up that is no longer needed,
extraneous code).

Reviewers: kcc, alekseyshl

Subscribers: llvm-commits, kubabrecka

Differential Revision: https://reviews.llvm.org/D27681

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@289572 91177308-0d34-0410-b5e6-96231b3b80d8

Change-Id: If9f3b384566cffa0bdd1740ef2266a6a9d5f6fa4

6 years agoReturn memory to OS right after free (not in the async thread). 42/182742/2
Evgeniy Stepanov [Fri, 22 Jun 2018 12:21:18 +0000 (15:21 +0300)]
Return memory to OS right after free (not in the async thread).

Summary:
In order to avoid starting a separate thread to return unused memory to
the system (the thread interferes with process startup on Android,
Zygota waits for all threads to exit before fork, but this thread never
exits), try to return it right after free.

Reviewers: eugenis

Subscribers: cryptoad, filcab, danalbert, kubabrecka, llvm-commits

Patch by Aleksey Shlyapnikov.

Differential Revision: https://reviews.llvm.org/D27003

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@288091 91177308-0d34-0410-b5e6-96231b3b80d8

Change-Id: I2e01818bbdf3a0b9f0855b28d963b8016000abc8

6 years agoPR other/86198 10/182010/2
Denis Khalikov [Tue, 19 Jun 2018 10:12:36 +0000 (13:12 +0300)]
PR other/86198

* elf.c (elf_add): Increase ".note.gnu.build-id" section size
checking up to 36 bytes.

Change-Id: I5a6046a551395ad61c8013a347c875ad22b33599

6 years agoPR sanitizer/86090 32/181532/3
Denis Khalikov [Thu, 14 Jun 2018 12:59:00 +0000 (15:59 +0300)]
PR sanitizer/86090

  libsanitizer/
  * configure.ac: Check for lstat and readlink.
  * configure, config.h.in: Rebuild.

Change-Id: I3c81a03c34828604f3be9db3906c4ecffafc360c

6 years agoPR other/67165 54/181154/2
Denis Khalikov [Thu, 7 Jun 2018 12:36:22 +0000 (15:36 +0300)]
PR other/67165

* elf.c (__builtin_prefetch): Define if not __GNUC__.
(unlikely): Define.
(SHF_UNCOMPRESSED, ELFCOMPRESS_ZLIB): Define.
(b_elf_chdr): Define type.
(enum debug_section): Add ZDEBUG_xxx values.
(debug_section_names): Add names for new sections.
(struct debug_section_info): Add compressed field.
(elf_zlib_failed, elf_zlib_fetch): New static functions.
(HUFFMAN_TABLE_SIZE, HUFFMAN_VALUE_MASK): Define.
(HUFFMAN_BITS_SHIFT, HUFFMAN_BITS_MASK): Define.
(HUFFMAN_SECONDARY_SHIFT): Define.
(ZDEBUG_TABLE_SIZE): Define.
(ZDEBUG_TABLE_CODELEN_OFFSET, ZDEBUG_TABLE_WORK_OFFSET): Define.
(final_next_secondary): New static variable if
BACKTRACE_GENERATE_FIXED_HUFFMAN_TABLE.
(elf_zlib_inflate_table): New static function.
(BACKTRACE_GENERATE_FIXED_HUFFMAN_TABLE): If define, define main
function to produce fixed Huffman table.
(elf_zlib_default_table): New static variable.
(elf_zlib_inflate): New static function.
(elf_zlib_verify_checksum): Likewise.
(elf_zlib_inflate_and_verify): Likewise.
(elf_uncompress_zdebug): Likewise.
(elf_uncompress_chdr): Likewise.
(backtrace_uncompress_zdebug): New extern function.
(elf_add): Look for .zdebug sections and SHF_COMPRESSED debug
sections, and uncompress them.
* internal.h (backtrace_compress_zdebug): Declare.
* ztest.c: New file.
* configure.ac: Check for -lz and check whether the linker
supports --compress-debug-sections.
* Makefile.am (ztest_SOURCES): New variable.
(ztest_CFLAGS, ztest_LDADD): New variables.
(check_PROGRAMS): Add ztest.
(ctestg_SOURCES): New variable.
(ctestg_CFLAGS, ctestg_LDFLAGS, ctestg_LDADD): New variables.
(ctesta_SOURCES): New variable.
(ctesta_CFLAGS, ctesta_LDFLAGS, ctesta_LDADD): New variables.
(check_PROGRAMS): Add ctestg and ctesta.
* configure, config.h.in, Makefile.in: Rebuild.
* xcoff.c: Initial support for DWARF debug sections in XCOFF.
(STYP_DWARF, SSUBTYP_DW*): Define.
(enum dwarf_section): Define.
(struct dwsect_info): Define.
(xcoff_add): Look for DWARF sections, pass them to
backtrace_dwarf_add.
* configure.ac: Check for clock_gettime.
* config.h.in: Regenerate.
* configure: Likewise.
* ztest.c (average_time, test_large): Conditionalize test timing
on clock_gettime availability.
* Makefile.am: Append the content of clock_gettime_link to
ztest_LDADD.
* configure.ac: Test for the case that clock_gettime is in librt.
* Makefile.in: Regenerate.
* configure: Likewise.
* ztest.c: #include <errno.h>.
(TEST_TIMING): Don't define, don't test.
(xclock_gettime, xclockid_t): Define if !HAVE_CLOCK_GETTIME.
(clockid_t, clock_gettime, CLOCK_REALTIME): Likewise.
(ZLIB_CLOCK_GETTIME_ARG): Define.
* configure.ac: Change clock_gettime_link to CLOCK_GETTIME_LINK.
* Makefile.am: Likewise.
* configure, Makefile.in: Rebuild.
* elf.c (elf_zlib_fetch): Change pval argument to uint64_t *.
Read a four byte integer.
(elf_zlib_inflate): Change val to uint64_t.  Align pin to a 32-bit
boundary before ever calling elf_zlib_fetch.
* ztest.c (test_large): Simplify print statements a bit.
* ztest.c (test_large): Pass unsigned long *, not size_t *, to
zlib uncompress function.
* configure.ac: Add CET_FLAGS to EXTRA_FLAGS.
* aclocal.m4: Regenerate.
* Makefile.in: Likewise.
* configure: Likewise.
* elf.c (codes) [GENERATE_FIXED_HUFFMAN_TABLE]: Fix size to be
288.
(main) [GENERATE_FIXED_HUFFMAN_TABLE]: Pass 288 to
elf_zlib_inflate_table.  Generate elf_zlib_default_dist_table.
(elf_zlib_default_table): Update.
(elf_zlib_default_dist_table): New static array.
(elf_zlib_inflate): Use elf_zlib_default_dist_table for dist table
for block type 1.
* ztest.c (struct zlib_test): Add uncompressed_len.
(tests): Initialize uncompressed_len field.  Add new test case.
(test_samples): Use uncompressed_len field.

Change-Id: I1dd4780768695f66177983c50942001365ff75ed

6 years agoPR sanitizer/77631 53/181153/2
Denis Khalikov [Thu, 7 Jun 2018 11:24:16 +0000 (14:24 +0300)]
PR sanitizer/77631

Support for external debug info.
* elf.c: Include <errno.h>, <sys/stat.h>, <unistd.h>.
(S_ISLNK): Define if not defined.
(xstrnlen): Define if strnlen is not available.
(b_elf_note): Define type.
(NT_GNU_BUILD_ID): Define macro.
(elf_crc32, elf_crc32_file): New static functions.
(elf_is_symlink, elf_readlink): New static functions.
(elf_open_debugfile_by_buildid): New static function.
(elf_try_debugfile): New static function.
(elf_find_debugfile_by_debuglink): New static function.
(elf_open_debugfile_by_debuglink): New static function.
(elf_add): Add filename and debuginfo parameters.  Adjust all
callers.  Look for external debug info notes, and try to fetch
debug info from external file.
(struct phdr_data): Add exe_filename field.
(phdr_callback): Pass filename to elf_add.
(backtrace_initialize): Add filename parameter.
* internal.h (backtrace_initialize): Add filename parameter.
* fileline.c (fileline_initialize): Pass filename to
backtrace_initialize.
* pecoff.c (fileline_initialize): Add unused filename parameter.
* unknown.c (fileline_initialize): Likewise.
* xcoff.c (fileline_initialize): Likewise.
* configure.ac: Check for objcopy --add-gnu-debuglink.
* Makefile.am (dtest): New test target.
* configure, Makefile.in: Rebuild.
* elf.c (backtrace_initialize): Set pd.exe_filename.
* configure.ac: Check for lstat and readlink.
* elf.c (lstat, readlink): Provide dummy versions if real versions
are not available.
* configure, config.h.in: Rebuild.

Change-Id: Ia723266f2d1a9d075202c0b6904e62fa18b75123

6 years agolibbacktrace: backport from mainline. 52/181152/2
Denis Khalikov [Thu, 7 Jun 2018 10:20:04 +0000 (13:20 +0300)]
libbacktrace: backport from mainline.

* btest.c (test5): Replace #ifdef guard with 'unused' attribute
to fix compile warning when BACKTRACE_SUPPORTED isn't defined.
* dwarf.c (free_line_header): Don't free dirs if dirs_count == 0.
(read_line_header): Don't allocate dirs if dirs_count == 0.
* edtest.c: New file.
* edtest2.c: New file.
* Makefile.am (edtest_SOURCES, edtest_LDADD): Define.
(check_PROGRAMS): Add edtest.
(edtest2_build.c, gen_edtest2_build): New targets.
* Makefile.in: Rebuild.
* elf.c (backtrace_initialize): Always set *fileline_fn.
* ttest.c: New file.
* btest.c: Move support functions into testlib.c.  Change calls to
check to pass file name.
* testlib.c: New file, copied from (part of) btest.c.
* testlib.h: New file, declarations for testlib.c.
* edtest.c: Use testlib.h and testlib.c.
* configure.ac: Test for -pthread, set HAVE_PTHREAD conditional.
* Makefile.am (btest_SOURCES): Add testlib.c.
(edtest_SOURCES): Likewise.
(CHECK_PROGRAMS): Add ttest if HAVE_PTHREAD.
(ttest_SOURCES, ttest_CFLAGS, ttest_LDADD): Define.
* configure, Makefile.in: Rebuild.
* configure.ac: Add AC_SYS_LARGEFILE.
* config.h.in: Regenerate.
* configure: Likewise.
* filetype.awk: Add AIX XCOFF type detection.
* configure.ac: Recognize xcoff format.
* Makefile.am (FORMAT_FILES): Add xcoff.c.
* fileline.c: Include <unistd.h>.
(fileline_initialize): Add case for AIX procfs.
* xcoff.c: New file.
* configure, Makefile.in: Rebuild.
* configure.ac: Check for XCOFF32/XCOFF64.  Check for loadquery.
* filetype.awk: Separate AIX XCOFF32 and XCOFF64.
* xcoff.c: Add support for AIX XCOFF32 and XCOFF64 formats.
* configure, config.h.in: Regenerate.
* fileline.c (fileline_initialize): Print pid_t as long.
* xcoff.c: Don't leak a file descriptor if an archive is malformed.
* xcoff.c (xcoff_process_linenos): Initialize incl to NULL.
* libbacktrace/Makefile.in
(HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_CFLAGS): Add $(AM_CFLAGS)
* Makefile.am (ttest_CFLAGS): Add $(AM_CFLAGS)
* Makefile.in: Regenerate.

Change-Id: Ib61ad222b79b9c3a38d35705608f74041acc767a

6 years agoRevert Tizen version of PR sanitizer/77631. 51/181151/3
Denis Khalikov [Wed, 6 Jun 2018 16:40:01 +0000 (19:40 +0300)]
Revert Tizen version of PR sanitizer/77631.

Revert commit related to PR sanitizer/77631 implementation
for the Tizen GCC. The feature should has an upstream
implementation.

Change-Id: I1ddf629e229d667877a69d80dd0d6295400b533a

6 years ago[ESan] EfficiencySanitizer implementation. 59/174159/9
Denis Khalikov [Wed, 24 Jan 2018 10:55:22 +0000 (13:55 +0300)]
[ESan] EfficiencySanitizer implementation.

EfficiencySanitizer (WorkingSet tool and CacheFragmentation tool)
implementation for X86_64 and armv7l.

The ESan is a set of compiler-based tools for analyzing targeted
performance problems.

This patch includes:

1. GCC pass.

1.1. GCC pass for WorkingSet tool.
Special compiler pass instruments every memory access in the program.
Memory accesses are simply prepended with a function call like
__esan_aligned_load(addr), __esan_aligned_store(addr).

1.2. GCC pass for CacheFragmentation tool.
Special compiler pass instruments every memory access to the struct
field. Creates fields counter array, each cell of that array
counts memory access to the special field. Creates array of
struct, where every instance of the struct represetnts meta info
of the real struct and so on.

A call to __esan_init is inserted to the static constructor.
A call to __esan_exit is inserted to the static destructor.

2. Runtime library.

2.1. WorkingSet tool.
The runtime library simply manages shadow memory and computes statistic
of the program efficiency. The tool maps one cashe line (64 bytes) of
the program to the one byte of the shadow memory. Runtime library measures
the data working set size of an application at each snapshot during
execution. It can help understand phased behavior as well as providing basic
direction for futher effort by the developer: e.g., knowing whether the working
set is close to fitting in current L3 cashes or is many times larger can help
to determine where to spend effort.

2.2. CacheFragmentation tool.
The runtime part prints statistics about an amount of field accesses and
detailed information about which field was actually accessed.

3. Testsuite.
Simple testsuite.

4. HOW TO USE:

4.1. WorkingSet tool.
To measure the working set size, you should build your binary or shared library
with compile time flag -fsanitize=efficiency-working-set and
set runtime options ESAN_OPTIONS=process_range_access=1:record_snapshots=1

4.2. CacheFragmentation tool.
To enable CacheFragmentation tool you should compile your binary or
shared library with compile time flag -fsanitize=efficiency-cache-frag
and set runtime options ESAN_OPTIONS=build_mode=0:verbosity=1

Change-Id: Ie3231d3defa183712997e6fca39b1e8b4586e9b7

6 years agopackaging: Add -marm and -fno-omit-frame-pointer 48/183448/2
Denis Khalikov [Thu, 5 Jul 2018 10:04:58 +0000 (13:04 +0300)]
packaging: Add -marm and -fno-omit-frame-pointer

To enable "fastunwinder" work on armv7l we should explicitly
build libasan with -marm and -fno-omit-frame-pointer.

Change-Id: I28e763fa7b088aa26a81e7bb6d3a7fa9ba7a714b

6 years ago[ASan] Intercept mcheck and mprobe on Linux 67/175667/3 accepted/tizen/base/20180413.181204 accepted/tizen/base/20180420.170848 submit/tizen_base/20180412.024656 submit/tizen_base/20180417.073401
Slava Barinov [Wed, 11 Apr 2018 09:57:23 +0000 (12:57 +0300)]
[ASan] Intercept mcheck and mprobe on Linux

This patch addresses https://github.com/google/sanitizers/issues/804.

Users can use mcheck and mprobe functions to verify heap state so we should
intercept them to avoid breakage of valid code.

Differential Revision: https://reviews.llvm.org/D32589
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@302001 91177308-0d34-0410-b5e6-96231b

Change-Id: I310e0e06d0ad4450acf779630acfb71cde9ea1d2
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
6 years agopackaging: Bootstrap compiler optimization 52/162552/7 submit/tizen_base/20180411.052502
Oleg Ogurtsov [Thu, 11 Jan 2018 09:53:42 +0000 (12:53 +0300)]
packaging: Bootstrap compiler optimization

Change-Id: Ie1e12ff3ae5c0550254f58da4750830e5739d3f5

6 years ago[ASan] Fix for TTC-5 (PR sanitizer/81697). 31/173031/1 accepted/tizen/base/20180406.180244 accepted/tizen/base/20180416.213938 submit/tizen_base/20180330.064117 submit/tizen_base/20180416.141938
Denis Khalikov [Mon, 19 Mar 2018 06:43:09 +0000 (09:43 +0300)]
[ASan] Fix for TTC-5 (PR sanitizer/81697).

gcc/

2017-11-30  Maxim Ostapenko  <m.ostapenko@samsung.com>

PR sanitizer/81697
* asan.c (asan_protect_global): Add new ignore_decl_rtl_set_p
parameter. Return true if ignore_decl_rtl_set_p is true and other
conditions are satisfied.
* asan.h (asan_protect_global): Add new parameter.
* varasm.c (categorize_decl_for_section): Pass true as second parameter
to asan_protect_global calls.

gcc/testsuite/

2017-11-30  Maxim Ostapenko  <m.ostapenko@samsung.com>

PR sanitizer/81697
* c-c++-common/asan/pr81697.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255283 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: I4568c3d228286d2a372c1e5c3a1dde62561ace74

6 years ago[ASan] Revert commit related to TTC-5 (PR sanitizer/81697). 30/173030/1
Denis Khalikov [Mon, 19 Mar 2018 06:08:53 +0000 (09:08 +0300)]
[ASan] Revert commit related to TTC-5 (PR sanitizer/81697).

We might have a strange situation with ASan and TLS,
when TLS_index struct should be defined as
.word   .LANCHOR0(tlsldm),
but patch for TTC-5 assumes that is no ANCHOR sections
with ASan at all. So, in this specific case we pass TLS_index
struct with wrong alignment to __tls_get_addr () function
which cause a SEGV.

Next commit fix sanitizer/81697 with patch from upstream.

Change-Id: I9ee35ade027d246870bf57387f40217226efb7cc

6 years ago[Sanitizers] Revert commit related to SUMMARY report 98/163498/3
Denis Khalikov [Mon, 11 Dec 2017 14:01:48 +0000 (17:01 +0300)]
[Sanitizers] Revert commit related to SUMMARY report

The commit with Change-Id: Ia258f1e3906bb095ca0d33d3354dd9b1f640c89f
adds SanitizerToolName to the report buffer, but the same name
is adding later at the line 200, so as result we will get
SanitzerToolName twice at the same buffer, therefore this
patch breaks thread_leaks1.c test, because the test expects
that report includes SanitizerToolname only once.

Change-Id: Ia98811936e4845e12cdde7a7f1286058a0766ada

6 years agoMerge "[asan_build] Enable asaned glibc work." into tizen_base accepted/tizen/base/20180126.040727 submit/tizen_base/20180124.094033
Jaehun Jeong [Wed, 24 Jan 2018 09:31:10 +0000 (09:31 +0000)]
Merge "[asan_build] Enable asaned glibc work." into tizen_base

6 years agoMerge "[ASAN] Add interceptor for __longjmp_chk" into tizen_base
Jaehun Jeong [Wed, 24 Jan 2018 09:30:17 +0000 (09:30 +0000)]
Merge "[ASAN] Add interceptor for __longjmp_chk" into tizen_base

6 years ago[ASan] Add interceptor for printf_chk 07/164507/1
Denis Khalikov [Tue, 19 Dec 2017 09:47:55 +0000 (12:47 +0300)]
[ASan] Add interceptor for printf_chk

Differential Revision: https://reviews.llvm.org/D40951

Change-Id: I7c32945659da4cf80e995370cb26fb063bb7930c

6 years ago[TTC-11] Embed UBSan into ASan runtime 63/158063/5 accepted/tizen/base/20171215.171112 submit/tizen_base/20171208.084018
Maxim Ostapenko [Fri, 27 Oct 2017 12:14:27 +0000 (15:14 +0300)]
[TTC-11] Embed UBSan into ASan runtime

Change the way we use ASan and UBSan together. Instead of keeping two
separate runtimes (libasan.so and libubsan.so), embed UBSan into ASan.
UBSan initialization code (e.g. flag parsing) is directly called
from ASan initialization, so we are able to enforce correct
initialization order.

This mirrors the approach we already use for ASan+LSan. This change
doesn't modify the way we use standalone UBSan.

gcc/
* config/gnu-user.h: append -lstdc++ if we link against ASan
runtime.
* gcc.c: Do not link against libubsan.so if
-fsanitize=address,undefined is used.

gcc/testsuite/
* c-c++-common/asan/asan_and_ubsan-1.c: New test.

libsanitizer/

* Makefile.am: Build UBSan strictly before ASan.
* Makefile.in: Regenerate.
* asan/Makefile.am: Embed UBSan into ASan runtime.
* asan/Makefile.in: Regenerate.
* configure.ac: Configure UBSan strictly before ASan.
* configure: Regenerate.
ubsan/ubsan_diag.cc (__sanitizer_print_stack_trace): Move to ...
ubsan/ubsan_diag_standalone.cc: ... here.
* ubsan/Makefile.am: Create a "plugin" library to be embedded
into ASan runtime.
* ubsan/Makefile.in: Regenerate.

Change-Id: Ia848a93929effb4b0ec057243c7343c1bd94fbfb
Signed-off-by: Maxim Ostapenko <m.ostapenko@samsung.com>
6 years agoUpdate ChangeLog.Tizen 19/163119/1 accepted/tizen/base/20171208.204010 submit/tizen_base/20171207.085008
Dongkyun Son [Thu, 7 Dec 2017 08:46:37 +0000 (17:46 +0900)]
Update ChangeLog.Tizen

Change-Id: If40d54536b967f821dc54eb15d71d81600df7395
Signed-off-by: Dongkyun Son <dongkyun.s@samsung.com>
6 years ago[TSan] Support cross building. 20/159920/5
Denis Khalikov [Fri, 17 Nov 2017 12:37:07 +0000 (15:37 +0300)]
[TSan] Support cross building.

In case we want to build binary with TSan for aarch64
CPU under qemu-user on x86_64 CPU, we should make sure
that we don't make any architecture dependent checks at
the runtime.
To support this, new flag "run_under_qemu" was added and
now available under TSAN_OPTIONS.

Change-Id: Ifad929d284d30b720afd60a60a88fa129f37d4a6

6 years ago[TSan] TSan options. 68/155968/3
Denis Khalikov [Mon, 16 Oct 2017 16:03:16 +0000 (19:03 +0300)]
[TSan] TSan options.

Enable TSan to read options from file.

Change-Id: I86286365a72ba1b1f9971018125140b9d7e518e4

6 years ago[TSan] Fix TSan initializaion. 89/152589/3
Denis Khalikov [Tue, 26 Sep 2017 09:34:21 +0000 (12:34 +0300)]
[TSan] Fix TSan initializaion.

TSan uses procfs for every ThreadContext.
We should ensure that procfs is mounted, to
avoid an error when TSan is initializing.

Change-Id: I8e9a3ec6f8920c95b5246bda56f5c55ef9fffb0e

6 years agopackaging: Add tsan_interface_atomic header. 76/155276/2
Denis Khalikov [Thu, 12 Oct 2017 14:19:17 +0000 (17:19 +0300)]
packaging: Add tsan_interface_atomic header.

Change-Id: I8f51690ede737591606612f674f6c7729113d587

6 years agoAdd a runtime flag Wprint-abs-path 34/161434/3
Oleg Ogurtsov [Thu, 23 Nov 2017 09:30:36 +0000 (12:30 +0300)]
Add a runtime flag Wprint-abs-path

A runtime flag for printing a real path to the source file on warning.

gcc/
* Makefile.in: added dependencies of linking.
* common.opt: added a flag description.
* diagnostic.c: added the dependence of the runtime flag and
implementation.

Change-Id: I3eb9178892f3c230845dc8e5c9ab4e1b1613f6f0