platform/upstream/llvm.git
4 years agoRemove strings.h include to fix GSYM Windows build
Reid Kleckner [Thu, 10 Oct 2019 18:17:24 +0000 (18:17 +0000)]
Remove strings.h include to fix GSYM Windows build

Fifth time's the charm.

llvm-svn: 374411

4 years agoUnbreak buildbots.
Greg Clayton [Thu, 10 Oct 2019 18:13:13 +0000 (18:13 +0000)]
Unbreak buildbots.

llvm-svn: 374410

4 years agoFix buildbots by using memset instead of bzero.
Greg Clayton [Thu, 10 Oct 2019 18:11:49 +0000 (18:11 +0000)]
Fix buildbots by using memset instead of bzero.

llvm-svn: 374409

4 years ago[libc++][test] Change IsSmallObject's calculation for std::any's small object buffer
Casey Carter [Thu, 10 Oct 2019 18:07:12 +0000 (18:07 +0000)]
[libc++][test] Change IsSmallObject's calculation for std::any's small object buffer

`sizeof(std::any) - sizeof(void*)` is correct for both libc++ and the MSVC standard library.

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

llvm-svn: 374407

4 years agoFix build by adding the missing dependency.
Michael Liao [Thu, 10 Oct 2019 18:04:52 +0000 (18:04 +0000)]
Fix build by adding the missing dependency.

llvm-svn: 374406

4 years ago[lit] Leverage argparse features to remove some code
Julian Lettner [Thu, 10 Oct 2019 18:03:37 +0000 (18:03 +0000)]
[lit] Leverage argparse features to remove some code

Reviewed By: rnk, serge-sans-paille

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

llvm-svn: 374405

4 years agoFix test to avoid check-not matching the temp file absolute path
Reid Kleckner [Thu, 10 Oct 2019 18:01:27 +0000 (18:01 +0000)]
Fix test to avoid check-not matching the temp file absolute path

Fix for PR43636

llvm-svn: 374404

4 years agoRe-land "Use -fdebug-compilation-dir to form absolute paths in coverage mappings"
Reid Kleckner [Thu, 10 Oct 2019 18:01:20 +0000 (18:01 +0000)]
Re-land "Use -fdebug-compilation-dir to form absolute paths in coverage mappings"

This reverts r374324 (git commit 62808631acceaa8b78f8ab9b407eb6b943ff5f77)

I changed the test to not rely on finding the sequence "clang, test,
CoverageMapping" in the CWD used to run the test. Instead it makes its
own internal directory hierarchy of foo/bar/baz and looks for that.

llvm-svn: 374403

4 years agoRemove CC autodetection from Makefile.rules
Adrian Prantl [Thu, 10 Oct 2019 17:59:18 +0000 (17:59 +0000)]
Remove CC autodetection from Makefile.rules

Auto-detecting CC in Makefile.rules is no longer useful. Ever since
out-of-tree builds we are better off just running lldb-dotest which
sets it directly. This also makes it harder to accidentally unset CC
in a Makefile.

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

llvm-svn: 374402

4 years agoSpeed up accelerator table lookups
Adrian Prantl [Thu, 10 Oct 2019 17:59:15 +0000 (17:59 +0000)]
Speed up accelerator table lookups

When debugging a large program like clang and doing "frame variable
*this", the ValueObject pretty printer is doing hundreds of scoped
FindTypes lookups. The ones that take longest are the ones where the
DWARFDeclContext ends in something like ::Iterator which produces many
false positives that need to be filtered out *after* extracting the
DIEs. This patch demonstrates a way to filter out false positives at
the accerator table lookup step.

With this patch
  lldb clang-10 -o "b EmitFunctionStart" -o r -o "f 2" -o "fr v *this" -b -- ...
goes (in user time) from 5.6s -> 4.8s
or (in wall clock) from 6.9s -> 6.0s.

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

llvm-svn: 374401

4 years ago[lit] Move argument parsing/validation to separate file
Julian Lettner [Thu, 10 Oct 2019 17:58:38 +0000 (17:58 +0000)]
[lit] Move argument parsing/validation to separate file

Reviewed By: serge-sans-paille

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

llvm-svn: 374400

4 years ago[clang-format] throws an incorrect assertion in consumeToken() formatting the MSVC stl
Paul Hoad [Thu, 10 Oct 2019 17:54:47 +0000 (17:54 +0000)]
[clang-format] throws an incorrect assertion in consumeToken() formatting the MSVC stl

Summary:
An incorrect assertion is thrown when clang-formatting MSVC's STL library

```
Assertion failed: !Line.startsWith(tok::hash), file C:/llvm/llvm-project/clang/lib/Format/TokenAnnotator.cpp, line 847
Stack dump:
0.      Program arguments: C:\llvm\build\bin\clang-format.exe -i -n ./stl/inc/xkeycheck.h
```

```
Enable warning C4005 to find the forbidden define.
```

Reviewers: mitchell-stellar, STL_MSFT, klimek, krasimir

Reviewed By: mitchell-stellar

Subscribers: cfe-commits

Tags: #clang-format, #clang-tools-extra, #clang

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

llvm-svn: 374399

4 years agoUnbreak llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast buildbot.
Greg Clayton [Thu, 10 Oct 2019 17:52:33 +0000 (17:52 +0000)]
Unbreak  llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast buildbot.

llvm-svn: 374398

4 years ago[DAGCombiner] fold select-of-constants to shift
Sanjay Patel [Thu, 10 Oct 2019 17:52:02 +0000 (17:52 +0000)]
[DAGCombiner] fold select-of-constants to shift

This reverses the scalar canonicalization proposed in D63382.

Pre: isPowerOf2(C1)
%r = select i1 %cond, i32 C1, i32 0
=>
%z = zext i1 %cond to i32
%r = shl i32 %z, log2(C1)

https://rise4fun.com/Alive/Z50

x86 already tries to fold this pattern, but it isn't done
uniformly, so we still see a diff. AArch64 probably should
enable the TLI hook to benefit too, but that's a follow-on.

llvm-svn: 374397

4 years agoUnbreak windows buildbots.
Greg Clayton [Thu, 10 Oct 2019 17:49:33 +0000 (17:49 +0000)]
Unbreak windows buildbots.

llvm-svn: 374396

4 years agogn build: restore tablegen restat optimization after r373664
Nico Weber [Thu, 10 Oct 2019 17:47:18 +0000 (17:47 +0000)]
gn build: restore tablegen restat optimization after r373664

llvm-svn: 374395

4 years agoImplement serializing scripted breakpoints and their extra args.
Jim Ingham [Thu, 10 Oct 2019 17:44:50 +0000 (17:44 +0000)]
Implement serializing scripted breakpoints and their extra args.

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

llvm-svn: 374394

4 years ago[lit] Extend internal diff to support -U
Joel E. Denny [Thu, 10 Oct 2019 17:40:12 +0000 (17:40 +0000)]
[lit] Extend internal diff to support -U

When using lit's internal shell, RUN lines like the following
accidentally execute an external `diff` instead of lit's internal
`diff`:

```
 # RUN: program | diff -U1 file -
```

Such cases exist now, in `clang/test/Analysis` for example.  We are
preparing patches to ensure lit's internal `diff` is called in such
cases, which will then fail because lit's internal `diff` doesn't
recognize `-U` as a command-line option.  This patch adds `-U`
support.

Reviewed By: rnk

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

llvm-svn: 374392

4 years agogn build: merge r374381 more (effectively a no-op)
Nico Weber [Thu, 10 Oct 2019 17:40:00 +0000 (17:40 +0000)]
gn build: merge r374381 more (effectively a no-op)

llvm-svn: 374391

4 years ago[lit] Extend internal diff to support `-` argument
Joel E. Denny [Thu, 10 Oct 2019 17:39:57 +0000 (17:39 +0000)]
[lit] Extend internal diff to support `-` argument

When using lit's internal shell, RUN lines like the following
accidentally execute an external `diff` instead of lit's internal
`diff`:

```
 # RUN: program | diff file -
```

Such cases exist now, in `clang/test/Analysis` for example.  We are
preparing patches to ensure lit's internal `diff` is called in such
cases, which will then fail because lit's internal `diff` doesn't
recognize `-` as a command-line option.  This patch adds support for
`-` to mean stdin.

Reviewed By: probinson, rnk

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

llvm-svn: 374390

4 years ago[lit] Clean up internal diff's encoding handling
Joel E. Denny [Thu, 10 Oct 2019 17:39:41 +0000 (17:39 +0000)]
[lit] Clean up internal diff's encoding handling

As suggested by rnk at D67643#1673043, instead of reading files
multiple times until an appropriate encoding is found, read them once
as binary, and then try to decode what was read.

For python >= 3.5, don't fail when attempting to decode the
`diff_bytes` output in order to print it.

Finally, add some tests for encoding handling.

Reviewed By: rnk

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

llvm-svn: 374389

4 years ago[lit] Make internal diff work in pipelines
Joel E. Denny [Thu, 10 Oct 2019 17:39:24 +0000 (17:39 +0000)]
[lit] Make internal diff work in pipelines

When using lit's internal shell, RUN lines like the following
accidentally execute an external `diff` instead of lit's internal
`diff`:

```
 # RUN: program | diff file -
 # RUN: not diff file1 file2 | FileCheck %s
```

Such cases exist now, in `clang/test/Analysis` for example.  We are
preparing patches to ensure lit's internal `diff` is called in such
cases, which will then fail because lit's internal `diff` cannot
currently be used in pipelines and doesn't recognize `-` as a
command-line option.

To enable pipelines, this patch moves lit's `diff` implementation into
an out-of-process script, similar to lit's `cat` implementation.  A
follow-up patch will implement `-` to mean stdin.

Reviewed By: probinson, stella.stamenova

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

llvm-svn: 374388

4 years ago[OPENMP50]Support for declare variant directive for NVPTX target.
Alexey Bataev [Thu, 10 Oct 2019 17:28:10 +0000 (17:28 +0000)]
[OPENMP50]Support for declare variant directive for NVPTX target.

NVPTX does not support global aliases. Instead, we have to copy the full
body of the variant function for the original function.

llvm-svn: 374387

4 years ago[test] Use a different module cache for Shell and API tests.
Jonas Devlieghere [Thu, 10 Oct 2019 17:27:09 +0000 (17:27 +0000)]
[test] Use a different module cache for Shell and API tests.

Before the test reorganization, everything was part of a single test
suite with a single module cache. Now that things are properly separated
this is no longer the case. Only the shell tests inherited the logic to
properly configure and wipe the module caches. This patch adds that
logic back for the API tests. While doing so, I noticed that we were
configuring a Clang module cache in CMake, but weren't actually using it
from dotest.py. I included a fix for that in this patch as well.

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

llvm-svn: 374386

4 years ago[test] Pass DSYMUTIL and SDKROOT as part of the Make invocation.
Jonas Devlieghere [Thu, 10 Oct 2019 17:27:06 +0000 (17:27 +0000)]
[test] Pass DSYMUTIL and SDKROOT as part of the Make invocation.

Pass the DSYMUTIL and SDKROOT variables on the command line instead of
the environment. This makes it easier to reproduce the make invocation
during development.

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

llvm-svn: 374385

4 years agoReland "[ASan] Do not misrepresent high value address dereferences as null dereferences"
Julian Lettner [Thu, 10 Oct 2019 17:19:58 +0000 (17:19 +0000)]
Reland "[ASan] Do not misrepresent high value address dereferences as null dereferences"

Updated: Removed offending TODO comment.

Dereferences with addresses above the 48-bit hardware addressable range
produce "invalid instruction" (instead of "invalid access") hardware
exceptions (there is no hardware address decoding logic for those bits),
and the address provided by this exception is the address of the
instruction (not the faulting address).  The kernel maps the "invalid
instruction" to SEGV, but fails to provide the real fault address.

Because of this ASan lies and says that those cases are null
dereferences.  This downgrades the severity of a found bug in terms of
security.  In the ASan signal handler, we can not provide the real
faulting address, but at least we can try not to lie.

rdar://50366151

Reviewed By: vitalybuka

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

> llvm-svn: 374265

llvm-svn: 374384

4 years agogn build: Merge r374381
GN Sync Bot [Thu, 10 Oct 2019 17:14:20 +0000 (17:14 +0000)]
gn build: Merge r374381

llvm-svn: 374383

4 years ago[test] Trim the symbtab test case (NFC)
Jonas Devlieghere [Thu, 10 Oct 2019 17:12:57 +0000 (17:12 +0000)]
[test] Trim the symbtab test case (NFC)

We don't actually need the section content for this tests.

llvm-svn: 374382

4 years agoAdd GsymCreator and GsymReader.
Greg Clayton [Thu, 10 Oct 2019 17:10:11 +0000 (17:10 +0000)]
Add GsymCreator and GsymReader.

This patch adds the ability to create GSYM files with GsymCreator, and read them with GsymReader. Full testing has been added for both new classes.

This patch differs from the original patch https://reviews.llvm.org/D53379 in that is uses a StringTableBuilder class from llvm instead of a custom version. Support for big and little endian files has been added. If the endianness matches the current host, we use efficient extraction for the header, address table and address info offset tables.

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

llvm-svn: 374381

4 years ago[dsymutil] Move CommonSymbols.clear() in resetParserState.
Jonas Devlieghere [Thu, 10 Oct 2019 16:37:38 +0000 (16:37 +0000)]
[dsymutil] Move CommonSymbols.clear() in resetParserState.

This seems like a more natural place to clear the vector, especially
since this method is clearing other data structures as well.

llvm-svn: 374378

4 years ago[ARM] VQSUB instruction
David Green [Thu, 10 Oct 2019 16:34:30 +0000 (16:34 +0000)]
[ARM] VQSUB instruction

Same as VQADD, VQSUB can be selected from llvm.ssub.sat intrinsics.

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

llvm-svn: 374377

4 years agoIncrease timeout in pexpect to lower chances of tests failing under ASAN.
Adrian Prantl [Thu, 10 Oct 2019 16:16:49 +0000 (16:16 +0000)]
Increase timeout in pexpect to lower chances of tests failing under ASAN.

If this doesn't actually work, I'll revert the change and just disable
the remaining thee pexpect tests under asan.

llvm-svn: 374375

4 years agoUse arrays on stack and avoid use of new and delete operators.
Siva Chandra [Thu, 10 Oct 2019 16:06:21 +0000 (16:06 +0000)]
Use arrays on stack and avoid use of new and delete operators.

Summary: Also fix an error found with LLVM_USE_SANITIZER=Address.

Reviewers: nelhage

Subscribers: libc-commits

Tags: #libc-project

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

llvm-svn: 374374

4 years ago[Codegen] Alter the default promotion for saturating adds and subs
David Green [Thu, 10 Oct 2019 16:04:49 +0000 (16:04 +0000)]
[Codegen] Alter the default promotion for saturating adds and subs

The default promotion for the add_sat/sub_sat nodes currently does:
   1. ANY_EXTEND iN to iM
   2. SHL by M-N
   3. [US][ADD|SUB]SAT
   4. L/ASHR by M-N
If the promoted add_sat or sub_sat node is not legal, this can produce code
that effectively does a lot of shifting (and requiring large constants to be
materialised) just to use the overflow flag. It is simpler to just do the
saturation manually, using the higher bitwidth addition and a min/max against
the saturating bounds. That is what this patch attempts to do.

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

llvm-svn: 374373

4 years agoFix assertions disabled builds after rL374367
Kadir Cetinkaya [Thu, 10 Oct 2019 16:04:45 +0000 (16:04 +0000)]
Fix assertions disabled builds after rL374367

llvm-svn: 374372

4 years agoIncrease timeout in gdbclientutils.py to decrease chance of test failing under ASAN.
Adrian Prantl [Thu, 10 Oct 2019 15:59:17 +0000 (15:59 +0000)]
Increase timeout in gdbclientutils.py to decrease chance of test failing under ASAN.

llvm-svn: 374371

4 years ago[DAGCombiner] reduce code duplication; NFC
Sanjay Patel [Thu, 10 Oct 2019 15:38:29 +0000 (15:38 +0000)]
[DAGCombiner] reduce code duplication; NFC

llvm-svn: 374370

4 years ago[Alignment][NFC] Use llv::Align in GISelKnownBits
Guillaume Chatelet [Thu, 10 Oct 2019 15:38:22 +0000 (15:38 +0000)]
[Alignment][NFC] Use llv::Align in GISelKnownBits

Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 374369

4 years ago[BPF] Remove relocation for patchable externs
Yonghong Song [Thu, 10 Oct 2019 15:33:09 +0000 (15:33 +0000)]
[BPF] Remove relocation for patchable externs

Previously, patchable extern relocations are introduced to patch
external variables used for multi versioning in
compile once, run everywhere use case. The load instruction
will be converted into a move with an patchable immediate
which can be changed by bpf loader on the host.

The kernel verifier has evolved and is able to load
and propagate constant values, so compiler relocation
becomes unnecessary. This patch removed codes related to this.

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

llvm-svn: 374367

4 years agoIn openFileForRead don't cache erroneous entries if the error relates to them being...
Kousik Kumar [Thu, 10 Oct 2019 15:29:01 +0000 (15:29 +0000)]
In openFileForRead don't cache erroneous entries if the error relates to them being directories. Add tests.

Summary:
It seems that when the CachingFileSystem is first given a file to open that is actually a directory, it incorrectly
caches that path to be errenous and throws an error when subsequently a directory open call is made for the same
path.
This change makes it so that we do NOT cache a path if it turns out we asked for a file when its a directory.

Reviewers: arphaman

Subscribers: dexonsmith, cfe-commits

Tags: #clang

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

llvm-svn: 374366

4 years ago[AMDGPU] Fixed dpp_combine.mir with expensive checks. NFC.
Stanislav Mekhanoshin [Thu, 10 Oct 2019 15:28:52 +0000 (15:28 +0000)]
[AMDGPU] Fixed dpp_combine.mir with expensive checks. NFC.

llvm-svn: 374365

4 years agoFix Wdocumentation warnings. NFCI.
Simon Pilgrim [Thu, 10 Oct 2019 15:25:16 +0000 (15:25 +0000)]
Fix Wdocumentation warnings. NFCI.

llvm-svn: 374364

4 years ago[OPENMP50]Register vendor name only once in vendor context selector.
Alexey Bataev [Thu, 10 Oct 2019 15:15:26 +0000 (15:15 +0000)]
[OPENMP50]Register vendor name only once in vendor context selector.

No need to store multiple copies of the same vendor names in the context
selector, keep only single copy.

llvm-svn: 374363

4 years ago[LLD][ELF] Fix stale comments about doing ICF
Russell Gallop [Thu, 10 Oct 2019 14:50:02 +0000 (14:50 +0000)]
[LLD][ELF] Fix stale comments about doing ICF

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

llvm-svn: 374362

4 years ago[MCA] Show aggregate over Average Wait times for the whole snippet (PR43219)
Roman Lebedev [Thu, 10 Oct 2019 14:46:21 +0000 (14:46 +0000)]
[MCA] Show aggregate over Average Wait times for the whole snippet (PR43219)

Summary:
As disscused in https://bugs.llvm.org/show_bug.cgi?id=43219,
i believe it may be somewhat useful to show //some// aggregates
over all the sea of statistics provided.

Example:
```
Average Wait times (based on the timeline view):
[0]: Executions
[1]: Average time spent waiting in a scheduler's queue
[2]: Average time spent waiting in a scheduler's queue while ready
[3]: Average time elapsed from WB until retire stage

      [0]    [1]    [2]    [3]
0.     3     1.0    1.0    4.7       vmulps     %xmm0, %xmm1, %xmm2
1.     3     2.7    0.0    2.3       vhaddps    %xmm2, %xmm2, %xmm3
2.     3     6.0    0.0    0.0       vhaddps    %xmm3, %xmm3, %xmm4
       3     3.2    0.3    2.3       <total>
```
I.e. we average the averages.

Reviewers: andreadb, mattd, RKSimon

Reviewed By: andreadb

Subscribers: gbedwell, arphaman, llvm-commits

Tags: #llvm

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

llvm-svn: 374361

4 years agoRevert "[FileCheck] Implement --ignore-case option."
Dmitri Gribenko [Thu, 10 Oct 2019 14:27:14 +0000 (14:27 +0000)]
Revert "[FileCheck] Implement --ignore-case option."

This reverts commit r374339. It broke tests:
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/19066

llvm-svn: 374359

4 years agoRevert "[Tests] Output of od can be lower or upper case (llvm-objcopy/yaml2obj)."
Dmitri Gribenko [Thu, 10 Oct 2019 14:26:54 +0000 (14:26 +0000)]
Revert "[Tests] Output of od can be lower or upper case (llvm-objcopy/yaml2obj)."

This reverts commit r374343. It broke tests:
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/19066

llvm-svn: 374358

4 years agoRevert "Fix OCaml/core.ml fneg check"
Dmitri Gribenko [Thu, 10 Oct 2019 14:16:58 +0000 (14:16 +0000)]
Revert "Fix OCaml/core.ml fneg check"

This reverts commit r374346. It attempted to fix OCaml tests, but is
does not actually fix them.

llvm-svn: 374357

4 years ago[X86] combineFMA - Convert to use isNegatibleForFree/GetNegatedExpression.
Simon Pilgrim [Thu, 10 Oct 2019 14:14:12 +0000 (14:14 +0000)]
[X86] combineFMA - Convert to use isNegatibleForFree/GetNegatedExpression.

Split off from D67557.

llvm-svn: 374356

4 years agoFix OCaml/core.ml fneg check (try 2)
Simon Pilgrim [Thu, 10 Oct 2019 14:13:55 +0000 (14:13 +0000)]
Fix OCaml/core.ml fneg check (try 2)

llvm-svn: 374355

4 years agoRevert "[IRBuilder] Update IRBuilder::CreateFNeg(...) to return a UnaryOperator"
Dmitri Gribenko [Thu, 10 Oct 2019 14:13:54 +0000 (14:13 +0000)]
Revert "[IRBuilder] Update IRBuilder::CreateFNeg(...) to return a UnaryOperator"

This reverts commit r374240. It broke OCaml tests:
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/19014

llvm-svn: 374354

4 years agounwind-via-stack-win.yaml: update for changes in yaml format
Pavel Labath [Thu, 10 Oct 2019 14:01:59 +0000 (14:01 +0000)]
unwind-via-stack-win.yaml: update for changes in yaml format

llvm-svn: 374353

4 years ago[lldb] Fix minidebuginfo-set-and-hit-breakpoint.test
Raphael Isemann [Thu, 10 Oct 2019 14:00:32 +0000 (14:00 +0000)]
[lldb] Fix minidebuginfo-set-and-hit-breakpoint.test

This was failing for me because of this error:
llvm-objcopy: error: 'build/tools/lldb/test/ObjectFile/ELF/Output/minidebuginfo-set-and-hit-breakpoint.test.tmp.mini_debuginfo': section '.dynsym' cannot be removed because it is referenced by the section '.hash'

Patch by Konrad Kleine!

llvm-svn: 374352

4 years ago[X86] combineFMADDSUB - Convert to use isNegatibleForFree/GetNegatedExpression.
Simon Pilgrim [Thu, 10 Oct 2019 13:46:44 +0000 (13:46 +0000)]
[X86] combineFMADDSUB - Convert to use isNegatibleForFree/GetNegatedExpression.

Split off from D67557, fixes the compile time regression mentioned in rL372756

llvm-svn: 374351

4 years ago[lldb] Add log output for the support files we pass to the CppModuleConfiguration
Raphael Isemann [Thu, 10 Oct 2019 13:43:37 +0000 (13:43 +0000)]
[lldb] Add log output for the support files we pass to the CppModuleConfiguration

CppModuleConfiguration is the most likely point of failure when we have weird
setups where we fail to load a C++ module. With this logging it should be easier
to figure out why we can't find a valid configuration as the configuration only
depends on the list of file paths.

llvm-svn: 374350

4 years agoRevert "[test] Use system locale for mri-utf8.test"
Thomas Preud'homme [Thu, 10 Oct 2019 13:39:12 +0000 (13:39 +0000)]
Revert "[test] Use system locale for mri-utf8.test"

This reverts commit r374318 / b6f1d1fa0e3ee0e25f22414bf97c05276b934507.

llvm-svn: 374349

4 years agoRevert "[AMDGPU] Run `unreachable-mbb-elimination` after isel to clean up PHIs."
Jay Foad [Thu, 10 Oct 2019 13:34:31 +0000 (13:34 +0000)]
Revert "[AMDGPU] Run `unreachable-mbb-elimination` after isel to clean up PHIs."

Summary:
This has been superseded by "[AMDGPU]: PHI Elimination hooks added for custom COPY insertion."

This reverts the code changes from commit 53f967f2bdb6aa7b08596880c3689d1ecad6f0ff
but keeps the test case.

Reviewers: hliao, arsenm, tpr, dstuttard

Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, t-tye, hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 374347

4 years agoFix OCaml/core.ml fneg check
Simon Pilgrim [Thu, 10 Oct 2019 13:29:47 +0000 (13:29 +0000)]
Fix OCaml/core.ml fneg check

llvm-svn: 374346

4 years ago[DAG][X86] Add isNegatibleForFree/GetNegatedExpression override placeholders. NFCI.
Simon Pilgrim [Thu, 10 Oct 2019 13:29:35 +0000 (13:29 +0000)]
[DAG][X86] Add isNegatibleForFree/GetNegatedExpression override placeholders. NFCI.

Continuing to undo the rL372756 reversion.

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

llvm-svn: 374345

4 years ago[llvm-readelf] - Do not enter an infinite loop when printing histogram.
George Rimar [Thu, 10 Oct 2019 13:26:26 +0000 (13:26 +0000)]
[llvm-readelf] - Do not enter an infinite loop when printing histogram.

This is similar to D68086.
We are entering an infinite loop when dumping a histogram for a specially crafted
.hash section with a loop in a chain.

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

llvm-svn: 374344

4 years ago[Tests] Output of od can be lower or upper case (llvm-objcopy/yaml2obj).
Kai Nacke [Thu, 10 Oct 2019 13:24:00 +0000 (13:24 +0000)]
[Tests] Output of od can be lower or upper case (llvm-objcopy/yaml2obj).

The command `od -t x` is used to dump data in hex format.
The LIT tests assumes that the hex characters are in lowercase.
However, there are also platforms which use uppercase letter.

To solve this issue the tests are updated to use the new
`--ignore-case` option of FileCheck.

Reviewers: Bigcheese, jakehehrlich, rupprecht, espindola, alexshap, jhenderson

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

llvm-svn: 374343

4 years agoFix the unwinding plan augmentation from x86 assembly
Pavel Labath [Thu, 10 Oct 2019 13:23:09 +0000 (13:23 +0000)]
Fix the unwinding plan augmentation from x86 assembly

Unwind plan augmentation should compute the plan row at offset x from
the instruction before offset x, but currently we compute it from the
instruction at offset x. Note that this behavior is a regression
introduced when moving the x86 assembly inspection engine to its own
file
(https://github.com/llvm/llvm-project/commit/1c9858b298d79ce82c45a2954096718b39550109#diff-375a2be066db6f34bb9a71442c9b71fcL913);
the original version handled this properly by copying the previous
instruction out before advancing the instruction pointer.

The relevant bug with more info is here: https://bugs.llvm.org/show_bug.cgi?id=43561

Differential Revision: https://reviews.llvm.org/D68454
Patch by Jaroslav Sevcik <jarin@google.com>.

llvm-svn: 374342

4 years agoFix some dangling else warnings
Pavel Labath [Thu, 10 Oct 2019 13:23:02 +0000 (13:23 +0000)]
Fix some dangling else warnings

EXPECT_EQ contains an if-else statement. It also contains some magic to
suppress the dangling else warnings, but it seems that some new
compilers can see through that...

llvm-svn: 374341

4 years ago[DAGCombine] Match more patterns for half word bswap
Amaury Sechet [Thu, 10 Oct 2019 13:20:10 +0000 (13:20 +0000)]
[DAGCombine] Match more patterns for half word bswap

Summary: It ensures that the bswap is generated even when a part of the subtree already matches a bswap transform.

Reviewers: craig.topper, efriedma, RKSimon, lebedev.ri

Subscribers: llvm-commits

Tags: #llvm

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

llvm-svn: 374340

4 years ago[FileCheck] Implement --ignore-case option.
Kai Nacke [Thu, 10 Oct 2019 13:15:41 +0000 (13:15 +0000)]
[FileCheck] Implement --ignore-case option.

The FileCheck utility is enhanced to support a `--ignore-case`
option. This is useful in cases where the output of Unix tools
differs in case (e.g. case not specified by Posix).

Reviewers: Bigcheese, jakehehrlich, rupprecht, espindola, alexshap, jhenderson, MaskRay

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

llvm-svn: 374339

4 years ago[LV][NFC] Factor out calculation of "best" estimated trip count.
Florian Hahn [Thu, 10 Oct 2019 13:07:01 +0000 (13:07 +0000)]
[LV][NFC] Factor out calculation of "best" estimated trip count.

This is just small refactoring to minimize changes in upcoming patch.
In the next path I'm going to introduce changes into heuristic for vectorization of "tiny trip count" loops.

Patch by Evgeniy Brevnov <evgueni.brevnov@gmail.com>

Reviewers: hsaito, Ayal, fhahn, reames

Reviewed By: hsaito

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

llvm-svn: 374338

4 years agoMinidumpYAML: Add support for the memory info list stream
Pavel Labath [Thu, 10 Oct 2019 13:05:46 +0000 (13:05 +0000)]
MinidumpYAML: Add support for the memory info list stream

Summary:
The implementation is fairly straight-forward and uses the same patterns
as the existing streams. The yaml form does not attempt to preserve the
data in the "gaps" that can be created by setting a larger-than-required
header or entry size in the stream header, because the existing consumer
(lldb) does not make use of the information in the gap in any way, and
attempting to preserve that would make the implementation more
complicated.

Reviewers: amccarth, jhenderson, clayborg

Subscribers: llvm-commits, lldb-commits, markmentovai, zturner, JosephTremoulet

Tags: #llvm

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

llvm-svn: 374337

4 years ago[ARM] VQADD instructions
David Green [Thu, 10 Oct 2019 13:05:04 +0000 (13:05 +0000)]
[ARM] VQADD instructions

This selects MVE VQADD from the vector llvm.sadd.sat or llvm.uadd.sat
intrinsics.

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

llvm-svn: 374336

4 years ago[lldb] Make sure import-std-module/sysroot actually passes for the right reasons
Raphael Isemann [Thu, 10 Oct 2019 12:57:14 +0000 (12:57 +0000)]
[lldb] Make sure import-std-module/sysroot actually passes for the right reasons

This test was previously passing because myabs was actually emitted into the
debug information and we called that. The test itself was broken as it didn't
use the libc++ directory structure (the /v1/ directory was just called /include/).

This patch gives myabs a default argument which we can't get from debug information
and inlines the function to make sure we can't call it from LLDB without loading
the C++ module.

llvm-svn: 374335

4 years ago[AArch64][x86] add tests for (v)select bit magic; NFC
Sanjay Patel [Thu, 10 Oct 2019 12:53:24 +0000 (12:53 +0000)]
[AArch64][x86] add tests for (v)select bit magic; NFC

llvm-svn: 374334

4 years ago[Sanitizers] Fix getrandom test
David Carlier [Thu, 10 Oct 2019 12:48:18 +0000 (12:48 +0000)]
[Sanitizers] Fix getrandom test

llvm-svn: 374333

4 years agoMake nullptr check more robust
Rui Ueyama [Thu, 10 Oct 2019 12:41:08 +0000 (12:41 +0000)]
Make nullptr check more robust

The only condition that isecLoc becomes null is

  Out::bufferStart == nullptr,
  isec->getParent()->offset == 0, and
  isec->outSecOff == 0.

We can check the first condition only once.

llvm-svn: 374332

4 years agoFile: Handle more cases in GetOptionsFromMode
Pavel Labath [Thu, 10 Oct 2019 12:40:27 +0000 (12:40 +0000)]
File: Handle more cases in GetOptionsFromMode

The "b" (binary) flag is meaningless most of the time, but the relevant
standars allow it. The standards permit one to spell it both as "r+b"
and "rb+", so handle both cases.

This fixes TestFileHandle.test_binary_inout with python2.

llvm-svn: 374331

4 years ago[Alignment][NFC] Make VectorUtils uas llvm::Align
Guillaume Chatelet [Thu, 10 Oct 2019 12:35:04 +0000 (12:35 +0000)]
[Alignment][NFC] Make VectorUtils uas llvm::Align

Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: hiraditya, rogfer01, llvm-commits

Tags: #llvm

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

llvm-svn: 374330

4 years ago[lld] getErrPlace(): don't perform arithmetics on maybe-null pointer
Roman Lebedev [Thu, 10 Oct 2019 12:22:55 +0000 (12:22 +0000)]
[lld] getErrPlace(): don't perform arithmetics on maybe-null pointer

isecLoc there can be null, but at the same time isec->getSize() may
be non-null. It is UB to offset a nullptr.The most straight-forward fix
here appears to perform casts+normal integral arithmetics.

FAIL: lld :: ELF/invalid/invalid-relocation-aarch64.test (1158 of 2217)
******************** TEST 'lld :: ELF/invalid/invalid-relocation-aarch64.test' FAILED ********************
Script:
--
: 'RUN: at line 2';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/yaml2obj /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/test/ELF/invalid/invalid-relocation-aarch64.test -o /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/lld/test/ELF/invalid/Output/invalid-relocation-aarch64.test.tmp.o
: 'RUN: at line 3';   not /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld.lld /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/lld/test/ELF/invalid/Output/invalid-relocation-aarch64.test.tmp.o -o /dev/null 2>&1 | /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/test/ELF/invalid/invalid-relocation-aarch64.test
--
Exit Code: 1

Command Output (stderr):
--
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/test/ELF/invalid/invalid-relocation-aarch64.test:4:10: error: CHECK: expected string not found in input
# CHECK: error: unknown relocation (1024) against symbol foo
         ^
<stdin>:1:1: note: scanning from here
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/ELF/Target.cpp:100:41: runtime error: applying non-zero offset 24 to null pointer
^
<stdin>:1:118: note: possible intended match here
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/ELF/Target.cpp:100:41: runtime error: applying non-zero offset 24 to null pointer
                                                                                                                     ^

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.
FAIL: lld :: ELF/invalid/invalid-relocation-x64.test (1270 of 2217)
******************** TEST 'lld :: ELF/invalid/invalid-relocation-x64.test' FAILED ********************
Script:
--
: 'RUN: at line 2';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/yaml2obj /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/test/ELF/invalid/invalid-relocation-x64.test -o /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/lld/test/ELF/invalid/Output/invalid-relocation-x64.test.tmp1.o
: 'RUN: at line 3';   echo ".global foo; foo:" > /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/lld/test/ELF/invalid/Output/invalid-relocation-x64.test.tmp2.s
: 'RUN: at line 4';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/llvm-mc /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/lld/test/ELF/invalid/Output/invalid-relocation-x64.test.tmp2.s -o /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/lld/test/ELF/invalid/Output/invalid-relocation-x64.test.tmp2.o -filetype=obj -triple x86_64-pc-linux
: 'RUN: at line 5';   not /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld.lld /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/lld/test/ELF/invalid/Output/invalid-relocation-x64.test.tmp1.o /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/lld/test/ELF/invalid/Output/invalid-relocation-x64.test.tmp2.o -o /dev/null 2>&1 | /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/test/ELF/invalid/invalid-relocation-x64.test
--
Exit Code: 1

Command Output (stderr):
--
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/test/ELF/invalid/invalid-relocation-x64.test:6:10: error: CHECK: expected string not found in input
# CHECK: error: unknown relocation (152) against symbol foo
         ^
<stdin>:1:1: note: scanning from here
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/ELF/Target.cpp:100:41: runtime error: applying non-zero offset 24 to null pointer
^
<stdin>:1:118: note: possible intended match here
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/ELF/Target.cpp:100:41: runtime error: applying non-zero offset 24 to null pointer
                                                                                                                     ^

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
Testing Time: 20.73s
********************
Failing Tests (2):
    lld :: ELF/invalid/invalid-relocation-aarch64.test
    lld :: ELF/invalid/invalid-relocation-x64.test

llvm-svn: 374329

4 years ago[AST] ASTReader::ReadSLocEntry(): move computation of FirstDecl into the branch where...
Roman Lebedev [Thu, 10 Oct 2019 12:22:42 +0000 (12:22 +0000)]
[AST] ASTReader::ReadSLocEntry(): move computation of FirstDecl into the branch where it's used

The existing code is not defined, you are not allowed
to produce non-null pointer from null pointer (F->FileSortedDecls here).
That being said, i'm not really confident this is fix-enough, but we'll see.

FAIL: Clang :: Modules/no-module-map.cpp (6879 of 16079)
******************** TEST 'Clang :: Modules/no-module-map.cpp' FAILED ********************
Script:
--
: 'RUN: at line 1';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/10.0.0/include -nostdsysteminc -fmodules-ts -fmodule-name=ab -x c++-header /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/Inputs/no-module-map/a.h /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/Inputs/no-module-map/b.h -emit-header-module -o /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/clang/test/Modules/Output/no-module-map.cpp.tmp.pcm
: 'RUN: at line 2';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/10.0.0/include -nostdsysteminc -fmodules-ts -fmodule-file=/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/clang/test/Modules/Output/no-module-map.cpp.tmp.pcm /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/no-module-map.cpp -I/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/Inputs/no-module-map -verify
: 'RUN: at line 3';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/10.0.0/include -nostdsysteminc -fmodules-ts -fmodule-file=/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/clang/test/Modules/Output/no-module-map.cpp.tmp.pcm /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/no-module-map.cpp -I/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/Inputs/no-module-map -verify -DA
: 'RUN: at line 4';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/10.0.0/include -nostdsysteminc -fmodules-ts -fmodule-file=/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/clang/test/Modules/Output/no-module-map.cpp.tmp.pcm /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/no-module-map.cpp -I/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/Inputs/no-module-map -verify -DB
: 'RUN: at line 5';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/10.0.0/include -nostdsysteminc -fmodules-ts -fmodule-file=/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/clang/test/Modules/Output/no-module-map.cpp.tmp.pcm /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/no-module-map.cpp -I/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/Inputs/no-module-map -verify -DA -DB
: 'RUN: at line 7';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/10.0.0/include -nostdsysteminc -E /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/clang/test/Modules/Output/no-module-map.cpp.tmp.pcm -o - | /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/no-module-map.cpp
: 'RUN: at line 8';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/10.0.0/include -nostdsysteminc -frewrite-imports -E /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/clang/test/Modules/Output/no-module-map.cpp.tmp.pcm -o - | /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/no-module-map.cpp
--
Exit Code: 2

Command Output (stderr):
--
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Serialization/ASTReader.cpp:1526:50: runtime error: applying non-zero offset 8 to null pointer
    #0 0x3a9bd0c in clang::ASTReader::ReadSLocEntry(int) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Serialization/ASTReader.cpp:1526:50
    #1 0x328b6f8 in clang::SourceManager::loadSLocEntry(unsigned int, bool*) const /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Basic/SourceManager.cpp:461:28
    #2 0x328b351 in clang::SourceManager::initializeForReplay(clang::SourceManager const&) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Basic/SourceManager.cpp:399:11
    #3 0x3996c71 in clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, clang::FrontendInputFile const&) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Frontend/FrontendAction.cpp:581:27
    #4 0x394f341 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:956:13
    #5 0x3a8a92b in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:290:25
    #6 0xaf8d62 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/tools/driver/cc1_main.cpp:250:15
    #7 0xaf1602 in ExecuteCC1Tool /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/tools/driver/driver.cpp:309:12
    #8 0xaf1602 in main /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/tools/driver/driver.cpp:382:12
    #9 0x7f2c1eecc2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #10 0xad57f9 in _start (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang-10+0xad57f9)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Serialization/ASTReader.cpp:1526:50 in
llvm-svn: 374328

4 years ago[ADR] ArrayRefTest: disable SizeTSizedOperations test - it's UB.
Roman Lebedev [Thu, 10 Oct 2019 12:22:33 +0000 (12:22 +0000)]
[ADR] ArrayRefTest: disable SizeTSizedOperations test - it's UB.

This test is not defined.

FAIL: LLVM-Unit :: ADT/./ADTTests/ArrayRefTest.SizeTSizedOperations (178 of 33926)
******************** TEST 'LLVM-Unit :: ADT/./ADTTests/ArrayRefTest.SizeTSizedOperations' FAILED ********************
Note: Google Test filter = ArrayRefTest.SizeTSizedOperations
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from ArrayRefTest
[ RUN      ] ArrayRefTest.SizeTSizedOperations
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:180:32: runtime error: applying non-zero offset 9223372036854775806 to null pointer
    #0 0x5ae8dc in llvm::ArrayRef<char>::slice(unsigned long, unsigned long) const /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:180:32
    #1 0x5ae44c in (anonymous namespace)::ArrayRefTest_SizeTSizedOperations_Test::TestBody() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/unittests/ADT/ArrayRefTest.cpp:85:3
    #2 0x928a96 in testing::Test::Run() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2474:5
    #3 0x929793 in testing::TestInfo::Run() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
    #4 0x92a152 in testing::TestCase::Run() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
    #5 0x9319d2 in testing::internal::UnitTestImpl::RunAllTests() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
    #6 0x931416 in testing::UnitTest::Run() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4257:10
    #7 0x920ac3 in RUN_ALL_TESTS /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46
    #8 0x920ac3 in main /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/UnitTestMain/TestMain.cpp:50:10
    #9 0x7f66135b72e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #10 0x472c19 in _start (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/unittests/ADT/ADTTests+0x472c19)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:180:32 in
llvm-svn: 374327

4 years agoFix -Wparentheses warning. NFCI.
Simon Pilgrim [Thu, 10 Oct 2019 12:21:52 +0000 (12:21 +0000)]
Fix -Wparentheses warning. NFCI.

llvm-svn: 374326

4 years ago[Windows] Introduce a switch for the `lldb-server` mode on Windows
Aleksandr Urakov [Thu, 10 Oct 2019 12:21:04 +0000 (12:21 +0000)]
[Windows] Introduce a switch for the `lldb-server` mode on Windows

Summary:
This patch introduces a switch, based on the environment variable
`LLDB_USE_LLDB_SERVER`, to determine whether to use the `ProcessWindows` plugin
(the old way) or the `lldb-server` way for debugging on Windows.

Reviewers: labath, amccarth, asmith, stella.stamenova

Reviewed By: labath, amccarth

Subscribers: mstorsjo, abidh, JDevlieghere, lldb-commits, leonid.mashinskiy

Tags: #lldb

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

llvm-svn: 374325

4 years agoRevert "Use -fdebug-compilation-dir to form absolute paths in coverage mappings"
Kadir Cetinkaya [Thu, 10 Oct 2019 12:20:11 +0000 (12:20 +0000)]
Revert "Use -fdebug-compilation-dir to form absolute paths in coverage mappings"

This reverts commit f6777964bde28c349d3e289ea37ecf5f5eeedbc4.

Because the absolute path check relies on temporary path containing
"clang", "test" and "CoverageMapping" as a subsequence, which is not
necessarily true on all systems(breaks internal integrates). Wanted to
fix it by checking for a leading "/" instead, but then noticed that it
would break windows tests, so leaving it to the author instead.

llvm-svn: 374324

4 years agoTestFileHandle.py: relax exception type checks
Pavel Labath [Thu, 10 Oct 2019 12:07:30 +0000 (12:07 +0000)]
TestFileHandle.py: relax exception type checks

the exceptions returned differ between swig4 (TypeError) and swig<=3
(NotImplementedError). Just check for the base Exception class instead.

Theoretically we could switch on the swig version and expect the precise
type directly, but checking the exact type does not seem that important.

Thanks to Raphael for helping me figure this out.

llvm-svn: 374322

4 years agoFix sanitizer lint check after r374315
Russell Gallop [Thu, 10 Oct 2019 12:02:31 +0000 (12:02 +0000)]
Fix sanitizer lint check after r374315

llvm-svn: 374321

4 years ago[Mips] Fix 374055
Mirko Brkusanin [Thu, 10 Oct 2019 12:02:14 +0000 (12:02 +0000)]
[Mips] Fix 374055

EXPENSIVE_CHECKS build was failing on new test.
This is fixed by marking $ra register as undef.
Test now has -verify-machineinstrs to check for operand flags.

llvm-svn: 374320

4 years ago[test] Use system locale for mri-utf8.test
Thomas Preud'homme [Thu, 10 Oct 2019 11:48:30 +0000 (11:48 +0000)]
[test] Use system locale for mri-utf8.test

Summary:
llvm-ar's mri-utf8.test test relies on the en_US.UTF-8 locale to be
installed for its last RUN line to work. If not installed, the unicode
string gets encoded (interpreted) as ascii which fails since the most
significant byte is non zero. This commit changes the test to only rely
on the system being able to encode the pound sign in its default
encoding (e.g. UTF-16 for Microsoft Windows) by always opening the file
via input/output redirection. This avoids forcing a given locale to be
present and supported. A Byte Order Mark is also added to help
recognizing the encoding of the file and its endianness.

Reviewers: gbreynoo, MaskRay, rupprecht, JamesNagurne, jfb

Subscribers: dexonsmith, llvm-commits

Tags: #llvm

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

llvm-svn: 374318

4 years ago[UBSan] Appease linter
Roman Lebedev [Thu, 10 Oct 2019 11:32:06 +0000 (11:32 +0000)]
[UBSan] Appease linter

llvm-svn: 374316

4 years ago[Sanitizers] Porting getrandom/getentropy interceptors to FreeBSD
David Carlier [Thu, 10 Oct 2019 11:31:37 +0000 (11:31 +0000)]
[Sanitizers] Porting getrandom/getentropy interceptors to FreeBSD

- Available from 12.x branch, by the time it lands next year in FreeBSD tree, the 11.x's might be EOL.
- Intentionally changed the getrandom test to C code as with 12.0 (might be fixed in CURRENT since), there is a linkage issue in C++ context.

Reviewers: emaste, dim, vitalybuka

Reviewed-By: vitalybuka
Differential Revision: https://reviews.llvm.org/D68451

llvm-svn: 374315

4 years ago[COFF] Wrap definitions in namespace lld { namespace coff {. NFC
Fangrui Song [Thu, 10 Oct 2019 11:27:58 +0000 (11:27 +0000)]
[COFF] Wrap definitions in namespace lld { namespace coff {. NFC

Similar to D67323, but for COFF. Many lld/COFF/ files already use
`namespace lld { namespace coff {`. Only a few need changing.

Reviewed By: ruiu

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

llvm-svn: 374314

4 years ago[lldb][NFC] Remove strange bool parameter from Searcher::SearchCallback
Raphael Isemann [Thu, 10 Oct 2019 11:26:51 +0000 (11:26 +0000)]
[lldb][NFC] Remove strange bool parameter from Searcher::SearchCallback

Summary:
The SearchCallback has a bool parameter that we always set to false, we never use in any callback implementation and that also changes its name
from one file to the other (either `containing` and `complete`). It was added in the original LLDB check in, so there isn't any history what
this was supposed to be, so let's just remove it.

Reviewers: jingham, JDevlieghere, labath

Reviewed By: jingham, labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374313

4 years ago[lldb] Fix out of bounds read in DataExtractor::GetCStr and add unit test that function.
Raphael Isemann [Thu, 10 Oct 2019 11:15:38 +0000 (11:15 +0000)]
[lldb] Fix out of bounds read in DataExtractor::GetCStr and add unit test that function.

Summary:
The `if (*cstr_end == '\0')` in the previous code checked if the previous loop terminated because it
found a null terminator or because it reached the end of the data. However, in the case that we hit
the end of the data before finding a null terminator, `cstr_end` points behind the last byte in our
data and `*cstr_end` reads the memory behind the array (which may be uninitialised)

This patch just rewrites that function use `std::find` and adds the relevant unit tests.

Reviewers: labath

Reviewed By: labath

Subscribers: abidh, JDevlieghere, lldb-commits

Tags: #lldb

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

llvm-svn: 374311

4 years ago[UBSan] Split nullptr-and-nonzero-offset-variable.c in another direction
Roman Lebedev [Thu, 10 Oct 2019 11:03:41 +0000 (11:03 +0000)]
[UBSan] Split nullptr-and-nonzero-offset-variable.c in another direction

llvm-svn: 374309

4 years agoRevert "[ASan] Do not misrepresent high value address dereferences as null dereferences"
Russell Gallop [Thu, 10 Oct 2019 10:56:52 +0000 (10:56 +0000)]
Revert "[ASan] Do not misrepresent high value address dereferences as null dereferences"

As it was breaking bots running sanitizer lint check

This reverts r374265 (git b577efe4567f1f6a711ad36e1d17280dd1c4f009)

llvm-svn: 374308

4 years ago[lldb][NFC] Use llvm::all_of instead of std::all_of in CppModuleConfiguration
Raphael Isemann [Thu, 10 Oct 2019 10:56:12 +0000 (10:56 +0000)]
[lldb][NFC] Use llvm::all_of instead of std::all_of in CppModuleConfiguration

llvm-svn: 374307

4 years ago[UBSan] Split nullptr-and-nonzero-offset-variable.cpp into C and C++ variants
Roman Lebedev [Thu, 10 Oct 2019 10:41:42 +0000 (10:41 +0000)]
[UBSan] Split nullptr-and-nonzero-offset-variable.cpp into C and C++ variants

I do not understand the BB failire, it fully passes locally.

llvm-svn: 374306

4 years ago[IfCvt][ARM] Optimise diamond if-conversion for code size
Oliver Stannard [Thu, 10 Oct 2019 09:58:28 +0000 (09:58 +0000)]
[IfCvt][ARM] Optimise diamond if-conversion for code size

Currently, the heuristics the if-conversion pass uses for diamond if-conversion
are based on execution time, with no consideration for code size. This adds a
new set of heuristics to be used when optimising for code size.

This is mostly target-independent, because the if-conversion pass can
see the code size of the instructions which it is removing. For thumb,
there are a few passes (insertion of IT instructions, selection of
narrow branches, and selection of CBZ instructions) which are run after
if conversion and affect these heuristics, so I've added target hooks to
better predict the code-size effect of a proposed if-conversion.

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

llvm-svn: 374301

4 years agos/@expectedFailure/@expectedFailureAll in TestFileHandle
Pavel Labath [Thu, 10 Oct 2019 09:52:32 +0000 (09:52 +0000)]
s/@expectedFailure/@expectedFailureAll in TestFileHandle

The test isn't using @expectedFailure correctly, which causes weird
errors, at least with python2, at least with linux. Possibly that
function shouldn't even be public as it's main use is as a backed for
other decorators.

llvm-svn: 374299

4 years ago[UBSan] Revisit nullptr-and-nonzero-offset-variable.cpp test to hopefully make it...
Roman Lebedev [Thu, 10 Oct 2019 09:51:13 +0000 (09:51 +0000)]
[UBSan] Revisit nullptr-and-nonzero-offset-variable.cpp test to hopefully make it pass on sanitizer-windows BB

llvm-svn: 374298

4 years agoUse error instead of fatal to report usage errors
Rui Ueyama [Thu, 10 Oct 2019 09:46:41 +0000 (09:46 +0000)]
Use error instead of fatal to report usage errors

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

llvm-svn: 374297

4 years agoRemove rest of time-trace message as it is inconsistent style
Russell Gallop [Thu, 10 Oct 2019 09:33:53 +0000 (09:33 +0000)]
Remove rest of time-trace message as it is inconsistent style

Other options which create output files don't produce output messages.
Improve documentation to help find trace file.

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

llvm-svn: 374294

4 years ago[UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour
Roman Lebedev [Thu, 10 Oct 2019 09:25:02 +0000 (09:25 +0000)]
[UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour

Summary:
Quote from http://eel.is/c++draft/expr.add#4:
```
4     When an expression J that has integral type is added to or subtracted
      from an expression P of pointer type, the result has the type of P.
(4.1) If P evaluates to a null pointer value and J evaluates to 0,
      the result is a null pointer value.
(4.2) Otherwise, if P points to an array element i of an array object x with n
      elements ([dcl.array]), the expressions P + J and J + P
      (where J has the value j) point to the (possibly-hypothetical) array
      element i+j of x if 0≤i+j≤n and the expression P - J points to the
      (possibly-hypothetical) array element i−j of x if 0≤i−j≤n.
(4.3) Otherwise, the behavior is undefined.
```

Therefore, as per the standard, applying non-zero offset to `nullptr`
(or making non-`nullptr` a `nullptr`, by subtracting pointer's integral value
from the pointer itself) is undefined behavior. (*if* `nullptr` is not defined,
i.e. e.g. `-fno-delete-null-pointer-checks` was *not* specified.)

To make things more fun, in C (6.5.6p8), applying *any* offset to null pointer
is undefined, although Clang front-end pessimizes the code by not lowering
that info, so this UB is "harmless".

Since rL369789 (D66608 `[InstCombine] icmp eq/ne (gep inbounds P, Idx..), null -> icmp eq/ne P, null`)
LLVM middle-end uses those guarantees for transformations.
If the source contains such UB's, said code may now be miscompiled.
Such miscompilations were already observed:
* https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190826/687838.html
* https://github.com/google/filament/pull/1566

Surprisingly, UBSan does not catch those issues
... until now. This diff teaches UBSan about these UB's.

`getelementpointer inbounds` is a pretty frequent instruction,
so this does have a measurable impact on performance;
I've addressed most of the obvious missing folds (and thus decreased the performance impact by ~5%),
and then re-performed some performance measurements using my [[ https://github.com/darktable-org/rawspeed | RawSpeed ]] benchmark:
(all measurements done with LLVM ToT, the sanitizer never fired.)
* no sanitization vs. existing check: average `+21.62%` slowdown
* existing check vs. check after this patch: average `22.04%` slowdown
* no sanitization vs. this patch: average `48.42%` slowdown

Reviewers: vsk, filcab, rsmith, aaron.ballman, vitalybuka, rjmccall, #sanitizers

Reviewed By: rsmith

Subscribers: kristof.beyls, nickdesaulniers, nikic, ychen, dtzWill, xbolva00, dberris, arphaman, rupprecht, reames, regehr, llvm-commits, cfe-commits

Tags: #clang, #sanitizers, #llvm

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

llvm-svn: 374293

4 years ago[LLD] [MinGW] Look for other library patterns with -l
Martin Storsjo [Thu, 10 Oct 2019 08:52:39 +0000 (08:52 +0000)]
[LLD] [MinGW] Look for other library patterns with -l

GNU ld looks for a number of other patterns than just lib<name>.dll.a
and lib<name>.a.

GNU ld does support linking directly against a DLL without using an
import library. If that's the only match for a -l argument, point out
that the user needs to use an import library, instead of leaving the
user with a puzzling message about the -l argument not being found
at all.

Also convert an existing case of fatal() into error().

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

llvm-svn: 374292