platform/upstream/llvm.git
3 years agoAdd support for firmware/standalone LC_NOTE "main bin spec" corefiles
Jason Molenda [Fri, 25 Sep 2020 21:08:44 +0000 (14:08 -0700)]
Add support for firmware/standalone LC_NOTE "main bin spec" corefiles

When a Mach-O corefile has an LC_NOTE "main bin spec" for a
standalone binary / firmware, with only a UUID and no load
address, try to locate the binary and dSYM by UUID and if
found, load it at offset 0 for the user.

Add a test case that tests a firmware/standalone corefile
with both the "kern ver str" and "main bin spec" LC_NOTEs.

<rdar://problem/68193804>

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

3 years ago[lsan] Add interceptor for pthread_detach.
Marco Vanotti [Fri, 25 Sep 2020 21:17:22 +0000 (14:17 -0700)]
[lsan] Add interceptor for pthread_detach.

This commit adds an interceptor for the pthread_detach function,
calling into ThreadRegistry::DetachThread, allowing for thread contexts
to be reused.

Without this change, programs may fail when they create more than 8K
threads.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=47389

Reviewed By: vitalybuka

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

3 years agoRevert "[IRSim] Adding basic implementation of llvm-sim."
Andrew Litteken [Fri, 25 Sep 2020 21:18:48 +0000 (16:18 -0500)]
Revert "[IRSim] Adding basic implementation of llvm-sim."

This reverts commit 15645d044bcfe2a0f63156048b302f997a717688.

3 years agoFix copy+paste typo in doxygen parameter name to fix Wdocumentation. NFCI.
Simon Pilgrim [Fri, 25 Sep 2020 21:09:51 +0000 (22:09 +0100)]
Fix copy+paste typo in doxygen parameter name to fix Wdocumentation. NFCI.

3 years ago[InstCombine] matchRotate - support (uniform) constant rotation amounts (PR46895)
Simon Pilgrim [Fri, 25 Sep 2020 21:03:10 +0000 (22:03 +0100)]
[InstCombine] matchRotate - support (uniform) constant rotation amounts (PR46895)

This patch adds handling of rotation patterns with constant shift amounts - the next bit will be how we want to support non-uniform constant vectors.

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

3 years ago[InstCombine] Fix test name to match type. NFCI.
Simon Pilgrim [Fri, 25 Sep 2020 21:00:19 +0000 (22:00 +0100)]
[InstCombine] Fix test name to match type. NFCI.

We're testing a <2 x i36> not <2 x i16>

3 years ago[IRSim] Adding basic implementation of llvm-sim.
Andrew Litteken [Thu, 17 Sep 2020 20:43:40 +0000 (15:43 -0500)]
[IRSim] Adding basic implementation of llvm-sim.

This is a similarity visualization tool that accepts a Module and
passes it to the IRSimilarityIdentifier.  The resulting SimilarityGroups
are output in a JSON file.

Tests are found in test/tools/llvm-sim and check for the file not found,
a bad module, and that the JSON is created correctly.

Reviewers: paquette, jroelofs

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

3 years ago[InstCombine] collectBitParts - add fshl/fshr handling
Simon Pilgrim [Fri, 25 Sep 2020 19:34:44 +0000 (20:34 +0100)]
[InstCombine] collectBitParts - add fshl/fshr handling

Pulled from D87452, this is a fixed version of the collectBitParts fshl/fshr handling which as @nikic noticed wasn't checking for different providers or had correct bit ordering (which was hid by only testing shift amounts of bitwidth/2).

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

3 years ago[LoopReroll][NewPM] Port -loop-reroll to NPM
Arthur Eubanks [Sat, 19 Sep 2020 00:25:40 +0000 (17:25 -0700)]
[LoopReroll][NewPM] Port -loop-reroll to NPM

Reviewed By: asbirlea

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

3 years agoAdd a verifier check that rejects non-distinct DISubprogram function
Adrian Prantl [Thu, 24 Sep 2020 23:59:36 +0000 (16:59 -0700)]
Add a verifier check that rejects non-distinct DISubprogram function
attachments. They would crash the backend, which expects all
DISubprograms that are not part of the type system to have a unit field.

Clang right before https://reviews.llvm.org/D79967 would generate this
kind of broken IR.

rdar://problem/69534688

Thanks to Fangrui for fixing an assembler test I had missed!

https://reviews.llvm.org/D88270

3 years ago[lldb] Pass reference instead of pointer in protected SBAddress methods.
Jonas Devlieghere [Fri, 25 Sep 2020 18:15:44 +0000 (11:15 -0700)]
[lldb] Pass reference instead of pointer in protected SBAddress methods.

Every call to the protected SBAddress constructor and the SetAddress
method takes the address of a valid object which means we might as well
pass it as a const reference instead of a pointer and drop the null
check.

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

3 years ago[WebAssembly] Check features before making SjLj vars thread-local
Thomas Lively [Fri, 25 Sep 2020 18:45:16 +0000 (11:45 -0700)]
[WebAssembly] Check features before making SjLj vars thread-local

1c5a3c4d3823 updated the variables inserted by Emscripten SjLj lowering to be
thread-local, depending on the CoalesceFeaturesAndStripAtomics pass to downgrade
them to normal globals if the target features did not support TLS. However, this
had the unintended side effect of preventing all non-TLS-supporting objects from
being linked into modules with shared memory, because stripping TLS marks an
object as thread-unsafe. This patch fixes the problem by only making the SjLj
lowering variables thread-local if the target machine supports TLS so that it
never introduces new usage of TLS that will be stripped. Since SjLj lowering
works on Modules instead of Functions, this required that the
WebAssemblyTargetMachine have its feature string updated to reflect the
coalesced features collected from all the functions so that a
WebAssemblySubtarget can be created without using any particular function.

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

3 years ago[Coroutine] Split PHI Nodes in `cleanuppad` blocks in a way that obeys EH pad rules
Daniel Paoliello [Fri, 25 Sep 2020 18:26:40 +0000 (11:26 -0700)]
[Coroutine] Split PHI Nodes in `cleanuppad` blocks in a way that obeys EH pad rules

Issue Details:
In order to support coroutine splitting, any multi-value PHI node in a coroutine is split into multiple blocks with single-value PHI Nodes, which then allows a subsequent transform to generate `reload` instructions as required (i.e., to reload the value if required if the coroutine has been resumed). This causes issues with EH pads (`catchswitch` and `catchpad`) as all pads within a `catchswitch` must have the same unwind destination, but the coroutine splitting logic may modify them to each have a unique unwind destination if there is a PHI node in the unwind `cleanuppad` that is set from values in the `catchswitch` and `cleanuppad` blocks.

Fix Details:
During splitting, if such a PHI node is detected, then create a "dispatcher" `cleanuppad` as well as the blocks with single-value PHI Nodes: thus the "dispatcher" is the unwind destination and it will detect which predecessor called it and then branch to the appropriate single-value PHI node block, which will then branch back to the original `cleanuppad` block.

Reviewed By: GorNishanov, lxfind

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

3 years ago[lld-macho] Ignore a few more undocumented flags
Jez Ng [Wed, 12 Aug 2020 23:57:55 +0000 (16:57 -0700)]
[lld-macho] Ignore a few more undocumented flags

Reviewed By: #lld-macho, compnerd

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

3 years ago[lld-macho] Always include custom syslibroot when running tests
Jez Ng [Sat, 19 Sep 2020 04:40:12 +0000 (21:40 -0700)]
[lld-macho] Always include custom syslibroot when running tests

This greatly reduces the amount of boilerplate in our tests.

Reviewed By: #lld-macho, compnerd

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

3 years ago[lld-macho] Support absolute symbols
Jez Ng [Fri, 18 Sep 2020 15:40:46 +0000 (08:40 -0700)]
[lld-macho] Support absolute symbols

They operate like Defined symbols but with no associated InputSection.

Note that `ld64` seems to treat the weak definition flag like a no-op for
absolute symbols, so I have replicated that behavior.

Reviewed By: #lld-macho, smeenai

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

3 years ago[lld-macho] Allow the entry symbol to be dynamically bound
Jez Ng [Thu, 17 Sep 2020 17:20:16 +0000 (10:20 -0700)]
[lld-macho] Allow the entry symbol to be dynamically bound

Apparently this is used in real programs. I've handled this by reusing
the logic we already have for branch (function call) relocations.

Reviewed By: #lld-macho, smeenai

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

3 years ago[lld-macho] Support -bundle
Jez Ng [Tue, 1 Sep 2020 06:23:37 +0000 (23:23 -0700)]
[lld-macho] Support -bundle

Not 100% sure but it appears that bundles are almost identical to
dylibs, aside from the fact that they do not contain `LC_ID_DYLIB`. ld64's code
seems to treat bundles and dylibs identically in most places.

Supporting bundles allows us to run e.g. XCTests, as all test suites are
compiled into bundles which get dynamically loaded by the `xctest` test runner.

Reviewed By: #lld-macho, smeenai

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

3 years ago[lld-macho] Implement support for PIC
Jez Ng [Sat, 5 Sep 2020 17:55:33 +0000 (10:55 -0700)]
[lld-macho] Implement support for PIC

* Implement rebase opcodes. Rebase opcodes tell dyld where absolute
  addresses have been encoded in the binary. If the binary is not loaded
  at its preferred address, dyld has to rebase these addresses by adding
  an offset to them.
* Support `-pie` and use it to test rebase opcodes.

This is necessary for absolute address references in dylibs, bundles etc
to work.

Reviewed By: #lld-macho, gkm

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

3 years ago[NFC] Fix comment for DataOp
clementval [Fri, 25 Sep 2020 18:27:23 +0000 (14:27 -0400)]
[NFC] Fix comment for DataOp

3 years ago[flang][OpenMP] Place the insertion point to the start of the block
Sourabh Singh Tomar [Fri, 25 Sep 2020 18:25:43 +0000 (23:55 +0530)]
[flang][OpenMP] Place the insertion point to the start of the block

After skeleton of the `Parallel Op` is created set the insertion point to start of the block. So that later `CodeGen` can proceed.

Note: This patch reflects the work that can be upstreamed from PR(merged)
PR: https://github.com/flang-compiler/f18-llvm-project/pull/424

Reviewed By: schweitz, kiranchandramohan

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

3 years agoOpaquePtr: Add type to sret attribute
Matt Arsenault [Wed, 23 Sep 2020 17:06:59 +0000 (13:06 -0400)]
OpaquePtr: Add type to sret attribute

Make the corresponding change that was made for byval in
b7141207a483d39b99c2b4da4eb3bb591eca9e1a. Like byval, this requires a
bulk update of the test IR tests to include the type before this can
be mandatory.

3 years ago[SCEV] Add support for `x != 0` to CollectCondition.
Florian Hahn [Fri, 25 Sep 2020 09:01:31 +0000 (10:01 +0100)]
[SCEV] Add support for `x != 0` to CollectCondition.

Add support for NE predicates with 0 constants. Those can be translated
to UMaxExpr(x, 1).

3 years ago[SCEV] Add another test using info from loop guards for BTC with NE.
Florian Hahn [Fri, 25 Sep 2020 17:51:12 +0000 (18:51 +0100)]
[SCEV] Add another test using info from loop guards for BTC with NE.

3 years agoMove PassBuilder::registerParseTopLevelPipelineCallback out-of-line
Hans Wennborg [Fri, 25 Sep 2020 17:49:15 +0000 (19:49 +0200)]
Move PassBuilder::registerParseTopLevelPipelineCallback out-of-line

For some mysterious reason it doesn't build with clang-cl when compiled
as part of the includes in clang's CodeGenAction.cpp
(crbug.com/1132292).

3 years agoRevert "Add a verifier check that rejects non-distinct DISubprogram function"
Adrian Prantl [Fri, 25 Sep 2020 17:51:54 +0000 (10:51 -0700)]
Revert "Add a verifier check that rejects non-distinct DISubprogram function"

This reverts commit e17f52d623cc146b7d9bf5a2e02965043508b4c4.

while investigating bot breakage.

3 years agoAArch64/GlobalISel: Narrow stack passed argument access size
Matt Arsenault [Fri, 25 Sep 2020 14:26:36 +0000 (10:26 -0400)]
AArch64/GlobalISel: Narrow stack passed argument access size

This fixes a verifier error in the testcase from bug 47619.

The stack passed s3 value was widened to 4-bytes, and producing a
4-byte memory access with a < 1 byte result type. We need to either
widen the result type or narrow the access size. This copies the code
directly from the AMDGPU handling, which narrows the load size. I
don't like that every target has to handle this, but this is currently
broken on the 11 release branch and this is the simplest fix.

This reverts commit 42bfa7c63b85e76fe16521d1671afcafaf8f64ed.

3 years ago[MLIR] Fix for updating function signature in normalizing memrefs
Haruki Imai [Fri, 25 Sep 2020 17:19:23 +0000 (22:49 +0530)]
[MLIR] Fix for updating function signature in normalizing memrefs

Normalizing memrefs failed when a caller of symbolic use in a function
can not be casted to `CallOp`. This patch avoids the failure by checking
the result of the casting. If the caller can not be casted to `CallOp`,
it is skipped.

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

3 years agoFix Assembler/disubprogram.ll after e17f52d623cc146b7d9bf5a2e02965043508b4c4
Fangrui Song [Fri, 25 Sep 2020 17:26:35 +0000 (10:26 -0700)]
Fix Assembler/disubprogram.ll after e17f52d623cc146b7d9bf5a2e02965043508b4c4

3 years ago[PowerPC] Add accumulator register class and instructions
Baptiste Saleil [Fri, 25 Sep 2020 16:30:38 +0000 (11:30 -0500)]
[PowerPC] Add accumulator register class and instructions

This patch adds the xxmfacc, xxmtacc and xxsetaccz instructions to manipulate
accumulator registers. It also adds the ACC register class definition for the
accumulator registers.

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

3 years agoFix DISubprogram-v4.ll after e17f52d623cc146b7d9bf5a2e02965043508b4c4
Fangrui Song [Fri, 25 Sep 2020 17:08:24 +0000 (10:08 -0700)]
Fix DISubprogram-v4.ll after e17f52d623cc146b7d9bf5a2e02965043508b4c4

3 years agoSema: remove unnecessary parameter for SwiftName handling (NFCI)
Saleem Abdulrasool [Thu, 24 Sep 2020 21:44:14 +0000 (21:44 +0000)]
Sema: remove unnecessary parameter for SwiftName handling (NFCI)

This code never actually did anything in the implementation.

`mergeDeclAttribute` is declared as `static`, and referenced exactly
once in the file: from `Sema::mergeDeclAttributes`.

`Sema::mergeDeclAttributes` sets `LocalAMK` to `AMK_None`.  If the
attribute is `DeprecatedAttr`, `UnavailableAttr`, or `AvailabilityAttr`
then the `LocalAMK` is updated.  However, because we are dealing with a
`SwiftNameDeclAttr` here, `LocalAMK` remains `AMK_None`.  This is then
passed to the function which will as a result pass the value of
`AMK_None == AMK_Override` aka `false`.  Simply propagate the value
through and erase the dead codepath.

Thanks to Aaron Ballman for flagging the use of the availability merge
kind here leading to this simplification!

Differential Revision: https://reviews.llvm.org/D88263
Reviewed By: Aaron Ballman

3 years ago[AArch64][GlobalISel] Add selection support for <8 x s16> G_INSERT_VECTOR_ELT with...
Amara Emerson [Fri, 25 Sep 2020 16:49:27 +0000 (09:49 -0700)]
[AArch64][GlobalISel] Add selection support for <8 x s16>  G_INSERT_VECTOR_ELT with GPR scalar.

Fixes the neon intrinsics test in the test suite.

3 years ago[profile] Add %t LLVM_PROFILE_FILE option to substitute $TMPDIR
Vedant Kumar [Tue, 8 Sep 2020 21:45:41 +0000 (14:45 -0700)]
[profile] Add %t LLVM_PROFILE_FILE option to substitute $TMPDIR

Add support for expanding the %t filename specifier in LLVM_PROFILE_FILE
to the TMPDIR environment variable. This is supported on all platforms.

On Darwin, TMPDIR is used to specify a temporary application-specific
scratch directory. When testing apps on remote devices, it can be
challenging for the host device to determine the correct TMPDIR, so it's
helpful to have the runtime do this work.

rdar://68524185

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

3 years ago[NFC] Fix build warnings
Rahul Joshi [Fri, 25 Sep 2020 16:35:41 +0000 (09:35 -0700)]
[NFC] Fix build warnings

3 years ago[SCEV] Add support for `x == constant` to CollectCondition.
Florian Hahn [Thu, 24 Sep 2020 20:57:14 +0000 (21:57 +0100)]
[SCEV] Add support for `x == constant` to CollectCondition.

Add support for EQ predicates with constant operand. In that case, using
the constant instead of an unknown expression should always be
beneficial.

3 years ago[SystemZ] Optimize bcmp calls (PR47420)
Dávid Bolvanský [Fri, 25 Sep 2020 15:54:21 +0000 (17:54 +0200)]
[SystemZ] Optimize bcmp calls (PR47420)

Solves https://bugs.llvm.org/show_bug.cgi?id=47420

Reviewed By: uweigand

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

3 years ago[CMake] Make sure _cmake_system_name has a default
David Tenty [Fri, 21 Aug 2020 16:47:12 +0000 (12:47 -0400)]
[CMake] Make sure _cmake_system_name has a default

We currently try to pick it up from the CMake arguments passed to llvm_ExternalProject_Add but
if there isn't an explicit option passed, we should reflect CMake's own default behaviour
of targeting the host, since we'll make decisions about what tools to use for the build based on
the setting. Otherwise, we'll get different behaviour between configuring an external project with
the default target and configuring with an explicit one targeting the same platform.

Reviewed By: stevewan, hubert.reinterpretcast

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

3 years ago[libc++][ci] Don't require passing --token to phabricator-report
Louis Dionne [Fri, 25 Sep 2020 14:49:18 +0000 (10:49 -0400)]
[libc++][ci] Don't require passing --token to phabricator-report

The CONDUIT_TOKEN is already taken from the environment. Also, disable
reporting back to Phabricator for now until we're ready to start spamming
the results back. This still needs a bit of testing.

3 years ago[NFC] Fix syntax of ranked memrefs in the MLIR Language Reference.
Rahul Joshi [Wed, 23 Sep 2020 17:57:09 +0000 (10:57 -0700)]
[NFC] Fix syntax of ranked memrefs in the MLIR Language Reference.

- Eliminate incorrect |
- Eliminate memspace0 as the memory spaces currently are integer literals and memory
  space 0 is not explicitly printed.

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

3 years ago[NFC] Fix minor typos in comments and reuse concreteOp.
Rahul Joshi [Thu, 24 Sep 2020 16:47:02 +0000 (09:47 -0700)]
[NFC] Fix minor typos in comments and reuse concreteOp.

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

3 years agoAdd a verifier check that rejects non-distinct DISubprogram function
Adrian Prantl [Thu, 24 Sep 2020 23:59:36 +0000 (16:59 -0700)]
Add a verifier check that rejects non-distinct DISubprogram function
attachments. They would crash the backend, which expects all
DISubprograms that are not part of the type system to have a unit field.

Clang right before https://reviews.llvm.org/D79967 would generate this
kind of broken IR.

rdar://problem/69534688

3 years ago[SVE] Revert accidental change from 405e22fbe8719cff6c40eec15c2044f42527f116
Cameron McInally [Fri, 25 Sep 2020 15:11:10 +0000 (10:11 -0500)]
[SVE] Revert accidental change from 405e22fbe8719cff6c40eec15c2044f42527f116

Accidentally commited two lines that were not intended. Remove those.

3 years ago[SVE] Lower fixed length VECREDUCE_[SMAX|SMIN] to Scalable
Cameron McInally [Fri, 25 Sep 2020 14:30:51 +0000 (09:30 -0500)]
[SVE] Lower fixed length VECREDUCE_[SMAX|SMIN] to Scalable

This patch is pretty similar to the VECREDUCE_ADD patch, with some minor tweaks.

Results from the AArch64ISD::[SMAX|SMIN]V_PRED return element sized results. This requires an ANY_EXTEND for results < 32-bits, since Legalization promotes those results.

There is no NEON i64 vector support for SMAXV|SMINV, so use SVE for those.

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

3 years ago[AIX] Try to not use LLVM tools while building runtimes
David Tenty [Tue, 11 Aug 2020 14:27:41 +0000 (10:27 -0400)]
[AIX] Try to not use LLVM tools while building runtimes

Since 64-bit XCOFF and the big AR format is not yet supported in some of these tools, this patch avoids additional setup of these tools. This patch is not intended to prevent picking up the LLVM tools if they happen to be available otherwise.

Reviewed By: hubert.reinterpretcast

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

3 years ago[SCEV] Swap operands if LHS is not unknown.
Florian Hahn [Thu, 24 Sep 2020 20:38:08 +0000 (21:38 +0100)]
[SCEV] Swap operands if LHS is not unknown.

Currently we only use information from guards for unknown expressions.
Swap LHS/RHS and predicate, if LHS is not unknown.

3 years ago[PowerPC][NFC] Merged two switch entries.
Stefan Pintilie [Fri, 25 Sep 2020 14:47:08 +0000 (09:47 -0500)]
[PowerPC][NFC] Merged two switch entries.

Two switch entries did exactly the same thing. This patch merges them.

3 years ago[InstCombine] Add some extra bswap tests from PR39793
Simon Pilgrim [Fri, 25 Sep 2020 14:45:53 +0000 (15:45 +0100)]
[InstCombine] Add some extra bswap tests from PR39793

Also test for cases where recognizeBSwapOrBitReverseIdiom checks for a truncated bswap pattern.

3 years agoFix some of the more egregious 80-col and whitespace issues; NFC
Aaron Ballman [Fri, 25 Sep 2020 14:36:45 +0000 (10:36 -0400)]
Fix some of the more egregious 80-col and whitespace issues; NFC

3 years ago[InstCombine] Add 'partial' bswap tests from PR39793
Simon Pilgrim [Fri, 25 Sep 2020 14:28:01 +0000 (15:28 +0100)]
[InstCombine] Add 'partial' bswap tests from PR39793

Tests for basic zext(bswap(trunc(x))) patterns shown on PR39793

3 years agoTypo fix; NFC
Aaron Ballman [Fri, 25 Sep 2020 14:25:17 +0000 (10:25 -0400)]
Typo fix; NFC

3 years ago[SCEV] Extract code to collect conditions to lambda (NFC).
Florian Hahn [Thu, 24 Sep 2020 17:01:55 +0000 (18:01 +0100)]
[SCEV] Extract code to collect conditions to lambda (NFC).

This makes re-using the common functionality easier in follow-up
patches.

3 years ago[libc++] Initial support for pre-commit CI with Buildkite
Louis Dionne [Wed, 23 Sep 2020 13:20:03 +0000 (09:20 -0400)]
[libc++] Initial support for pre-commit CI with Buildkite

This commit adds basic files and scripts that are used for the Buildkite
pre-commit CI setup. This was tested to mostly work on a fork of llvm-project,
however some adjustments will have to be made as we complete the real
setup.

3 years ago[SCEV] Add more tests using info from loop guards for BTC.
Florian Hahn [Fri, 25 Sep 2020 12:53:58 +0000 (13:53 +0100)]
[SCEV] Add more tests using info from loop guards for BTC.

3 years ago[gn build] Port e336b74c995
LLVM GN Syncbot [Fri, 25 Sep 2020 12:13:19 +0000 (12:13 +0000)]
[gn build] Port e336b74c995

3 years ago[Analyzer] Fix unused variable warning in Release builds
Benjamin Kramer [Fri, 25 Sep 2020 12:08:45 +0000 (14:08 +0200)]
[Analyzer] Fix unused variable warning in Release builds

clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:377:19: warning: unused variable 'Init'

3 years ago[clang-format] Add a MacroExpander.
Manuel Klimek [Tue, 7 Jul 2020 10:17:14 +0000 (12:17 +0200)]
[clang-format] Add a MacroExpander.

Summary:
The MacroExpander allows to expand simple (non-resursive) macro
definitions from a macro identifier token and macro arguments. It
annotates the tokens with a newly introduced MacroContext that keeps
track of the role a token played in expanding the macro in order to
be able to reconstruct the macro expansion from an expanded (formatted)
token stream.

Made Token explicitly copy-able to enable copying tokens from the parsed
macro definition.

Reviewers: sammccall

Subscribers: mgorny, cfe-commits

Tags: #clang

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

3 years ago[mlir] [VectorOps] generalize printing support for integers
Aart Bik [Fri, 25 Sep 2020 10:32:05 +0000 (03:32 -0700)]
[mlir] [VectorOps] generalize printing support for integers

This generalizes printing beyond just i1,i32,i64 and also accounts
for signed and unsigned interpretation in the output.

Reviewed By: nicolasvasilache

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

3 years ago[PPC] [AIX] Implement calling convention IR for C99 complex types on AIX
Chris Bowler [Fri, 25 Sep 2020 11:36:49 +0000 (07:36 -0400)]
[PPC] [AIX] Implement calling convention IR for C99 complex types on AIX

Add AIX calling convention logic to Clang for C99 complex types on AIX

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

3 years ago[InstCombine] Add bswap tests from funnel shift intrinsics
Simon Pilgrim [Fri, 25 Sep 2020 11:32:08 +0000 (12:32 +0100)]
[InstCombine] Add bswap tests from funnel shift intrinsics

Based on (WIP) patch in D87452 - I'm intending to add the intrinsics handling to collectBitParts as a separate patch to make the changes clearer.

3 years ago[PowerPC][LLD] Extend R2 save stub to support offsets of more than 26 bits
Stefan Pintilie [Tue, 22 Sep 2020 23:44:54 +0000 (18:44 -0500)]
[PowerPC][LLD] Extend R2 save stub to support offsets of more than 26 bits

The R2 save stub will now support offsets up to 64 bits.

There are three cases that will be used.
1) The offset fits in 26 bits.
```
b <26 bit offset>
```
2) The offset does not fit in 26 bits but fits in 34 bits.
```
paddi r12, 0, <34 bit offset>, 1
mtctr r12
bctr
```
3) The offset does not fit in 34 bits. Since this is an R2 save stub we can use
the TOC in R2. We are not loading the offset but the actual address we want to
branch to.
```
addis r12, r2, <address in TOC lo>
ld r12 <address in TOC hi>(r12)
mtctr r12
bctr
```

In case 1) the stub is only 8 bytes while in cases 2) and 3) the stub will be
20 bytes.

Reviewed By: MaskRay, sfertile, NeHuang

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

3 years ago[CMake][CTE] Add "check-clang-extra-..." targets to test only a particular Clang...
Whisperity [Fri, 25 Sep 2020 11:32:56 +0000 (13:32 +0200)]
[CMake][CTE] Add "check-clang-extra-..." targets to test only a particular Clang extra tool

Create targets `check-clang-extra-clang-tidy`, `check-clang-extra-clang-query`
similar to how `check-clang-sema`, `check-clang-parser`, etc. are
auto-generated from the directory structure.

This allows running only a particular sub-tool's tests, not having to wait
through the entire `check-clang-tools` execution.

Differential Revision: http://reviews.llvm.org/D84176

3 years ago[Analyzer] Fix for `ExprEngine::computeObjectUnderConstruction()` for base and delega...
Adam Balogh [Wed, 5 Aug 2020 19:38:15 +0000 (21:38 +0200)]
[Analyzer] Fix for `ExprEngine::computeObjectUnderConstruction()` for base and delegating consturctor initializers

For /C++/ constructor initializers `ExprEngine:computeUnderConstruction()`
asserts that they are all member initializers. This is not neccessarily
true when this function is used to get the return value for the
construction context thus attempts to fetch return values of base and
delegating constructor initializers result in assertions. This small
patch fixes this issue.

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

3 years ago[AArch64] PAC/BTI code generation for LLVM generated functions
Momchil Velikov [Fri, 25 Sep 2020 10:45:22 +0000 (11:45 +0100)]
[AArch64] PAC/BTI code generation for LLVM generated functions

PAC/BTI-related codegen in the AArch64 backend is controlled by a set
of LLVM IR function attributes, added to the function by Clang, based
on command-line options and GCC-style function attributes. However,
functions, generated in the LLVM middle end (for example,
asan.module.ctor or __llvm_gcov_write_out) do not get any attributes
and the backend incorrectly does not do any PAC/BTI code generation.

This patch record the default state of PAC/BTI codegen in a set of
LLVM IR module-level attributes, based on command-line options:

* "sign-return-address", with non-zero value means generate code to
  sign return addresses (PAC-RET), zero value means disable PAC-RET.

* "sign-return-address-all", with non-zero value means enable PAC-RET
  for all functions, zero value means enable PAC-RET only for
  functions, which spill LR.

* "sign-return-address-with-bkey", with non-zero value means use B-key
  for signing, zero value mean use A-key.

This set of attributes are always added for AArch64 targets (as
opposed, for example, to interpreting a missing attribute as having a
value 0) in order to be able to check for conflicts when combining
module attributed during LTO.

Module-level attributes are overridden by function level attributes.
All the decision making about whether to not to generate PAC and/or
BTI code is factored out into AArch64FunctionInfo, there shouldn't be
any places left, other than AArch64FunctionInfo, which directly
examine PAC/BTI attributes, except AArch64AsmPrinter.cpp, which
is/will-be handled by a separate patch.

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

3 years ago[AMDGPU] Fix declaration parameter names to match definition
Jay Foad [Fri, 25 Sep 2020 10:38:17 +0000 (11:38 +0100)]
[AMDGPU] Fix declaration parameter names to match definition

This fixes the declaration of AMDGPULegalizerInfo::legalizeBufferLoad to
match the definition. It is still confusing that that parameter order is
different from legalizeBufferStore.

https://bugs.llvm.org/show_bug.cgi?id=47535

3 years ago[SplitKit] In addDeadDef tolerate parent range that defines more lanes
Jay Foad [Mon, 21 Sep 2020 11:32:13 +0000 (12:32 +0100)]
[SplitKit] In addDeadDef tolerate parent range that defines more lanes

Following on from D87757 "[SplitKit] Only copy live lanes", in
SplitEditor::addDeadDef, when we're checking whether the parent live
interval has a subrange defining the same lanes, tolerate the case
where the parent subrange defines a superset of the lanes. This can
happen when the child subrange comes from SplitEditor::buildCopy
decomposing a partial copy into a sequence of subreg copies that cover
the required lanes.

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

3 years agoRevert rGe55410f8b260 : "AArch64/GlobalISel: Add testcase for bug 47619"
Simon Pilgrim [Fri, 25 Sep 2020 10:31:14 +0000 (11:31 +0100)]
Revert rGe55410f8b260 : "AArch64/GlobalISel: Add testcase for bug 47619"

This reverts commit e55410f8b260a2868d600ca99fe5ee80f9cd4fc5.

This is failing on EXPENSIVE_CHECKS buildbots

3 years ago[msan] Remove redundant test
Vitaly Buka [Fri, 25 Sep 2020 09:20:33 +0000 (02:20 -0700)]
[msan] Remove redundant test

The test needs to control intercept_strcmp option.
It's already implemented as lit.test strcmp.c.

3 years ago[msan] Fix gethostent tests
Vitaly Buka [Fri, 25 Sep 2020 08:28:23 +0000 (01:28 -0700)]
[msan] Fix gethostent tests

gethostent should follow sethostent.

3 years ago[Object/yaml2obj/obj2yaml][test] - Split, cleanup and move MIPS abi-flags.yaml test...
Georgii Rymar [Thu, 24 Sep 2020 14:39:11 +0000 (17:39 +0300)]
[Object/yaml2obj/obj2yaml][test] - Split, cleanup and move MIPS abi-flags.yaml test. NFCI.

We have the `Object/Mips/abi-flags.yaml` which tests how yaml2obj/obj2yaml
handle `SHT_MIPS_ABIFLAGS` sections.

This patch splits it into two tests: one for obj2yaml and one for yaml2obj
and moves the result to right places.

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

3 years ago[AArch64][GlobalISel] Manually select G_DUP with s8/s16 gpr scalar operands.
Amara Emerson [Fri, 25 Sep 2020 08:28:50 +0000 (01:28 -0700)]
[AArch64][GlobalISel] Manually select G_DUP with s8/s16 gpr scalar operands.

These don't get selected by the imported patterns, and avoiding generating them
is a whole load of not-worth-it-hassle (until we have fp types in GlobalISel).

3 years ago[AArch64][GlobalISel] Make <8 x s16> for G_INSERT_VECTOR_ELT legal.
Amara Emerson [Thu, 24 Sep 2020 20:06:03 +0000 (13:06 -0700)]
[AArch64][GlobalISel] Make <8 x s16> for G_INSERT_VECTOR_ELT legal.

3 years ago[flang][driver] Add missing dependency (shared library builds, NFC)
Andrzej Warzynski [Fri, 25 Sep 2020 08:52:49 +0000 (09:52 +0100)]
[flang][driver] Add missing dependency (shared library builds, NFC)

`FlangFrontendTests` depends on libclangFrontend (it uses
DiagnosticConsumer classes from there). This patch adds the missing
dependency in CMake.

The missing dependency manifests itself only with BUILD_SHARED_LIBS=ON.
This symbol is linked in statically with libflangFrontend when
BUILD_SHARED_LIBS=OFF.

3 years ago[ARM] Find VPT implicitly predicated by VCTP
Sam Parker [Tue, 22 Sep 2020 09:43:18 +0000 (10:43 +0100)]
[ARM] Find VPT implicitly predicated by VCTP

On failing to find a VCTP in the list of instructions that explicitly
predicate the entry of a VPT block, inspect whether the block is
controlled via VPT which is implicitly predicated due to it's
predicated operand(s).

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

3 years ago[mlir][SCFToGPU] LaunchOp propagate optional attributes
Artur Bialas [Fri, 25 Sep 2020 07:21:16 +0000 (09:21 +0200)]
[mlir][SCFToGPU] LaunchOp propagate optional attributes

Allow propagating optional user defined attributes during SCF to GPU conversion. Gives opportunity to use user defined attributes in the further lowering. For example setting subgroup size, or other options for GPU dispatch. This does not break backward compatibility and does not require new attributes, just allow passing optional ones.

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

3 years ago[libc] Using llvm_libc memcpy in mem* benchmarks.
Anthony Steinhauser [Fri, 25 Sep 2020 05:03:52 +0000 (22:03 -0700)]
[libc] Using llvm_libc memcpy in mem* benchmarks.

Currently the mem* benchmarks use memcpy from Glibc and memset from LLVM libc.
That's misleading and produces inconsistent results and behaviors.

This change makes Memcpy.cpp consistent with Memset.cpp:
https://github.com/llvm/llvm-project/blob/master/libc/benchmarks/Memset.cpp#L49

Reviewers: sivachandra

Reviewed By: sivachandra

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

3 years agoFix uninitialized XRayArg
Ian Levesque [Fri, 25 Sep 2020 04:20:14 +0000 (00:20 -0400)]
Fix uninitialized XRayArg

3 years ago[lld][WebAssembly] Allow `atomics` feature with unshared memory
Thomas Lively [Fri, 25 Sep 2020 03:35:29 +0000 (20:35 -0700)]
[lld][WebAssembly] Allow `atomics` feature with unshared memory

 https://github.com/WebAssembly/threads/issues/144 updated the
WebAssembly threads proposal to make atomic operations on unshared memories
valid. This change updates the feature checking in the linker accordingly.
Production WebAssembly engines have recently been updated to allow this
behvaior, but after this change users who accidentally use atomics with unshared
memories on older versions of the engines will get validation errors at runtime
rather than link errors.

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

3 years ago[NFC] [PPC] Add PowerPC expected IR tests for C99 complex
Chris Bowler [Thu, 24 Sep 2020 23:06:56 +0000 (19:06 -0400)]
[NFC] [PPC] Add PowerPC expected IR tests for C99 complex

Adding this test so that I can extend it in a follow on patch with
expected IR for AIX when I implement complex handling in
AIXABIInfo.

Reviewed By: daltenty, ZarkoCA

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

3 years ago[xray] Function coverage groups
Ian Levesque [Fri, 18 Sep 2020 18:45:51 +0000 (14:45 -0400)]
[xray] Function coverage groups

Add the ability to selectively instrument a subset of functions by dividing the functions into N logical groups and then selecting a group to cover. By selecting different groups over time you could cover the entire application incrementally with lower overhead than instrumenting the entire application at once.

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

3 years agoPR47176: Don't read from an inactive union member if a friend function
Richard Smith [Fri, 25 Sep 2020 01:07:05 +0000 (18:07 -0700)]
PR47176: Don't read from an inactive union member if a friend function
has default arguments and an exception specification.

3 years agoHint how to get a symbolized stack trace if llvm-symbolizer is not found on crashes
Mehdi Amini [Fri, 25 Sep 2020 01:50:40 +0000 (01:50 +0000)]
Hint how to get a symbolized stack trace if llvm-symbolizer is not found on crashes

Most users of LLVM tools hit the raw traces and don't know how to get LLVM to
symbolize automatically for them.

When we print the non-symbolized stack trace, we will add information about
how to get it symbolized.

Reviewed By: MaskRay

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

3 years ago[Hexagon] Avoid crash on CONCAT_VECTORS with illegal element types
Krzysztof Parzyszek [Fri, 25 Sep 2020 00:00:15 +0000 (19:00 -0500)]
[Hexagon] Avoid crash on CONCAT_VECTORS with illegal element types

Legal vector element types may not be legal as scalar types. When
CONCAT_VECTORS is converted to BUILD_VECTOR, the individual vector
elements become standalone operands to the build operation. If they
have illegal (scalar) types, they need to be made legal. In doing
so, the case of TRUNCATE was not handled, causing an assertion to
fail.

3 years ago[lld] Clean up in lld::{coff,elf}::link after D70378
Fangrui Song [Fri, 25 Sep 2020 01:01:26 +0000 (18:01 -0700)]
[lld] Clean up in lld::{coff,elf}::link after D70378

Library users should not need to call errorHandler().reset() explicitly.

google/iree calls lld::elf::link and without the patch some global
variables are not cleaned up in the next invocation.

3 years ago[ValueTracking] Make isGuaranteedNotToBeUndefOrPoison exit early when MetadataAsValue...
Juneyoung Lee [Fri, 25 Sep 2020 00:49:13 +0000 (09:49 +0900)]
[ValueTracking] Make isGuaranteedNotToBeUndefOrPoison exit early when MetadataAsValue is given

It is set to conservatively return false, otherwise noundef attributes are added to function calls with metadata arguments.

3 years ago[ValueTracking] Check uses of Argument if it is given to isGuaranteedNotToBeUndefOrPoison
Juneyoung Lee [Thu, 24 Sep 2020 09:52:30 +0000 (18:52 +0900)]
[ValueTracking] Check uses of Argument if it is given to isGuaranteedNotToBeUndefOrPoison

This is a patch that allows isGuaranteedNotToBeUndefOrPoison to return more precise result
when an argument is given, by looking through its uses at the entry block (and following blocks as well, if it is checking poison only).

This is useful when there is a function call with noundef arguments at the entry block.

Reviewed By: nikic

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

3 years agoRevert "[NFCI][IR] ConstantRangeTest: add basic scaffolding for next-gen precision...
Reid Kleckner [Thu, 24 Sep 2020 23:47:15 +0000 (16:47 -0700)]
Revert "[NFCI][IR] ConstantRangeTest: add basic scaffolding for next-gen precision/correctness testing"

This reverts commit 9bcf7b1c7a139a455400df109d81c638b9e75150.

Breaks build with MSVC.

3 years agoRevert "Add a static_assert confirming that DiagnosticBuilder is small"
Reid Kleckner [Thu, 24 Sep 2020 23:39:46 +0000 (16:39 -0700)]
Revert "Add a static_assert confirming that DiagnosticBuilder is small"

This reverts commit a32feed0dbeac7606d042d0d7e041c9eaf12cd51.

This assert doesn't hold in 32-bit builds, I didn't do the math right.

3 years agoAdd a static_assert confirming that DiagnosticBuilder is small
Reid Kleckner [Thu, 24 Sep 2020 23:38:07 +0000 (16:38 -0700)]
Add a static_assert confirming that DiagnosticBuilder is small

3 years ago[intel-pt] Refactor the JSON parsing
Walter Erquinigo [Thu, 24 Sep 2020 20:39:21 +0000 (13:39 -0700)]
[intel-pt] Refactor the JSON parsing

Recently https://reviews.llvm.org/D88103 introduced a nice API for
converting a JSON object into C++ types, which include nice error
messaging.

I'm using that new functioniality to perform the parsing in a much more
elegant way. As a result, the code looks simpler and more maintainable,
as we aren't parsing anymore individual fields manually.

I updated the test cases accordingly.

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

3 years ago[MS] For unknown ISAs, pass non-trivially copyable arguments indirectly
Reid Kleckner [Thu, 24 Sep 2020 21:11:06 +0000 (14:11 -0700)]
[MS] For unknown ISAs, pass non-trivially copyable arguments indirectly

Passing them directly is likely to be non-conforming, since it usually
involves copying the bytes of the record. For unknown architectures, we
don't know what MSVC does or will do, but we should at least try to
conform as well as we can.

3 years ago[MS] Simplify rules for passing C++ records
Reid Kleckner [Thu, 24 Sep 2020 20:42:41 +0000 (13:42 -0700)]
[MS] Simplify rules for passing C++ records

Regardless of the target architecture, we should always use the C rules
(RAA_Default) for records that "canBePassedInRegisters". Those are
trivially copyable things, and things marked with [[trivial_abi]].

This should be NFC, although it changes where the final decision about
x86_32 overaligned records is made. The current x86_32 C rules say that
overaligned things are passed indirectly, so there is no functional
difference.

3 years ago[AMDGPU] Fixes typo in the test. NFC.
Stanislav Mekhanoshin [Thu, 24 Sep 2020 23:07:15 +0000 (16:07 -0700)]
[AMDGPU] Fixes typo in the test. NFC.

denormal-fp-math-fp32 -> denormal-fp-math-f32

3 years ago[RISCV] Merge the pipeline models for Rocket
Evandro Menezes [Thu, 17 Sep 2020 23:20:50 +0000 (18:20 -0500)]
[RISCV] Merge the pipeline models for Rocket

Merge the 32 and 64 bit pipeline models for Rocket into a single file.

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

3 years ago[llvm] Add -bbsections-cold-text-prefix to emit cold clusters to a different section.
Snehasish Kumar [Thu, 17 Sep 2020 04:40:00 +0000 (21:40 -0700)]
[llvm] Add -bbsections-cold-text-prefix to emit cold clusters to a different section.

This change adds an option to basic block sections to allow cold
clusters to be assigned a custom text prefix. With a custom prefix such
as ".text.split." (D87840), lld can place them in a separate output section.
The benefits are -

* Empirically shown to improve icache and itlb metrics by 3-5%
(absolute) compared to placing split parts in .text.unlikely.
* Mitigates against poor profiles, eg samplePGO profiles used with the
machine function splitter. Optimizations such as hugepage remapping can
make different decisions at the section granularity.
* Enables section granularity hotness monitoring (checking on the
decisions made during compilation vs sample data from production).

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

3 years ago[OpenMP] OpenMPOpt Support for Globalization Remarks
Joseph Huber [Thu, 24 Sep 2020 16:49:58 +0000 (12:49 -0400)]
[OpenMP] OpenMPOpt Support for Globalization Remarks

Summary:
This patch add support for printing analysis messages relating to data
globalization on the GPU. This occurs when data is shared between the
threads in a GPU context and must be pushed to global or shared memory.

Reviewers: jdoerfert

Subscribers: guansong hiraditya llvm-commits ormris sstefan1 yaxunl

Tags: #OpenMP #LLVM

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

3 years agoFix regex in test.
Bill Wendling [Thu, 24 Sep 2020 22:20:47 +0000 (15:20 -0700)]
Fix regex in test.

3 years ago[lld] Make -z keep-text-section-prefix recognize .text.split. as a prefix.
Snehasish Kumar [Thu, 17 Sep 2020 17:04:03 +0000 (10:04 -0700)]
[lld] Make -z keep-text-section-prefix recognize .text.split. as a prefix.

".text.split." holds symbols which are split out from functions in
other input sections. For example, with -fsplit-machine-functions,
placing the cold parts in .text.split instead of .text.unlikely mitigates
against poor profile inaccuracy. Techniques such as hugepage remapping can
make conservative decisions at the section granularity.

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

3 years ago[lld-macho][re-land] Implement and test resolution of common symbols
Jez Ng [Thu, 24 Sep 2020 22:00:56 +0000 (15:00 -0700)]
[lld-macho][re-land] Implement and test resolution of common symbols

Earlier build break fixed in c32e69b2ce7abfb151a87ba363ac9e25abf7d417.

This reverts commit c367f93e8539c4d0bcdc86ad7ea7923e06231a93.

3 years ago[lld-macho][re-land] Initial support for common symbols
Jez Ng [Thu, 24 Sep 2020 21:44:14 +0000 (14:44 -0700)]
[lld-macho][re-land] Initial support for common symbols

Fix earlier build break via a static_cast.

This reverts commit 8112d494d344dc0935d5c078f066a43d7c984e0c.

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