platform/upstream/llvm.git
4 years ago[z/OS][AIX] Move lambda definition to fix build problem
David Tenty [Thu, 16 Jul 2020 23:55:45 +0000 (19:55 -0400)]
[z/OS][AIX] Move lambda definition to fix build problem

This is a follow on change to eed19bd8 and contains a fix for a build
failure that occurs on both z/OS and AIX as a result of this commit:

https://reviews.llvm.org/rG670915094462d831e3733e5b01a76471b8cf6dd8.

4 years ago[Loop Simplify] Resolve an issue where metadata is not applied to a loop latch.
Sidharth Baveja [Fri, 17 Jul 2020 14:01:03 +0000 (14:01 +0000)]
[Loop Simplify] Resolve an issue where metadata is not applied to a loop latch.

Summary:
This patch resolves an issue where the metadata of a loop is not added to the
new loop latch, and not removed from the old loop latch. This issue occurs in
the SplitBlockPredecessors function, which  adds a new block in a loop, and
in the case that the block passed into this function is the header of the loop,
the loop can be modified such that the latch of the loop is replaced.
This patch applies to the Loop Simplify pass since it ensures that each loop
has exit blocks which only have predecessors that are inside of the loop. In
the case that this is not true, the pass will create a new exit block for the
loop. This guarantees that the loop preheader/header will dominate the exit blocks.

Author: sidbav (Sidharth Baveja)

Reviewers: asbirlea (Alina Sbirlea), chandlerc (Chandler Carruth), Whitney (Whitney Tsang), bmahjour (Bardia Mahjour)

Reviewed By:  asbirlea (Alina Sbirlea)

Subscribers: hiraditya (Aditya Kumar), llvm-commits

Tag: LLVM

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

4 years agorecommit 4fc752b30b9a [CUDA][HIP] Always defer diagnostics for wrong-sided reference
Yaxun (Sam) Liu [Wed, 15 Jul 2020 17:25:32 +0000 (13:25 -0400)]
recommit 4fc752b30b9a [CUDA][HIP] Always defer diagnostics for wrong-sided reference

Fixed regression in test builtin-amdgcn-atomic-inc-dec-failure.cpp.

4 years ago[NFC][ARM] Add SimplifyCFG test
Sam Parker [Fri, 17 Jul 2020 13:06:32 +0000 (14:06 +0100)]
[NFC][ARM] Add SimplifyCFG test

4 years ago[ms] [llvm-ml] Remove unused function
Eric Astor [Wed, 15 Jul 2020 19:00:34 +0000 (15:00 -0400)]
[ms] [llvm-ml] Remove unused function

Summary: Remove unused function

Reviewed By: lbenes

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

4 years ago[MSP430] Actualize the toolchain description
Anatoly Trosinenko [Fri, 17 Jul 2020 10:35:57 +0000 (13:35 +0300)]
[MSP430] Actualize the toolchain description

Reviewed By: krisb

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

4 years ago[analyzer] Add system header simulator a symmetric random access iterator operator+
Endre Fülöp [Mon, 6 Jul 2020 14:25:57 +0000 (16:25 +0200)]
[analyzer] Add system header simulator a symmetric random access iterator operator+

Summary:
Random access iterators must handle operator+, where the iterator is on the
RHS. The system header simulator library is extended with these operators.

Reviewers: Szelethus

Subscribers: whisperity, xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, Charusso, steakhal, martong, ASDenysPetrov, cfe-commits

Tags: #clang

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

4 years ago[LV] Enable the LoopVectorizer to create pointer inductions
Anna Welker [Fri, 17 Jul 2020 10:34:28 +0000 (11:34 +0100)]
[LV] Enable the LoopVectorizer to create pointer inductions

This patch enables the LoopVectorizer to build a phi of pointer
type and provide the vector loads and stores with vector type
getelementptrs built from the pointer induction variable, which
produces much less instructions than the previous approach of
creating scalar getelementpointers and glue them together to a
vector.

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

4 years ago[llvm-readobj] - Add proper testing for the SHT_MIPS_ABIFLAGS section.
Georgii Rymar [Thu, 16 Jul 2020 15:07:33 +0000 (18:07 +0300)]
[llvm-readobj] - Add proper testing for the SHT_MIPS_ABIFLAGS section.

This rewrites the mips-abiflags.test to stop using recompiled objects,
adds testing for all missed bits and also adds two missing enum values
to lib/ObjectYAML, which are used in the new test.

Differential revision: https://reviews.llvm.org/D83954

4 years agoAdd -o /dev/null to make it explicit that we don't care about the
Adrian Kuegel [Fri, 17 Jul 2020 12:21:13 +0000 (14:21 +0200)]
Add -o /dev/null to make it explicit that we don't care about the
compiler output.

4 years agoRevert "[CUDA][HIP] Always defer diagnostics for wrong-sided reference"
Yaxun (Sam) Liu [Fri, 17 Jul 2020 12:09:44 +0000 (08:09 -0400)]
Revert "[CUDA][HIP] Always defer diagnostics for wrong-sided reference"

This reverts commit 4fc752b30b9acac73a282cb844a6240e6cb70cca.

4 years ago[AMDGPU] Add some missing check prefixes and tweak test
Jay Foad [Fri, 17 Jul 2020 11:57:23 +0000 (12:57 +0100)]
[AMDGPU] Add some missing check prefixes and tweak test

The test needed some extra ALU instructions to prevent it from being
memory bound.

4 years ago[AMDGPU] Add some missing check prefixes
Jay Foad [Fri, 17 Jul 2020 11:56:29 +0000 (12:56 +0100)]
[AMDGPU] Add some missing check prefixes

4 years ago[x86] add tests for FMA with FMF; NFC
Sanjay Patel [Thu, 16 Jul 2020 19:01:01 +0000 (15:01 -0400)]
[x86] add tests for FMA with FMF; NFC

4 years ago[CUDA][HIP] Always defer diagnostics for wrong-sided reference
Yaxun (Sam) Liu [Wed, 15 Jul 2020 17:25:32 +0000 (13:25 -0400)]
[CUDA][HIP] Always defer diagnostics for wrong-sided reference

When a device function calls a host function or vice versa, this is wrong-sided
reference. Currently clang immediately diagnose it. This is different from nvcc
behavior, where it is diagnosed only if the function is really emitted.

Current clang behavior causes false alarms for valid use cases.

This patch let clang always defer diagnostics for wrong-sided
reference.

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

4 years agoMake helpers static. NFC.
Benjamin Kramer [Fri, 17 Jul 2020 11:49:11 +0000 (13:49 +0200)]
Make helpers static. NFC.

4 years agoAdd -flang flag to the test-release.sh script
Hans Wennborg [Fri, 17 Jul 2020 11:22:17 +0000 (13:22 +0200)]
Add -flang flag to the test-release.sh script

The flag is off by default.

4 years ago[lldb/COFF] Remove strtab zeroing hack
Pavel Labath [Wed, 15 Jul 2020 15:13:20 +0000 (17:13 +0200)]
[lldb/COFF] Remove strtab zeroing hack

Summary:
This code (recently responsible for a unaligned access sanitizer
failure) claims that the string table offset zero should result in an
empty string.

I cannot find any mention of this detail in the Microsoft COFF
documentation, and the llvm COFF parser also does not handle offset zero
specially. This code was introduced in 0076e7159, which also does not go
into specifics, citing "various bugfixes".

Given that this is obviously a hack, and does not cause tests to fail, I
think we should just delete it.

Reviewers: amccarth, markmentovai

Subscribers: lldb-commits

Tags: #lldb

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

4 years ago[HWLoops] Stop converting to a while loop when it would be unsafe to
Sam Tebbs [Thu, 16 Jul 2020 14:55:50 +0000 (15:55 +0100)]
[HWLoops] Stop converting to a while loop when it would be unsafe to

There were cases where a do-while loop would be converted to a while
loop before finding out that it would be unsafe to expand the SCEV in
this situation and then bailing out of hardware loop conversion.

This patch checks if it would be unsafe to expand the SCEV and if so stops converting the do-while into a while, allowing conversion to a hardware loop.

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

4 years ago[AMDGPU] Avoid splitting FLAT offsets in unsafe ways
Jay Foad [Wed, 8 Jul 2020 13:13:32 +0000 (14:13 +0100)]
[AMDGPU] Avoid splitting FLAT offsets in unsafe ways

As explained in the comment:

// For a FLAT instruction the hardware decides whether to access
// global/scratch/shared memory based on the high bits of vaddr,
// ignoring the offset field, so we have to ensure that when we add
// remainder to vaddr it still points into the same underlying object.
// The easiest way to do that is to make sure that we split the offset
// into two pieces that are both >= 0 or both <= 0.

In particular FLAT (as opposed to SCRATCH and GLOBAL) instructions have
an unsigned immediate offset field, so we can't use it to help split a
negative offset.

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

4 years ago[TableGen] Report an error instead of asserting
Jay Foad [Thu, 16 Apr 2020 08:29:28 +0000 (09:29 +0100)]
[TableGen] Report an error instead of asserting

This gives a nice error if you accidentally try to use an empty list for
the RegTypes of a RegisterClass.

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

4 years ago[InstCombine][Test] Test for fix of replacing select with Phis when branch has the...
Max Kazantsev [Fri, 17 Jul 2020 09:59:19 +0000 (16:59 +0700)]
[InstCombine][Test] Test for fix of replacing select with Phis when branch has the same labels

An additional test that allows to check the correctness of handling the case of the same
branch labels in the dominator when trying to replace select with phi-node.

Patch By: Kirill Polushin
Differential Revision: https://reviews.llvm.org/D84006
Reviewed By: mkazantsev

4 years ago[Sema][AArch64] Add parsing support for arm_sve_vector_bits attribute
Cullen Rhodes [Fri, 29 May 2020 09:17:37 +0000 (09:17 +0000)]
[Sema][AArch64] Add parsing support for arm_sve_vector_bits attribute

Summary:

This patch implements parsing support for the 'arm_sve_vector_bits' type
attribute, defined by the Arm C Language Extensions (ACLE, version 00bet5,
section 3.7.3) for SVE [1].

The purpose of this attribute is to define fixed-length (VLST) versions
of existing sizeless types (VLAT). For example:

    #if __ARM_FEATURE_SVE_BITS==512
    typedef svint32_t fixed_svint32_t __attribute__((arm_sve_vector_bits(512)));
    #endif

Creates a type 'fixed_svint32_t' that is a fixed-length version of
'svint32_t' that is normal-sized (rather than sizeless) and contains
exactly 512 bits. Unlike 'svint32_t', this type can be used in places
such as structs and arrays where sizeless types can't.

Implemented in this patch is the following:

  * Defined and tested attribute taking single argument.
  * Checks the argument is an integer constant expression.
  * Attribute can only be attached to a single SVE vector or predicate
    type, excluding tuple types such as svint32x4_t.
  * Added the `-msve-vector-bits=<bits>` flag. When specified the
    `__ARM_FEATURE_SVE_BITS__EXPERIMENTAL` macro is defined.
  * Added a language option to store the vector size specified by the
    `-msve-vector-bits=<bits>` flag. This is used to validate `N ==
    __ARM_FEATURE_SVE_BITS`, where N is the number of bits passed to the
    attribute and `__ARM_FEATURE_SVE_BITS` is the feature macro defined under
    the same flag.

The `__ARM_FEATURE_SVE_BITS` macro will be made non-experimental in the final
patch of the series.

[1] https://developer.arm.com/documentation/100987/latest

This is patch 1/4 of a patch series.

Reviewers: sdesmalen, rsandifo-arm, efriedma, ctetreau, cameron.mcinally, rengolin, aaron.ballman

Reviewed By: sdesmalen, aaron.ballman

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

4 years ago[MachineScheduler] Fix the TopDepth/BotHeightReduce latency heuristics
Jay Foad [Tue, 7 Jan 2020 15:43:46 +0000 (15:43 +0000)]
[MachineScheduler] Fix the TopDepth/BotHeightReduce latency heuristics

tryLatency compares two sched candidates. For the top zone it prefers
the one with lesser depth, but only if that depth is greater than the
total latency of the instructions we've already scheduled -- otherwise
its latency would be hidden and there would be no stall.

Unfortunately it only tests the depth of one of the candidates. This can
lead to situations where the TopDepthReduce heuristic does not kick in,
but a lower priority heuristic chooses the other candidate, whose depth
*is* greater than the already scheduled latency, which causes a stall.

The fix is to apply the heuristic if the depth of *either* candidate is
greater than the already scheduled latency.

All this also applies to the BotHeightReduce heuristic in the bottom
zone.

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

4 years ago[lldb/DWARF] Don't get confused by line sequences with tombstone values
Pavel Labath [Thu, 16 Jul 2020 15:28:17 +0000 (17:28 +0200)]
[lldb/DWARF] Don't get confused by line sequences with tombstone values

Summary:
With D81784, lld has started debug info resolving relocations to
garbage-collected symbols as -1 (instead of relocation addend). For an
unaware consumer this generated sequences which seemingly wrap the
address space -- their first entry was 0xfffff, but all other entries
were low numbers.

Lldb stores line sequences concatenated into one large vector, sorted by
the first entry, and searched with std::lower_bound. This resulted in
the low-value entries being placed at the end of the vector, which
utterly confused the lower_bound algorithm, and caused it to not find a
match. (Previously, these sequences would be at the start of the vector,
and normally would contain addresses that are far smaller than any real
address we want to look up, so std::lower_bound was fine.)

This patch makes lldb ignore these kinds of sequences completely. It
does that by changing the construction algorithm from iterating over the
rows (as parsed by llvm), to iterating over the sequences. This is
important because the llvm parsed performs validity checks when
constructing the sequence array, whereas the row array contains raw
data.

Reviewers: JDevlieghere, MaskRay

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

4 years ago[asan] Dedup MemToShadowSize
Vitaly Buka [Fri, 17 Jul 2020 09:38:18 +0000 (02:38 -0700)]
[asan] Dedup MemToShadowSize

Added D83247 and D84004.

4 years ago[ScheduleDAG] Move DBG_VALUEs after first term forward.
Florian Hahn [Fri, 17 Jul 2020 09:27:14 +0000 (10:27 +0100)]
[ScheduleDAG] Move DBG_VALUEs after first term forward.

MBBs are not allowed to have non-terminator instructions after the first
terminator. Currently in some cases (see the modified test),
EmitSchedule can add DBG_VALUEs after the last terminator, for example
when referring a debug value that gets folded into a TCRETURN
instruction on ARM.

This patch updates EmitSchedule to move inserted DBG_VALUEs just before
the first terminator. I am not sure if there are terminators produce
values that can in turn be used by a DBG_VALUE. In that case, moving the
DBG_VALUE might result in referencing an undefined register. But in any
case, it seems like currently there is no way to insert a proper DBG_VALUEs
for such registers anyways.

Alternatively it might make sense to just remove those extra DBG_VALUES.

I am not too familiar with the details of debug info in the backend and
would appreciate any suggestions on how to address the issue in the best
possible way.

Reviewers: vsk, aprantl, jpaquette, efriedma, paquette

Reviewed By: aprantl

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

4 years ago[msan] Fix strxfrm test
Vitaly Buka [Fri, 17 Jul 2020 08:45:14 +0000 (01:45 -0700)]
[msan] Fix strxfrm test

Revert D83719 and explicitly set locate to "C".

4 years ago[lsan] Fix SyntaxWarning: "is" with a literal
Vitaly Buka [Fri, 17 Jul 2020 08:47:45 +0000 (01:47 -0700)]
[lsan] Fix SyntaxWarning: "is" with a literal

4 years ago[gwp-asan] Fix check-all with LIT_FILTER
Vitaly Buka [Fri, 17 Jul 2020 08:46:14 +0000 (01:46 -0700)]
[gwp-asan] Fix check-all with LIT_FILTER

4 years ago[sanitizer] Fix protoent without network
Vitaly Buka [Fri, 17 Jul 2020 08:23:27 +0000 (01:23 -0700)]
[sanitizer] Fix protoent without network

4 years ago[PowerPC] Precommit test case for PR46759. NFC.
Kai Luo [Fri, 17 Jul 2020 08:36:30 +0000 (08:36 +0000)]
[PowerPC] Precommit test case for PR46759. NFC.

4 years ago[TSan] Add option for emitting compound read-write instrumentation
Marco Elver [Fri, 17 Jul 2020 06:53:56 +0000 (08:53 +0200)]
[TSan] Add option for emitting compound read-write instrumentation

This adds option -tsan-compound-read-before-write to emit different
instrumentation for the write if the read before that write is omitted
from instrumentation. The default TSan runtime currently does not
support the different instrumentation, and the option is disabled by
default.

Alternative runtimes, such as the Kernel Concurrency Sanitizer (KCSAN)
can make use of the feature. Indeed, the initial motivation is for use
in KCSAN as it was determined that due to the Linux kernel having a
large number of unaddressed data races, it makes sense to improve
performance and reporting by distinguishing compounded operations. E.g.
the compounded instrumentation is typically emitted for compound
operations such as ++, +=, |=, etc. By emitting different reports, such
data races can easily be noticed, and also automatically bucketed
differently by CI systems.

Reviewed By: dvyukov, glider

Tags: #llvm

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

4 years ago[compiler-rt][asan] Define MemToShadowSize for sparc64
Rainer Orth [Fri, 17 Jul 2020 08:04:19 +0000 (10:04 +0200)]
[compiler-rt][asan] Define MemToShadowSize for sparc64

[compiler-rt][asan][hwasan] Refactor shadow setup into sanitizer_common (NFCI) <https://reviews.llvm.org/D83247>
broke the Solaris/sparcv9 <http://lab.llvm.org:8014/builders/clang-solaris11-sparcv9/builds/6623> build:

  FAILED: projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.sparcv9.dir/asan_linux.cpp.o
  /opt/llvm-buildbot/bin/c++  -D_DEBUG -D_FILE_OFFSET_BITS=64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/compiler-rt/lib/asan -I/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/compiler-rt/lib/asan -Iinclude -I/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/include -I/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/include/llvm/Support/Solaris -I/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/compiler-rt/lib/asan/.. -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -std=c++14 -Wno-unused-parameter -O3     -m64 -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fvisibility=hidden -fno-lto -O3 -g -Wno-variadic-macros -Wno-non-virtual-dtor -fno-rtti -UNDEBUG -std=c++14 -MD -MT projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.sparcv9.dir/asan_linux.cpp.o -MF projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.sparcv9.dir/asan_linux.cpp.o.d -o projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.sparcv9.dir/asan_linux.cpp.o -c /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/compiler-rt/lib/asan/asan_linux.cpp
  /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/compiler-rt/lib/asan/asan_linux.cpp: In function ‘__sanitizer::uptr __asan::FindDynamicShadowStart()’:
  /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/compiler-rt/lib/asan/asan_linux.cpp:103:28: error: ‘MemToShadowSize’ was not declared in this scope
     uptr shadow_size_bytes = MemToShadowSize(kHighMemEnd);
                              ^~~~~~~~~~~~~~~
  /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/compiler-rt/lib/asan/asan_linux.cpp:103:28: note: suggested alternative: ‘MemToShadow’
     uptr shadow_size_bytes = MemToShadowSize(kHighMemEnd);
                              ^~~~~~~~~~~~~~~
                              MemToShadow

Fixed by also definining `MemToShadowSize` in `compiler-rt/lib/asan/asan_mapping_sparc64.h`.

Tested on `sparcv9-sun-solaris2.11`.

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

4 years ago[ARM] halfword store hits llvm_unreachable with big-endian
Simon Wallis [Fri, 17 Jul 2020 07:26:30 +0000 (08:26 +0100)]
[ARM] halfword store hits llvm_unreachable with big-endian

Summary:
[ARM] halfword store hits llvm_unreachable with big-endian

Provide missing case in getFixupKindContainerSizeBytes().

This stops execution reaching llvm_unreachable("Unknown fixup kind!")

D83947

Reviewers: olista01, ostannard

Reviewed By: ostannard

Subscribers: ostannard, kristof.beyls, hiraditya, danielkiss, llvm-commits

Tags: #llvm

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

Change-Id: I598aa1fb51fd1c6f424c557c85d6df6d1958bc62

4 years ago[lldb] Store StackFrameRecognizers in the target instead of a global list
Raphael Isemann [Fri, 17 Jul 2020 06:36:38 +0000 (08:36 +0200)]
[lldb] Store StackFrameRecognizers in the target instead of a global list

Summary:

Currently the frame recognizers are stored in a global list (the list in the
StackFrameRecognizersManagerImpl singleton to be precise). All commands and
plugins that modify the list are just modifying that global list of recognizers
which is shared by all Target and Debugger instances.

This is clearly against the idea of LLDB being usable as a library and it also
leads to some very obscure errors as now multiple tests are sharing the used
frame recognizers. For example D83400 is currently failing as it reorders some
test_ functions which permanently changes the frame recognizers of all
debuggers/targets. As all frame recognizers are also initialized in a 'once'
guard, it's also impossible to every restore back the original frame recognizers
once they are deleted in a process.

This patch just moves the frame recognizers into the current target. This seems
the way everyone assumes the system works as for example the assert frame
recognizers is using the current target to find the function/so-name to look for
(which only works if the recognizers are stored in the target).

Reviewers: jingham, mib

Reviewed By: jingham, mib

Subscribers: MrHate, JDevlieghere

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

4 years ago[libc][Obvious] Cleanup of include lines and target listings in FPUtil.
Siva Chandra Reddy [Fri, 17 Jul 2020 07:08:28 +0000 (00:08 -0700)]
[libc][Obvious] Cleanup of include lines and target listings in FPUtil.

4 years ago[sanitizer] Revert accidentally committed file
Vitaly Buka [Fri, 17 Jul 2020 07:08:45 +0000 (00:08 -0700)]
[sanitizer] Revert accidentally committed file

4 years ago[profile] Enabled test on windows
Vitaly Buka [Fri, 17 Jul 2020 07:05:07 +0000 (00:05 -0700)]
[profile] Enabled test on windows

Works with D34797

4 years ago[InstCombine] Fix replace select with Phis when branch has the same labels
Max Kazantsev [Fri, 17 Jul 2020 07:01:59 +0000 (14:01 +0700)]
[InstCombine] Fix replace select with Phis when branch has the same labels

```
define i32 @test(i1 %cond) {
entry:
  br i1 %cond, label %exit, label %exit
exit:
  %result = select i1 %cond, i32 123, i32 456
  ret i32 %result
}
```
In this test, after applying transformation of replacing select with Phis,
the result will be:

```
define i32 @test(i1 %cond) {
entry:
  br i1 %cond, label %exit, label %exit
exit:
  %result = i32 phi [123, %exit], [123, %exit]
  ret i32 %result
}
```
That is, select is transformed into an invalid Phi, which will then be
reduced to 123 and the second value will be lost. But it is worth
noting that this problem will arise only if select is in the InstCombine
worklist will be before the branch. Otherwise, InstCombine will replace
the branch condition with false and transformation will not be applied.

The fix is to check the target labels in the branch condition for equality.

Patch By: Kirill Polushin
Differential Revision: https://reviews.llvm.org/D84003
Reviewed By: mkazantsev

4 years agoRevert "[AMDGPU/MemOpsCluster] Implement new heuristic for computing max mem ops...
hsmahesha [Fri, 17 Jul 2020 06:10:10 +0000 (11:40 +0530)]
Revert "[AMDGPU/MemOpsCluster] Implement new heuristic for computing max mem ops cluster size"

This reverts commit cc9d69385659be32178506a38b4f2e112ed01ad4.

4 years ago[DebugInfo] Fix a misleading usage of DWARF forms with DIEExpr. NFCI.
Igor Kudrin [Fri, 17 Jul 2020 05:46:47 +0000 (12:46 +0700)]
[DebugInfo] Fix a misleading usage of DWARF forms with DIEExpr. NFCI.

For now, DIEExpr is used only in two places:

 1) in the debug info library unit test suite to emit
    a DW_AT_str_offsets_base attribute with the DW_FORM_sec_offset
    form, see dwarfgen::DIE::addStrOffsetsBaseAttribute();

 2) in DwarfCompileUnit::addLocationAttribute() to generate the location
    attribute for a TLS variable.

The later case used an incorrect DWARF form of DW_FORM_udata, which
implies storing an uleb128 value, not a 4/8 byte constant. The generated
result was as expected because DIEExpr::SizeOf() did not handle the used
form, but returned the size of the code pointer by default.

The patch fixes the issue by using more appropriate DWARF forms for
the problematic case and making DIEExpr::SizeOf() more straightforward.

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

4 years ago[lldb] Only set the executable module for a target once
Raphael Isemann [Fri, 17 Jul 2020 06:03:07 +0000 (08:03 +0200)]
[lldb] Only set the executable module for a target once

Summary:

When we try to find the executable module for our target we don't check
if we already have an executable module set. This causes that when debugging
a program that dlopens another executable, LLDB will take that other executable
as the new executable of the target (which causes that future launches of the
target will launch the dlopen'd executable instead of the original executable).

This just adds a check that we only set the executable when we haven't already
found one.

Fixes rdar://63443099

Reviewers: jasonmolenda, jingham, teemperor

Reviewed By: jasonmolenda, teemperor

Subscribers: jingham, JDevlieghere

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

4 years ago[X86] Change the scheduler model for 'pentium4' to SandyBridgeModel.
Craig Topper [Fri, 17 Jul 2020 05:04:24 +0000 (22:04 -0700)]
[X86] Change the scheduler model for 'pentium4' to SandyBridgeModel.

I meant to do this in D83913, but missed it while updating the
feature list.

Interestingly I think this is disabling the postRA scheduler. But
it does match our default 64-bit behavior.

Reviewed By: echristo

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

4 years ago[X86] Reorder how the subtarget map key is created.
Craig Topper [Fri, 17 Jul 2020 03:14:20 +0000 (20:14 -0700)]
[X86] Reorder how the subtarget map key is created.

We use a SmallString<512> and attempted to reserve enough space
for CPU plus Features, but that doesn't account for all the things
that get added to the string.

Reorder the string so the shortest things go first which shouldn't
exceed the small size. Finally add the feature string at the end
which might be long. This should ensure at most one heap allocation
without needing to use reserve.

I don't know if this matters much in practice, but I was looking
into something else that will require more code here and noticed
the odd reserve call.

4 years ago[llvm] Add RISCVTargetParser.def to the module map
Jonas Devlieghere [Fri, 17 Jul 2020 04:38:49 +0000 (21:38 -0700)]
[llvm] Add RISCVTargetParser.def to the module map

This fixes the modules build.

4 years ago[ValueTracking] Let isGuaranteedNotToBeUndefOrPoison consider noundef
Juneyoung Lee [Fri, 17 Jul 2020 03:53:08 +0000 (12:53 +0900)]
[ValueTracking] Let isGuaranteedNotToBeUndefOrPoison consider noundef

 This patch adds support for noundef arguments.

Reviewed By: nikic

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

4 years agoAdd a test for D83752
Juneyoung Lee [Fri, 17 Jul 2020 03:50:28 +0000 (12:50 +0900)]
Add a test for D83752

4 years ago[DWARFYAML] Merge forms that use same encodings. NFC.
Xing GUO [Fri, 17 Jul 2020 03:28:29 +0000 (11:28 +0800)]
[DWARFYAML] Merge forms that use same encodings. NFC.

4 years ago[polly][NFC] Add missing 'override's
Logan Smith [Fri, 17 Jul 2020 03:12:13 +0000 (20:12 -0700)]
[polly][NFC] Add missing 'override's

4 years ago[compiler-rt][NFC] Add missing 'override's
Logan Smith [Fri, 17 Jul 2020 03:07:57 +0000 (20:07 -0700)]
[compiler-rt][NFC] Add missing 'override's

4 years ago[LangRef] Mention that freeze does not consider aggregate's paddings
Juneyoung Lee [Fri, 17 Jul 2020 02:53:26 +0000 (11:53 +0900)]
[LangRef] Mention that freeze does not consider aggregate's paddings

Make explicit that freeze does not touch paddings of an aggregate.
(Relevant comment: https://reviews.llvm.org/D83752#2152550)

This implies that `v = freeze(load p); store v, q` may still leave undef bits
or poison in memory if `v` is an aggregate, but it still happens for
non-byte integers such as i1.

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

4 years ago[AMDGPU] Translate s_and/s_andn2 to s_mov in vcc optimisation
Carl Ritson [Fri, 17 Jul 2020 02:12:12 +0000 (11:12 +0900)]
[AMDGPU] Translate s_and/s_andn2 to s_mov in vcc optimisation

When SCC is dead, but VCC is required then replace s_and / s_andn2
with s_mov into VCC when mask value is 0 or -1.

Reviewed By: rampitec

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

4 years ago[profile] Disable new failing test from D83967
Vitaly Buka [Fri, 17 Jul 2020 02:47:36 +0000 (19:47 -0700)]
[profile] Disable new failing test from D83967

4 years ago[sanitizer] Fix symbolizer build broken by D82702
Vitaly Buka [Fri, 17 Jul 2020 02:33:50 +0000 (19:33 -0700)]
[sanitizer] Fix symbolizer build broken by D82702

4 years agoRevert "[libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes...
Richard Smith [Fri, 17 Jul 2020 01:06:06 +0000 (18:06 -0700)]
Revert "[libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked."

This causes binaries linked with this runtime to crash on startup if
dlsym uses any of the intercepted functions. (For example, that happens
when using tcmalloc as the allocator: dlsym attempts to allocate memory
with malloc, and tcmalloc uses strncmp within its implementation.)

Also revert dependent commit "[libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given."

This reverts commit f78d9fceea736d431e9e3cbca291e3909e3aa46d and 12d1124c49beec0fb79d36944960e5bf0f236d4c.

4 years ago[gn build] Port 9870f77441c
LLVM GN Syncbot [Thu, 16 Jul 2020 23:07:46 +0000 (23:07 +0000)]
[gn build] Port 9870f77441c

4 years ago[gn build] Port 0f6220ddd6c
LLVM GN Syncbot [Thu, 16 Jul 2020 23:07:45 +0000 (23:07 +0000)]
[gn build] Port 0f6220ddd6c

4 years ago[gn build] Port 0e940d55f8a
LLVM GN Syncbot [Thu, 16 Jul 2020 23:07:45 +0000 (23:07 +0000)]
[gn build] Port 0e940d55f8a

4 years ago[gn build] (manually) merge 9870f77441c
Nico Weber [Thu, 16 Jul 2020 23:07:28 +0000 (19:07 -0400)]
[gn build] (manually) merge 9870f77441c

4 years ago[profile] Move __llvm_profile_raw_version into a separate file
Min-Yih Hsu [Fri, 10 Jul 2020 16:40:09 +0000 (09:40 -0700)]
[profile] Move __llvm_profile_raw_version into a separate file

Similar to the reason behind moving __llvm_profile_filename into a
separate file[1]. When users try to use Full LTO with BFD linker to
generate IR level PGO profile, the __llvm_profile_raw_version variable,
which is used for marking instrumentation level, generated by frontend
would somehow conflict with the weak symbol provided by profiling
runtime.

In most of the cases, BFD linkers will pick profiling runtime's weak symbol
as the real definition and thus generate the incorrect instrumentation
level metadata in the final executables.

Moving __llvm_profile_raw_version into a separate file would make
linkers not seeing the weak symbol in the archive unless the frontend
doesn't generate one.

[1] https://reviews.llvm.org/D34797

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

4 years ago[tsan][go] Fix for missing symbols needed by GotsanRuntimeCheck
Jon Roelofs [Thu, 16 Jul 2020 23:01:06 +0000 (17:01 -0600)]
[tsan][go] Fix for missing symbols needed by GotsanRuntimeCheck

4 years ago[ORC] Switch from initializer lists to named arguments to work around MSVC.
Lang Hames [Thu, 16 Jul 2020 22:55:29 +0000 (15:55 -0700)]
[ORC] Switch from initializer lists to named arguments to work around MSVC.

MSVC doesn't like some of the initializer list uses in 0e940d55f8a.
Switch to named arguments to work around this.

4 years ago[libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when ...
Dokyung Song [Thu, 16 Jul 2020 21:24:06 +0000 (21:24 +0000)]
[libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given.

Summary: This patch disables implicit builtin knowledge about memcmp-like functions when compiling the program for fuzzing, i.e., when -fsanitize=fuzzer(-no-link) is given. This allows libFuzzer to always intercept memcmp-like functions as it effectively disables optimizing calls to such functions into different forms. This is done by adding a set of flags (-fno-builtin-memcmp and others) in the clang driver. Individual -fno-builtin-* flags previously used in several libFuzzer tests are now removed, as it is now done automatically in the clang driver.

Reviewers: morehouse, hctim

Subscribers: cfe-commits, #sanitizers

Tags: #clang, #sanitizers

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

4 years ago[lldb/Test] Skip TestMacABImacOSFramework.py with reproducers
Jonas Devlieghere [Thu, 16 Jul 2020 22:49:22 +0000 (15:49 -0700)]
[lldb/Test] Skip TestMacABImacOSFramework.py with reproducers

This test is hitting https://bugs.python.org/issue22393 which results in
the lit multiprocessing pool deadlocking and the reproducer job timing
out on GreenDragon.

4 years ago[ORC] Add more explicit casts to fix a narrowing conversion errors.
Lang Hames [Thu, 16 Jul 2020 22:35:51 +0000 (15:35 -0700)]
[ORC] Add more explicit casts to fix a narrowing conversion errors.

4 years ago[ORC] Add explicit cast to fix a narrowing conversion error.
Lang Hames [Thu, 16 Jul 2020 22:26:56 +0000 (15:26 -0700)]
[ORC] Add explicit cast to fix a narrowing conversion error.

4 years agocmake list formatting fix
Nico Weber [Thu, 16 Jul 2020 22:29:48 +0000 (18:29 -0400)]
cmake list formatting fix

4 years ago[PowerPC][Power10] Add 128-bit Binary Integer Operation instruction definitions and...
Albion Fung [Thu, 16 Jul 2020 17:03:11 +0000 (12:03 -0500)]
[PowerPC][Power10] Add 128-bit Binary Integer Operation instruction definitions and MC Tests

This patch adds the instruction definitions and MC tests for the 128-bit Binary
Integer Operation instructions introduced in Power10.

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

4 years ago[builtins] Omit 80-bit builtins on Android and MSVC
Ryan Prichard [Thu, 16 Jul 2020 22:10:22 +0000 (15:10 -0700)]
[builtins] Omit 80-bit builtins on Android and MSVC

long double is a 64-bit double-precision type on:
 - MSVC (32- and 64-bit x86)
 - Android (32-bit x86)

long double is a 128-bit quad-precision type on x86_64 Android.

The assembly variants of the 80-bit builtins are correct, but some of
the builtins are implemented in C and require that long double be the
80-bit type passed via an x87 register.

Reviewed By: compnerd

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

4 years ago[compiler-rt][asan][hwasan] Fix Android bots
Teresa Johnson [Thu, 16 Jul 2020 21:42:00 +0000 (14:42 -0700)]
[compiler-rt][asan][hwasan] Fix Android bots

Fix failure in Android bots from refactoring in
5d2be1a18845c528d3e86f7efcc59872e4a757c3 (https://crbug.com/1106482).

We need to make the UnmapFromTo available outside sanitizer_common for
calls from hwasan and asan linux handling. While here, remove
declaration of GetHighMemEnd which is no longer in sanitizer_common.

4 years ago[ORC] Add TargetProcessControl and TPCIndirectionUtils APIs.
Lang Hames [Thu, 16 Jul 2020 19:51:14 +0000 (12:51 -0700)]
[ORC] Add TargetProcessControl and TPCIndirectionUtils APIs.

TargetProcessControl is a new API for communicating with JIT target processes.
It supports memory allocation and access, and inspection of some process
properties, e.g. the target proces triple and page size.

Centralizing these APIs allows utilities written against TargetProcessControl
to remain independent of the communication procotol with the target process
(which may be direct memory access/allocation for in-process JITing, or may
involve some form of IPC or RPC).

An initial set of TargetProcessControl-based utilities for lazy compilation is
provided by the TPCIndirectionUtils class.

An initial implementation of TargetProcessControl for in-process JITing
is provided by the SelfTargetProcessControl class.

An example program showing how the APIs can be used is provided in
llvm/examples/OrcV2Examples/LLJITWithTargetProcessControl.

4 years ago[lldb] Eliminated unused local variable
Adrian McCarthy [Thu, 16 Jul 2020 21:44:24 +0000 (14:44 -0700)]
[lldb] Eliminated unused local variable

I got misled by this remnant from earlier changes.

4 years ago[SimplifyCFG] Fix crash in the EXPENSIVE_CHECKS build
Jon Roelofs [Thu, 16 Jul 2020 21:10:22 +0000 (15:10 -0600)]
[SimplifyCFG] Fix crash in the EXPENSIVE_CHECKS build

SimplifyCFG was incorrectly reporting to the pass manager that it had not made
changes after folding away a PHI.  This is detected in the EXPENSIVE_CHECKS
build when the function's hash changes.

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

4 years ago[spirv] Use owning module ref to avoid leaks and fix ASAN tests
Lei Zhang [Thu, 16 Jul 2020 20:05:51 +0000 (16:05 -0400)]
[spirv] Use owning module ref to avoid leaks and fix ASAN tests

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

4 years ago[WebAssembly] 64-bit (function) pointer fixes.
Wouter van Oortmerssen [Fri, 10 Jul 2020 23:51:01 +0000 (16:51 -0700)]
[WebAssembly] 64-bit (function) pointer fixes.

Accounting for the fact that Wasm function indices are 32-bit, but in wasm64 we want uniform 64-bit pointers.
Includes reloc types for 64-bit table indices.

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

4 years ago[NFC][PhaseOrdering] Add a test demonstrating pitfails of common code hoisting on...
Roman Lebedev [Thu, 16 Jul 2020 20:33:10 +0000 (23:33 +0300)]
[NFC][PhaseOrdering] Add a test demonstrating pitfails of common code hoisting on loop rotation

Depending on the -rotation-max-header-size=?,
hoisting common code early makes loop rotation impossible.

4 years ago[X86] Move integer hadd/hsub formation into a helper function shared by combineAdd...
Craig Topper [Thu, 16 Jul 2020 19:52:02 +0000 (12:52 -0700)]
[X86] Move integer hadd/hsub formation into a helper function shared by combineAdd and combineSub.

There was a lot of duplicate code here for checking the VT and
subtarget. Moving it into a helper avoids that.

It also fixes a bug that combineAdd reused Op0/Op1 after a call
to isHorizontalBinOp may have changed it. The new helper function
has its own local version of Op0/Op1 that aren't shared by other
code.

Fixes PR46455.

Reviewed By: spatel, bkramer

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

4 years ago[libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not...
Dokyung Song [Thu, 16 Jul 2020 20:26:03 +0000 (20:26 +0000)]
[libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

Summary: libFuzzer intercepts certain library functions such as memcmp/strcmp by defining weak hooks. Weak hooks, however, are called only when other runtimes such as ASan is linked. This patch defines libFuzzer's own interceptors, which is linked into the libFuzzer executable when other runtimes are not linked, i.e., when -fsanitize=fuzzer is given, but not others.

Reviewers: kcc, morehouse, hctim

Reviewed By: morehouse, hctim

Subscribers: krytarowski, mgorny, cfe-commits, #sanitizers

Tags: #clang, #sanitizers

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

4 years ago[Statepoint] Fix bug found by sanitaizer.
Denis Antrushin [Thu, 16 Jul 2020 19:54:58 +0000 (22:54 +0300)]
[Statepoint] Fix bug found by sanitaizer.

Statepoint has no static operands, so it cannot be verified
against MCInstrDescr. Revert NumDefs change introduced by ef658ebd629.

4 years agoHarmonize Python shebang
serge-sans-paille [Wed, 15 Jul 2020 07:31:13 +0000 (09:31 +0200)]
Harmonize Python shebang

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

4 years agoFix incorrect file path in documentation
Matt Arsenault [Thu, 16 Jul 2020 00:42:17 +0000 (20:42 -0400)]
Fix incorrect file path in documentation

4 years agoAMDGPU: Add a few more missing test for AGPR tuple copying
Matt Arsenault [Thu, 16 Jul 2020 19:44:44 +0000 (15:44 -0400)]
AMDGPU: Add a few more missing test for AGPR tuple copying

4 years ago[X86] Change the tuning settings for pentium4 to be more modern since its the default...
Craig Topper [Thu, 16 Jul 2020 18:20:57 +0000 (11:20 -0700)]
[X86] Change the tuning settings for pentium4 to be more modern since its the default 32-bit cpu in clang

Alternative to D83897. I believe the big change here is that I removed slow unaligned memory 16

Down side that it may adversely effect tuning if someone explicitly targets -march=pentium4 and expects pentium4 tuned code. Of course pentium4 is so old our default behavior with the previous settings may not have been the best either.

Reviewed By: echristo, RKSimon

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

4 years agoRemove an unused variable in Clang.
Nadav Rotem [Tue, 14 Jul 2020 20:59:36 +0000 (13:59 -0700)]
Remove an unused variable in Clang.

https://reviews.llvm.org/D83788

4 years ago[libc++abi] Temporarily disable test on Apple to fix the CI
Louis Dionne [Thu, 16 Jul 2020 19:41:55 +0000 (15:41 -0400)]
[libc++abi] Temporarily disable test on Apple to fix the CI

This test has been failing on some SDKs for a long time because we lack
a proper way of identifying the SDK version in Lit. Until that is possible,
mark the test as unsupported on Apple to restore the CI.

4 years ago[libc++] Remove shortcut Lit features for Apple backdeployment
Louis Dionne [Thu, 16 Jul 2020 19:34:15 +0000 (15:34 -0400)]
[libc++] Remove shortcut Lit features for Apple backdeployment

Some time ago, I introduced shortcut features like dylib-has-no-shared_mutex
to encode whether the deployment target supported shared_mutex (say). This
made the test suite annotations cleaner.

However, the problem with building Lit features on top of other Lit
features is that it's easier for them to become stale, especially when
they are generated programmatically. Furthermore, it makes the bar for
defining configurations from scratch higher, since more features have
to be defined. Instead, I think it's better to put the XFAILs in the
tests directly, which allows cleaning them up with a simple grep.

4 years agoAMDGPU: Add missing tests for copyPhysReg AGPR tuples
Matt Arsenault [Thu, 16 Jul 2020 19:17:10 +0000 (15:17 -0400)]
AMDGPU: Add missing tests for copyPhysReg AGPR tuples

4 years ago[llvm] Moved InlineSizeEstimatorAnalysis test to .ll
Mircea Trofin [Wed, 15 Jul 2020 23:02:15 +0000 (16:02 -0700)]
[llvm] Moved InlineSizeEstimatorAnalysis test to .ll

Summary:
Following guidance in
https://llvm.org/docs/TestingGuide.html#testing-analysis

Reviewers: mehdi_amini

Subscribers: mgorny, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[intel-pt] Fix building due to CMake + python changes
Walter Erquinigo [Thu, 16 Jul 2020 19:18:59 +0000 (12:18 -0700)]
[intel-pt] Fix building due to CMake + python changes

Python is now handled in CMake with different variables, thus
the intel plugin needs a corresponding update.

Test Plan:

Differential Revision: https://phabricator.intern.facebook.com/D22555992

4 years ago[libc++] Improve how we report the testing configuration
Louis Dionne [Thu, 16 Jul 2020 19:01:09 +0000 (15:01 -0400)]
[libc++] Improve how we report the testing configuration

4 years ago[gn build] Port 5e8b4be9f85
LLVM GN Syncbot [Thu, 16 Jul 2020 19:08:09 +0000 (19:08 +0000)]
[gn build] Port 5e8b4be9f85

4 years ago[AST][NFC] Simplify a regression test
Jan Korous [Thu, 16 Jul 2020 19:06:02 +0000 (12:06 -0700)]
[AST][NFC] Simplify a regression test

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

4 years ago[WebAssembly] Triple::wasm64 related cleanup
Wouter van Oortmerssen [Mon, 6 Jul 2020 20:34:16 +0000 (13:34 -0700)]
[WebAssembly] Triple::wasm64 related cleanup

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

4 years agoTemporarily Revert "[AssumeBundles] Use operand bundles to encode alignment assumptions"
Eric Christopher [Thu, 16 Jul 2020 18:40:43 +0000 (11:40 -0700)]
Temporarily Revert "[AssumeBundles] Use operand bundles to encode alignment assumptions"
due to the performance bugs filed in https://bugs.llvm.org/show_bug.cgi?id=46753.

An SROA change soon may obviate some of these problems.

This reverts commit 8d09f20798ac180b1749276bff364682ce0196ab.

4 years ago[InjectTLIMappings] Use StringRef instead of std::string for FN name.
Nadav Rotem [Tue, 14 Jul 2020 20:35:06 +0000 (13:35 -0700)]
[InjectTLIMappings] Use StringRef instead of std::string for FN name.

https://reviews.llvm.org/D83797

4 years ago[Analyzer] Hotfix for various crashes in iterator checkers
Adam Balogh [Tue, 7 Jul 2020 10:03:07 +0000 (12:03 +0200)]
[Analyzer] Hotfix for various crashes in iterator checkers

The patch that introduces handling iterators implemented as pointers may
cause crash in some projects because pointer difference is mistakenly
handled as pointer decrement. (Similair case for iterators implemented
as class instances are already handled correctly.) This patch fixes this
issue.

The second case that causes crash is comparison of an iterator
implemented as pointer and a null-pointer. This patch contains a fix for
this issue as well.

The third case which causes crash is that the checker mistakenly
considers all integers as nonloc::ConcreteInt when handling an increment
or decrement of an iterator implemented as pointers. This patch adds a
fix for this too.

The last case where crashes were detected is when checking for success
of an std::advance() operation. Since the modeling of iterators
implemented as pointers is still incomplete this may result in an
assertion. This patch replaces the assertion with an early exit and
adds a FIXME there.

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

4 years agoRevert "[Darwin] Fix OS version checks inside simulators"
Julian Lettner [Thu, 16 Jul 2020 18:46:45 +0000 (11:46 -0700)]
Revert "[Darwin] Fix OS version checks inside simulators"

This reverts commit b16dfbead21a458799a0dab96599eb15f5d9b7ea.

Accidental push, reverting and creating a new revision.

4 years ago[compiler-rt][asan][hwasan] Refactor shadow setup into sanitizer_common (NFCI)
Teresa Johnson [Mon, 6 Jul 2020 18:05:12 +0000 (11:05 -0700)]
[compiler-rt][asan][hwasan] Refactor shadow setup into sanitizer_common (NFCI)

Summary:
This refactors some common support related to shadow memory setup from
asan and hwasan into sanitizer_common. This should not only reduce code
duplication but also make these facilities available for new compiler-rt
uses (e.g. heap profiling).

In most cases the separate copies of the code were either identical, or
at least functionally identical. A few notes:

In ProtectGap, the asan version checked the address against an upper
bound (kZeroBaseMaxShadowStart, which is (2^18). I have created a copy
of kZeroBaseMaxShadowStart in hwasan_mapping.h, with the same value, as
it isn't clear why that code should not do the same check. If it
shouldn't, I can remove this and guard this check so that it only
happens for asan.

In asan's InitializeShadowMemory, in the dynamic shadow case it was
setting __asan_shadow_memory_dynamic_address to 0 (which then sets both
macro SHADOW_OFFSET as well as macro kLowShadowBeg to 0) before calling
FindDynamicShadowStart(). AFAICT this is only needed because
FindDynamicShadowStart utilizes kHighShadowEnd to
get the shadow size, and kHighShadowEnd is a macro invoking
MEM_TO_SHADOW(kHighMemEnd) which in turn invokes:
(((kHighMemEnd) >> SHADOW_SCALE) + (SHADOW_OFFSET))
I.e. it computes the shadow space needed by kHighMemEnd (the shift), and
adds the offset. Since we only want the shadow space here, the earlier
setting of SHADOW_OFFSET to 0 via __asan_shadow_memory_dynamic_address
accomplishes this. In the hwasan version, it simply gets the shadow
space via "MemToShadowSize(kHighMemEnd)", where MemToShadowSize just
does the shift. I've simplified the asan handling to do the same
thing, and therefore was able to remove the setting of the SHADOW_OFFSET
via __asan_shadow_memory_dynamic_address to 0.

Reviewers: vitalybuka, kcc, eugenis

Subscribers: dberris, #sanitizers, llvm-commits, davidxl

Tags: #sanitizers

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

4 years ago[RISCV] Add support for -mcpu option.
Zakk Chen [Thu, 16 Jul 2020 17:32:01 +0000 (10:32 -0700)]
[RISCV] Add support for -mcpu option.

Summary:
1. gcc uses `-march` and `-mtune` flag to chose arch and
pipeline model, but clang does not have `-mtune` flag,
we uses `-mcpu` to chose both infos.
2. Add SiFive e31 and u54 cpu which have default march
and pipeline model.
3. Specific `-mcpu` with rocket-rv[32|64] would select
pipeline model only, and use the driver's arch choosing
logic to get default arch.

Reviewers: lenary, asb, evandro, HsiangKai

Reviewed By: lenary, asb, evandro

Tags: #llvm, #clang

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