platform/upstream/llvm.git
3 years ago[mlir][spirv] Relax restriction on pointer type for CooperativeMatrix load/store
Thomas Raoux [Fri, 31 Jul 2020 15:02:21 +0000 (08:02 -0700)]
[mlir][spirv] Relax restriction on pointer type for CooperativeMatrix load/store

This change allow CooperativeMatrix Load/Store operations to use pointer type
that may not match the matrix element type. This allow us to declare buffer
with a larger type size than the matrix element type. This follows SPIR-V spec
and this is needed to be able to use cooperative matrix in combination with
shared local memory efficiently.

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

3 years ago[flang] Add -h as a synonym for help
Richard Barton [Sat, 18 Jul 2020 13:22:18 +0000 (14:22 +0100)]
[flang] Add -h as a synonym for help

As expected by user in http://lists.llvm.org/pipermail/flang-dev/2020-June/000404.html

Depends on D84856

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

3 years ago[flang] Add details to --help screen on default behaviour
Richard Barton [Thu, 25 Jun 2020 15:01:56 +0000 (16:01 +0100)]
[flang] Add details to --help screen on default behaviour

Add a usage string and a defaults section that clarifies:
 * If no input files are given, f18 reads from stdin
 * If no input files are given, f18 dumps the parse tree.
 * The default behaviour is to exec F18_FC.
 * The fefault F18_FC setting is 'gfortran'

Adds a simple regression test which tests the top and tail of the help
screen and the exit status.

Depends on D84855

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

3 years ago[flang] Make interactive behaviour more obvious
Richard Barton [Fri, 17 Jul 2020 08:15:21 +0000 (09:15 +0100)]
[flang] Make interactive behaviour more obvious

When flang is invoked with no files it waits for input on stdin. Make it
print a message saying this to prevent the user being surprised.

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

3 years agoSupport addrspacecast initializers with isNoopAddrSpaceCast
Matt Arsenault [Fri, 27 May 2016 22:50:12 +0000 (15:50 -0700)]
Support addrspacecast initializers with isNoopAddrSpaceCast

Moves isNoopAddrSpaceCast to the TargetMachine. It logically belongs
with the DataLayout.

3 years ago[MLIR][Shape] Allow unsafe `shape.broadcast`
Frederik Gossen [Fri, 31 Jul 2020 14:17:31 +0000 (14:17 +0000)]
[MLIR][Shape] Allow unsafe `shape.broadcast`

In a context in which `shape.broadcast` is known not to produce an error value,
we want it to operate solely on extent tensors. The operation's behavior is
then undefined in the error case as the result type cannot hold this value.

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

3 years ago[gn build] (manually) merge 63d3aeb529
Nico Weber [Fri, 31 Jul 2020 13:54:39 +0000 (09:54 -0400)]
[gn build] (manually) merge 63d3aeb529

3 years ago[MLIR,OpenMP][NFCI] Removed loop for accessing regions of ParallelOp
Sourabh Singh Tomar [Fri, 31 Jul 2020 13:22:12 +0000 (18:52 +0530)]
[MLIR,OpenMP][NFCI] Removed loop for accessing regions of ParallelOp

`ParallelOp` has only one region associated with it.

Reviewed By: kiranchandramohan, ftynse

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

3 years agoDR2303: Prefer 'nearer' base classes during template deduction.
Erich Keane [Fri, 17 Jul 2020 16:48:01 +0000 (09:48 -0700)]
DR2303: Prefer 'nearer' base classes during template deduction.

DR2303 fixes the case where the derived-base match for template
deduction is ambiguous if a base-of-base ALSO matches. The canonical
example (as shown in the test) is just like the MSVC implementation of
std::tuple.

This fixes a fairly sizable issue, where if a user inherits from
std::tuple on Windows (with the MS STL), they cannot use that type to
call a function that takes std::tuple.

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

3 years ago[clangd] Be more explicit on testing the optional DefLoc in LocatedSymbol.
Haojian Wu [Fri, 31 Jul 2020 12:32:18 +0000 (14:32 +0200)]
[clangd] Be more explicit on testing the optional DefLoc in LocatedSymbol.

And also fix a bug where we may return a meaningless location.

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

3 years ago[clang-tidy] Fix build problem after commit 45a720a864320bbbeb596a
Bjorn Pettersson [Fri, 31 Jul 2020 12:28:49 +0000 (14:28 +0200)]
[clang-tidy] Fix build problem after commit 45a720a864320bbbeb596a

When building with LLVM8.0 on RHEL7.8 I got failures like this
after commit 45a720a864320bbbe:

/app/llvm/8.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/
5.4.0/../../../../include/c++/5.4.0/ext/new_allocator.h:120:23:
error: no matching constructor for initialization of
'std::pair<std::__cxx11::basic_string<char>,
std::__cxx11::basic_string<char> >'
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }

...

../../clang-tools-extra/clang-tidy/ClangTidyOptions.cpp:73:15:
note: in instantiation of function template specialization
'std::vector<std::pair<std::__cxx11::basic_string<char>,
std::__cxx11::basic_string<char> >,
std::allocator<std::pair<std::__cxx11::basic_string<char>,
std::__cxx11::basic_string<char> > > >::emplace_back<llvm::StringRef,
const std::__cxx11::basic_string<char> &>' requested here
Options.emplace_back(KeyValue.getKey(), KeyValue.getValue().Value);

This is an attempt to avoid such build problems.

3 years ago[DWARFYAML] Make the debug_aranges entry optional.
Xing GUO [Fri, 31 Jul 2020 04:56:10 +0000 (12:56 +0800)]
[DWARFYAML] Make the debug_aranges entry optional.

This patch makes the 'debug_aranges' entry optional. If the entry is
empty, yaml2obj will only emit the header for it.

Reviewed By: jhenderson

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

3 years ago[DWARFYAML] Add helper function getDWARFEmitterByName(). NFC.
Xing GUO [Fri, 31 Jul 2020 12:06:30 +0000 (20:06 +0800)]
[DWARFYAML] Add helper function getDWARFEmitterByName(). NFC.

In this patch, we add a helper function getDWARFEmitterByName(). This
function returns the proper DWARF section emitting method by the name.

Reviewed By: jhenderson

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

3 years ago[DWARFYAML] Add emitDebug[GNU]Pub[names/types] functions. NFC.
Xing GUO [Fri, 31 Jul 2020 12:02:20 +0000 (20:02 +0800)]
[DWARFYAML] Add emitDebug[GNU]Pub[names/types] functions. NFC.

In this patch, emitDebugPubnames(), emitDebugPubtypes(),
emitDebugGNUPubnames(), emitDebugGNUPubtypes() are added.

Reviewed By: jhenderson

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

3 years ago[clangd] Fix remote index build on macOS
Kirill Bobyrev [Fri, 31 Jul 2020 12:02:19 +0000 (14:02 +0200)]
[clangd] Fix remote index build on macOS

macOS builds suddenly started failing:

https://github.com/kirillbobyrev/indexing-tools/runs/925090879

This patch makes use of imported libraries and fixes builds for macOS.

Landing this without a review since the patch is quite straightforward
and I've been testing it on my local macOS machine for a while.

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

3 years ago[Sanitizers] Fix lint failure with Python 3.6
Nemanja Ivanovic [Fri, 31 Jul 2020 11:19:47 +0000 (06:19 -0500)]
[Sanitizers] Fix lint failure with Python 3.6

There are some files in compiler-rt that use UTF-8 characters in some of the
comments. This causes lint failures with some versions of Python. This patch
just makes the encoding explicit in the call to open.

3 years ago[mlir][Linalg] Conv {1,2,3}D ops defined with TC syntax
Jakub Lichman [Fri, 31 Jul 2020 11:18:11 +0000 (13:18 +0200)]
[mlir][Linalg] Conv {1,2,3}D ops defined with TC syntax

Replaced definition of named ND ConvOps with tensor comprehension
syntax which reduces boilerplate code significantly. Furthermore,
new ops to support TF convolutions added (without strides and dilations).

Reviewed By: nicolasvasilache

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

3 years ago[OpenMP] Use weak attribute in interface only for static library
Joachim Protze [Thu, 30 Jul 2020 07:28:17 +0000 (09:28 +0200)]
[OpenMP] Use weak attribute in interface only for static library

This is to address the issue reported at:
https://bugs.llvm.org/show_bug.cgi?id=46863

Since weak is meaningless for a shared library interface function, this patch
disables the attribute, when the OpenMP library is built as shared library.

ompt_start_tool is not an interface function, but a internally called function
possibly implemented by an OMPT tool.
This function needs to be weak if possible to allow overwriting ompt_start_tool
with a function implementation built into the application.

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

3 years ago[clang][Syntax] syntax::Arena doesnt own TokenBuffer
Kadir Cetinkaya [Thu, 30 Jul 2020 19:38:40 +0000 (21:38 +0200)]
[clang][Syntax] syntax::Arena doesnt own TokenBuffer

Currently an Arena can only be built while consuming a TokenBuffer,
some users (like clangd) might want to share a TokenBuffer with multiple
compenents. This patch changes Arena's TokenBuffer member to be a reference so
that it can be created with read-only token buffers.

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

3 years ago[clangd] Propagate remote index errors via Expected
Kirill Bobyrev [Fri, 31 Jul 2020 09:48:27 +0000 (11:48 +0200)]
[clangd] Propagate remote index errors via Expected

This is a refactoring: errors should be logged only on the highest level.
Switch from Optional to Expected in the serialization code.

Reviewed By: kadircet

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

3 years ago[NFC] Remove unused GetUnderlyingObject paramenter
Vitaly Buka [Fri, 31 Jul 2020 09:09:54 +0000 (02:09 -0700)]
[NFC] Remove unused GetUnderlyingObject paramenter

 Depends on D84617.

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

3 years ago[mlir] Add TFFramework dialect to DialectSymbolRegistry.
Alexander Belyaev [Fri, 31 Jul 2020 09:00:15 +0000 (11:00 +0200)]
[mlir] Add TFFramework dialect to DialectSymbolRegistry.

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

3 years ago[analyzer] Fix out-of-tree only clang build by not relaying on private header
Balazs Benics [Fri, 31 Jul 2020 08:28:14 +0000 (10:28 +0200)]
[analyzer] Fix out-of-tree only clang build by not relaying on private header

It turned out that the D78704 included a private LLVM header, which is excluded
from the LLVM install target.
I'm substituting that `#include` with the public one by moving the necessary
`#define` into that. There was a discussion about this at D78704 and on the
cfe-dev mailing list.

I'm also placing a note to remind others of this pitfall.

Reviewed By: mgorny

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

3 years ago[flang] Fix CMPLX folding with complex arguments
Jean Perier [Fri, 31 Jul 2020 08:25:34 +0000 (10:25 +0200)]
[flang] Fix CMPLX folding with complex arguments

CMPLX folding was expecting only one arguments in case X argument
is complex. This is wrong since there is also the optional KIND
argument.

Reviewed By: schweitz

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

3 years agoRevert "[ELF] Add --dependency-file option"
Petr Hosek [Fri, 31 Jul 2020 08:12:38 +0000 (01:12 -0700)]
Revert "[ELF] Add --dependency-file option"

This reverts commit b4c7657ba602acde1c2ea5391c973949b9c3ce09 which
seems to be breaking certain bots with assertion error.

3 years ago[PowerPC] Retrieve the offset from load/store if it stores to stack slots
QingShan Zhang [Fri, 31 Jul 2020 07:05:45 +0000 (07:05 +0000)]
[PowerPC] Retrieve the offset from load/store if it stores to stack slots

Scheduler will try to retrieve the offset and base addr to determine if two
loads/stores are disjoint memory access. PowerPC failed to handle this for
frame index which will bring extra memory dependency for loads/stores.

Reviewed By: jji

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

3 years ago[Driver] Exclude options::LinkerInput for GCC linking
Fangrui Song [Fri, 31 Jul 2020 07:04:09 +0000 (00:04 -0700)]
[Driver] Exclude options::LinkerInput for GCC linking

options::LinkerInput options may get duplicated after 6a75496836ea14bcfd2f4b59d35a1cad4ac58cee..

3 years ago[Driver] Render -e for Gnu.cpp
Fangrui Song [Fri, 31 Jul 2020 06:49:32 +0000 (23:49 -0700)]
[Driver] Render -e for Gnu.cpp

3 years ago[JumpThreading] Let SimplifyPartiallyRedundantLoad look into freeze
Juneyoung Lee [Fri, 31 Jul 2020 06:26:54 +0000 (15:26 +0900)]
[JumpThreading] Let SimplifyPartiallyRedundantLoad look into freeze

This patch allows SimplifyPartiallyRedundantLoad work when
the branch condition was frozen.

Reviewed By: efriedma

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

3 years ago[MC] Support infix operator !
Fangrui Song [Fri, 31 Jul 2020 06:24:09 +0000 (23:24 -0700)]
[MC] Support infix operator !

Disabled for Darwin mode.

Also disabled for ARM which has compatible aliases (implied 'sp' operand
in 'srs*' instructions like 'srsda #31!').

3 years ago[JumpThreading] Add a test for D84944 ; NFC
Juneyoung Lee [Fri, 31 Jul 2020 06:20:38 +0000 (15:20 +0900)]
[JumpThreading] Add a test for D84944 ; NFC

3 years ago[JITLink] Use correct Addressable constructor.
Lang Hames [Fri, 31 Jul 2020 05:46:04 +0000 (22:46 -0700)]
[JITLink] Use correct Addressable constructor.

Calling createAddressable(false) generates an absolute symbol. We want
createAddressable(0, false), which generates an external symbol.

3 years ago[X86] Remove x86_sse42_crc32_64_64 from X86TTIImpl::simplifyDemandedUseBitsIntrinsic
Craig Topper [Fri, 31 Jul 2020 04:50:17 +0000 (21:50 -0700)]
[X86] Remove x86_sse42_crc32_64_64 from X86TTIImpl::simplifyDemandedUseBitsIntrinsic

It doesn't do any simplifying. It just computes known bits. We
can just let InstCombine call computeKnownBits which will handle
this just as well.

3 years ago[SimpleLoopUnswitch] Preserve make.implicit in non-trivial unswitch if legal
Max Kazantsev [Fri, 31 Jul 2020 04:38:43 +0000 (11:38 +0700)]
[SimpleLoopUnswitch] Preserve make.implicit in non-trivial unswitch if legal

We can preserve make.implicit metadata in the split block if it is
guaranteed that after following the branch we always reach the block
where processing of null case happens, which is equivalent to
"initial condition must execute if the loop is entered".

Differential Revision: https://reviews.llvm.org/D84925
Reviewed By: asbirlea

3 years ago[SimpleLoopUnswitch] Drop make.implicit metadata in case of non-trivial unswitching
Max Kazantsev [Fri, 31 Jul 2020 04:10:00 +0000 (11:10 +0700)]
[SimpleLoopUnswitch] Drop make.implicit metadata in case of non-trivial unswitching

Non-trivial unswitching simply moves terminator being unswitch from the loop
up to the switch block. It also preserves all metadata that was there. It might not
be a correct thing to do for `make.implicit` metadata. Consider case:
```
for (...) {
  cond = // computed in loop
  if (cond) return X;
  if (p == null) throw_npe(); !make implicit
}
```
Before the unswitching, if `p` is null and we reach this check, we are guaranteed
to go to `throw_npe()` block. Now we unswitch on `p == null` condition:
```
if (p == null) !make implicit {
  for (...) {
    if (cond) return X;
    throw_npe()
  }
} else {
  for (...) {
    if (cond) return X;
  }
}
```
Now, following `true` branch of `p == null` does not always lead us to
`throw_npe()` because the loop has side exit. Now, if we run ImplicitNullCheck
pass on this code, it may end up making the unswitch condition implicit. This may
lead us to turning normal path to `return X` into signal-throwing path, which is
not efficient.

Note that this does not happen during trivial unswitch: it guarantees that we do not
have side exits before condition being unswitched.

This patch fixes this situation by unconditional dropping of `make.implicit` metadata
when we perform non-trivial unswitch. We could preserve it if we could prove that the
condition always executes. This can be done as a follow-up.

Differential Revision: https://reviews.llvm.org/D84916
Reviewed By: asbirlea

3 years agoFix a crash when the sample profile uses md5 and -sample-profile-merge-inlinee
Wei Mi [Fri, 31 Jul 2020 00:47:27 +0000 (17:47 -0700)]
Fix a crash when the sample profile uses md5 and -sample-profile-merge-inlinee
is enabled.

When -sample-profile-merge-inlinee is enabled, new FunctionSamples may be
created during profile merge without GUIDToFuncNameMap being initialized.
That will occasionally cause compiler crash. The patch fixes it.

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

3 years agodebguserver's type sniffer to only treat .app things that end in .app
Jason Molenda [Fri, 31 Jul 2020 03:55:41 +0000 (20:55 -0700)]
debguserver's type sniffer to only treat .app things that end in .app

On an iOS device, if debugserver is left to figure out how to launch
the binary provided, it looks at the filename to see if it contains
".app" and asks FrontBoard to launch it.  However, if this is actually
a command line app with the characters ".app" in the name, it would
end up trying to launch that via the FrontBoard calls even though it
needed to be launched via posix_spawn.  For instance, a command line
program called com.application.tester.

Jim suggested this patch where we only send binaries that end in ".app"
to FrontBoard.

Often debugsever is invoked with a --launch command line argument to
specify the launch method, and none of this code is hit in that
instance.

<rdar://problem/65297100>

3 years ago[NFC] GetUnderlyingObject -> getUnderlyingObject
Vitaly Buka [Fri, 31 Jul 2020 04:07:10 +0000 (21:07 -0700)]
[NFC] GetUnderlyingObject -> getUnderlyingObject

I am going to touch them in the next patch anyway

3 years agoMake a test case more flexible on Windows wrt the number of backslashes.
Wolfgang Pieb [Fri, 31 Jul 2020 03:36:31 +0000 (20:36 -0700)]
Make a test case more flexible on Windows wrt the number of backslashes.

3 years ago[test] Fix thinlto-distributed-newpm.ll
Arthur Eubanks [Fri, 31 Jul 2020 03:09:34 +0000 (20:09 -0700)]
[test] Fix thinlto-distributed-newpm.ll

Broken by https://reviews.llvm.org/D84981.

3 years ago[X86] Pass the OperandVector by reference to ParseIntelOperand and ParseRoundingMode...
Craig Topper [Fri, 31 Jul 2020 02:42:57 +0000 (19:42 -0700)]
[X86] Pass the OperandVector by reference to ParseIntelOperand and ParseRoundingMode. NFCI

Similar to what was recently done to ParseATTOperand. Make
ParseIntelOperand directly responsible for adding to the operand
vector instead of returning the operand. Return a bool for error.

Remove ErrorOperand since it is no longer used.

3 years ago[tbaa] Rename type-based-aa -> tbaa
Arthur Eubanks [Wed, 29 Jul 2020 23:44:22 +0000 (16:44 -0700)]
[tbaa] Rename type-based-aa -> tbaa

For consistency with legacy pass name.
Helps with 37 instances of "unknown pass name 'tbaa'" in check-llvm under NPM.

Reviewed By: ychen

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

3 years ago[NewPM] Don't print 'Invalidating all non-preserved analyses'
Arthur Eubanks [Thu, 30 Jul 2020 20:49:41 +0000 (13:49 -0700)]
[NewPM] Don't print 'Invalidating all non-preserved analyses'

If an analysis is actually invalidated, there's already a log statement
for that: 'Invalidating analysis: FooAnalysis'.
Otherwise the statement is not very useful.

Reviewed By: asbirlea, ychen

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

3 years ago[flang] Fixes for RESHAPE()
Peter Steinfeld [Wed, 29 Jul 2020 21:46:36 +0000 (14:46 -0700)]
[flang] Fixes for RESHAPE()

I fixed an assert caused by passing an empty array as the source= argument to
RESHAPE().  In the process, I noticed that there were no tests for RESHAPE(),
so I wrote a test that covers all the description in 16.9.163.  In the process,
I made the error messages more consistent and descriptive.  I also changed the
test to see if a reference to an intrinsic function was a constant to say that
it is a constant if it's a refererence to an invalid intrinsic.  This avoids
emitting multiple messages for the same erroneous source.

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

3 years ago[ValueTracking] Remove AllocaForValue parameter
Vitaly Buka [Fri, 31 Jul 2020 01:48:34 +0000 (18:48 -0700)]
[ValueTracking] Remove AllocaForValue parameter

findAllocaForValue uses AllocaForValue to cache resolved values.
The function is used only to resolve arguments of lifetime
intrinsic which usually are not fare for allocas. So result reuse
is likely unnoticeable.

In followup patches I'd like to replace the function with
GetUnderlyingObjects.

Depends on D84616.

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

3 years ago[OpenMP] Refactored the function `targetDataEnd`
Shilei Tian [Fri, 31 Jul 2020 01:37:01 +0000 (21:37 -0400)]
[OpenMP] Refactored the function `targetDataEnd`

Refactored the function `targetDataEnd` to make preparation of fixing
the issue of ahead-of-time target memory deallocation. This patch only
renamed `targetDataEnd` related variables and functions to conform
with LLVM code standard.

Reviewed By: ye-luo

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

3 years ago[NFC] Move findAllocaForValue into ValueTracking.h
Vitaly Buka [Fri, 31 Jul 2020 01:22:59 +0000 (18:22 -0700)]
[NFC] Move findAllocaForValue into ValueTracking.h

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

3 years ago[OpenMP] Refactored the function `target`
Shilei Tian [Fri, 31 Jul 2020 01:05:30 +0000 (21:05 -0400)]
[OpenMP] Refactored the function `target`

Refactored the function `target` to make preparation for fixing the
issue of ahead-of-time device memory deallocation.

Reviewed By: ye-luo

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

3 years ago[NFC][AMDGPU] Improve fused fmul+fadd tests.
dfukalov [Thu, 30 Jul 2020 01:12:17 +0000 (04:12 +0300)]
[NFC][AMDGPU] Improve fused fmul+fadd tests.

Reviewed By: rampitec

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

3 years ago[X86] Fix for ballooning compile times due to Load Value Injection (LVI) mitigations
Scott Constable [Fri, 31 Jul 2020 00:21:48 +0000 (17:21 -0700)]
[X86] Fix for ballooning compile times due to Load Value Injection (LVI) mitigations

Fix for the issue raised in https://github.com/rust-lang/rust/issues/74632.

The current heuristic for inserting LFENCEs uses a quadratic-time algorithm. This can apparently cause substantial compilation slowdowns for building Rust projects, where functions > 5000 LoC are apparently common.

The updated heuristic in this patch implements a linear-time algorithm. On a set of benchmarks, the slowdown factor for the generated code was comparable (2.55x geo mean for the quadratic-time heuristic, vs. 2.58x for the linear-time heuristic). Both heuristics offer the same security properties, namely, mitigating LVI.

This patch also includes some formatting fixes.

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

3 years ago[X86] Separate CPU Feature lists in X86.td between architecture features and tuning...
Craig Topper [Fri, 31 Jul 2020 00:05:06 +0000 (17:05 -0700)]
[X86] Separate CPU Feature lists in X86.td between architecture features and tuning features

After the recent change to the tuning settings for pentium4 to improve our default 32-bit behavior, I've decided to see about implementing -mtune support. This way we could have a default architecture CPU of "pentium4" or "x86-64" and a default tuning cpu of "generic". And we could change our "pentium4" tuning settings back to what they were before.

As a step to supporting this, this patch separates all of the features lists for the CPUs into 2 lists. I'm using the Proc class and a new ProcModel class to concat the 2 lists before passing to the target independent ProcessorModel. Future work to truly support mtune would change ProcessorModel to take 2 lists separately. I've diffed the X86GenSubtargetInfo.inc file before and after this patch to ensure that the final feature list for the CPUs isn't changed.

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

3 years ago[Attributor] Add time trace support.
kuterd [Thu, 30 Jul 2020 20:26:39 +0000 (23:26 +0300)]
[Attributor] Add time trace support.

This patch addes time trace functionality to have a better understanding
of the analysis times.

Reviewed By: jdoerfert

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

3 years ago[ValueTracking] Add basic computeKnownBits support for llvm.abs intrinsic
Craig Topper [Thu, 30 Jul 2020 18:25:55 +0000 (11:25 -0700)]
[ValueTracking] Add basic computeKnownBits support for llvm.abs intrinsic

This includes basic support for computeKnownBits on abs. I've left FIXMEs for more complicated things we could do.

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

3 years ago[profile] Remove dependence on getpagesize from InstrProfilingBuffer.c.o
Vedant Kumar [Thu, 30 Jul 2020 23:19:05 +0000 (16:19 -0700)]
[profile] Remove dependence on getpagesize from InstrProfilingBuffer.c.o

InstrProfilingBuffer.c.o is generic code that must support compilation
into freestanding projects. This gets rid of its dependence on the
_getpagesize symbol from libc, shifting it to InstrProfilingFile.c.o.

This fixes a build failure seen in a firmware project.

rdar://66249701

3 years ago[debugserver/Apple Silicon] Handoff connections when attaching to translated processes
Davide Italiano [Thu, 30 Jul 2020 23:20:38 +0000 (16:20 -0700)]
[debugserver/Apple Silicon] Handoff connections when attaching to translated processes

When we detect a process that the native debugserver cannot handle,
handoff the connection fd to the translated debugserver.

3 years ago[LegalizeTypes][SVE] Support widen/split legalization for SPLAT_VECTOR
Eli Friedman [Mon, 27 Jul 2020 21:08:31 +0000 (14:08 -0700)]
[LegalizeTypes][SVE] Support widen/split legalization for SPLAT_VECTOR

Just the obvious implementation that rewrites the result type. Also fix
warning from EXTRACT_SUBVECTOR legalization that triggers on the test.

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

3 years ago[AArch64][GlobalISel] Add legalization & selection support for G_INTRINSIC_LRINT.
Amara Emerson [Fri, 24 Jul 2020 20:01:36 +0000 (13:01 -0700)]
[AArch64][GlobalISel] Add legalization & selection support for G_INTRINSIC_LRINT.

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

3 years ago[doc] Describe the header guard style
Mircea Trofin [Thu, 30 Jul 2020 23:08:06 +0000 (16:08 -0700)]
[doc] Describe the header guard style

clang-tidy's llvm-header-guard rule references the LLVM style - where it's
missing.

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

3 years ago[libc] Add a tool called WrapperGen.
Siva Chandra Reddy [Wed, 29 Jul 2020 06:42:11 +0000 (23:42 -0700)]
[libc] Add a tool called WrapperGen.

This tool will be used to generate C wrappers for the C++ LLVM libc
implementations. This change does not hook this tool up to anything yet.
However, it can be useful for cases where one does not want to run the
objcopy step (to insert the C symbol in the object file) but can make use
of LTO to eliminate the cost of the additional wrapper call. This can be
relevant for certain downstream platforms. If this tool can benefit other
libc platforms in general, then it can be integrated into the build system
with options to use or not use the wrappers. An example of such a
platform is CUDA.

Reviewed By: abrachet

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

3 years ago[clang codegen][AArch64] Use llvm.aarch64.neon.fcvtzs/u where it's necessary
Eli Friedman [Mon, 27 Jul 2020 21:01:46 +0000 (14:01 -0700)]
[clang codegen][AArch64] Use llvm.aarch64.neon.fcvtzs/u where it's necessary

fptosi/fptoui have similar, but not identical, semantics.  In
particular, the behavior on overflow is different.

Fixes https://bugs.llvm.org/show_bug.cgi?id=46844 for 64-bit.  (The
corresponding patch for 32-bit is more involved because the equivalent
intrinsics don't exist, as far as I can tell.)

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

3 years ago[gn build] Port 763671f387f
LLVM GN Syncbot [Thu, 30 Jul 2020 22:29:22 +0000 (22:29 +0000)]
[gn build] Port 763671f387f

3 years ago[llvm-jitlink] Add -harness option to llvm-jitlink.
Lang Hames [Thu, 30 Jul 2020 05:55:33 +0000 (22:55 -0700)]
[llvm-jitlink] Add -harness option to llvm-jitlink.

The -harness option enables new testing use-cases for llvm-jitlink. It takes a
list of objects to treat as a test harness for any regular objects passed to
llvm-jitlink.

If any files are passed using the -harness option then the following
transformations are applied to all other files:

  (1) Symbols definitions that are referenced by the harness files are promoted
      to default scope. (This enables access to statics from test harness).

  (2) Symbols definitions that clash with definitions in the harness files are
      deleted. (This enables interposition by test harness).

  (3) All other definitions in regular files are demoted to local scope.
      (This causes untested code to be dead stripped, reducing memory cost and
      eliminating spurious unresolved symbol errors from untested code).

These transformations allow the harness files to reference and interpose
symbols in the regular object files, which can be used to support execution
tests (including fuzz tests) of functions in relocatable objects produced by a
build.

3 years ago[JITLink] Allow JITLinkContext::notifyResolved to return an Error.
Lang Hames [Thu, 30 Jul 2020 03:46:56 +0000 (20:46 -0700)]
[JITLink] Allow JITLinkContext::notifyResolved to return an Error.

This allows clients to detect invalid transformations applied by JITLink passes
(e.g. inserting or removing symbols in unexpected ways) and terminate linking
with an error.

This change is used to simplify the error propagation logic in
ObjectLinkingLayer.

3 years ago[COFF] Port CallGraphSort to COFF from ELF
Zequan Wu [Tue, 21 Jul 2020 20:46:11 +0000 (13:46 -0700)]
[COFF] Port CallGraphSort to COFF from ELF

3 years ago[MLIR][NFC] Add SymbolUse::UseRange::empty()
Rahul Joshi [Thu, 30 Jul 2020 21:18:33 +0000 (14:18 -0700)]
[MLIR][NFC] Add SymbolUse::UseRange::empty()

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

3 years agoAMDGPU: Fix liveness errors when copying AGPR tuples
Matt Arsenault [Wed, 1 Jul 2020 16:48:42 +0000 (12:48 -0400)]
AMDGPU: Fix liveness errors when copying AGPR tuples

Avoid recursively calling copyPhysReg for AGPR handling. This was
dropping the necessary super register implicit defs to avoid liveness
verifier errors.

3 years ago[mlir][spirv] Add support for converting memref of vector to SPIR-V
Thomas Raoux [Thu, 30 Jul 2020 21:56:50 +0000 (14:56 -0700)]
[mlir][spirv] Add support for converting memref of vector to SPIR-V

This allow declaring buffers and alloc of vectors so that we can support vector
load/store.

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

3 years ago[clang-tidy][NFC] Use StringMap for ClangTidyCheckFactories::FacoryMap
Nathan James [Thu, 30 Jul 2020 21:57:32 +0000 (22:57 +0100)]
[clang-tidy][NFC] Use StringMap for ClangTidyCheckFactories::FacoryMap

Reviewed By: gribozavr2

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

3 years agoPR46908: Emit undef destroying_delete_t as an aggregate RValue.
Richard Smith [Thu, 30 Jul 2020 21:17:26 +0000 (14:17 -0700)]
PR46908: Emit undef destroying_delete_t as an aggregate RValue.

We previously used a non-aggregate RValue to represent the passed value,
which violated the assumptions of call arg lowering in some cases, in
particular on 32-bit Windows, where we'd end up producing an FCA store
with TBAA metadata, that the IR verifier would reject.

3 years ago[lld-macho] Add comment for literal argument
Jez Ng [Thu, 30 Jul 2020 21:38:58 +0000 (14:38 -0700)]
[lld-macho] Add comment for literal argument

3 years agoAMDGPU: Put inexpensive ops first in AMDGPUAnnotateUniformValues::visitLoadInst
Changpeng Fang [Thu, 30 Jul 2020 21:37:06 +0000 (14:37 -0700)]
AMDGPU: Put inexpensive ops first in AMDGPUAnnotateUniformValues::visitLoadInst

Summary:
  This is in response to the review of https://reviews.llvm.org/D84873:
The expensive check should be reordered last

Reviewers:
  arsenm

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

3 years ago[lld-macho] Make __LINKEDIT sections contiguous
Jez Ng [Thu, 30 Jul 2020 21:29:14 +0000 (14:29 -0700)]
[lld-macho] Make __LINKEDIT sections contiguous

codesign (or more specifically libstuff) checks that each section in
__LINKEDIT ends where the next one starts -- no gaps are permitted. This
diff achieves it by aligning every section's start and end points to
WordSize.

Remarks: ld64 appears to satisfy the constraint by adding padding bytes
when generating the __LINKEDIT data, e.g. by emitting BIND_OPCODE_DONE
(which is a 0x0 byte) repeatedly. I think the approach this diff takes
is a bit more elegant, but I'm not sure if it's too restrictive. In
particular, it assumes padding always uses the zero byte. But we can
revisit this later.

Reviewed By: #lld-macho, compnerd

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

3 years ago[lld-macho] Implement -headerpad
Jez Ng [Thu, 30 Jul 2020 21:28:45 +0000 (14:28 -0700)]
[lld-macho] Implement -headerpad

Tools like `install_name_tool` and `codesign` may modify the Mach-O
header and increase its size. The linker has to provide padding to make this
possible. This diff does that, plus sets its default value to 32 bytes (which
is what ld64 does).

Unlike ld64, however, we lay out our sections *exactly* `-headerpad` bytes from
the header, whereas ld64 just treats the padding requirement as a lower bound.
ld64 actually starts laying out the non-header sections in the __TEXT segment
from the end of the (page-aligned) segment rather than the front, so its
binaries typically have more than `-headerpad` bytes of actual padding.
We should consider implementing the same alignment behavior.

Reviewed By: #lld-macho, compnerd

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

3 years ago[lld-macho] Support __dso_handle for C++
Jez Ng [Thu, 30 Jul 2020 21:28:41 +0000 (14:28 -0700)]
[lld-macho] Support __dso_handle for C++

The C++ ABI requires dylibs to pass a pointer to __cxa_atexit which does
e.g. cleanup of static global variables. The C++ spec says that the pointer
can point to any address in one of the dylib's segments, but in practice
ld64 seems to set it to point to the header, so that's what's implemented
here.

Reviewed By: #lld-macho, smeenai

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

3 years ago[ConstantRange][CVP] Make use of abs poison flag
Nikita Popov [Thu, 30 Jul 2020 20:54:53 +0000 (22:54 +0200)]
[ConstantRange][CVP] Make use of abs poison flag

Pass the abs poison flag to the underlying ConstantRange
implementation, allowing CVP to simplify based on it.

Importantly, this recognizes that abs with poison flag is actually
non-negative...

3 years ago[SelectionDAG] Fix lowering of vector geps
Jon Roelofs [Wed, 29 Jul 2020 19:14:17 +0000 (13:14 -0600)]
[SelectionDAG] Fix lowering of vector geps

This fixes an assertion failure that was being triggered in
SelectionDAG::getZeroExtendInReg(), where it was trying to extend the <2xi32>
to i64 (which should have been <2xi64>).

Fixes: rdar://66016901

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

3 years ago[lldb/Docs] Remove stale bot on GreenDragon and add reproducer one
Jonas Devlieghere [Thu, 30 Jul 2020 20:50:05 +0000 (13:50 -0700)]
[lldb/Docs] Remove stale bot on GreenDragon and add reproducer one

 - Remove the link to the Python 3 job which no longer exists.
 - Add a link to the reproducer job.

3 years ago[ConstantRange] Support abs with poison flag
Nikita Popov [Thu, 30 Jul 2020 20:47:33 +0000 (22:47 +0200)]
[ConstantRange] Support abs with poison flag

This just adds the ConstantRange support, including exhaustive
testing. It's not wired up to the IR intrinsic flag yet.

3 years ago[lldb/Docs] Add lldb-arm-ubuntu to the list of bots
Jonas Devlieghere [Thu, 30 Jul 2020 20:46:47 +0000 (13:46 -0700)]
[lldb/Docs] Add lldb-arm-ubuntu to the list of bots

3 years ago[compiler-rt] [profile] fix profile generate for mingw x86_64
Peiyuan Song [Thu, 30 Jul 2020 20:37:17 +0000 (23:37 +0300)]
[compiler-rt] [profile] fix profile generate for mingw x86_64

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

3 years ago[LLD] [Mingw] Don't export symbols from profile generate
Peiyuan Song [Thu, 30 Jul 2020 20:32:37 +0000 (23:32 +0300)]
[LLD] [Mingw] Don't export symbols from profile generate

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

3 years ago[ConstantRange][CVP] Compute min/max/abs intrinsic ranges
Nikita Popov [Thu, 30 Jul 2020 20:15:06 +0000 (22:15 +0200)]
[ConstantRange][CVP] Compute min/max/abs intrinsic ranges

Wire up ConstantRange::intrinsic() to the existing primitives for
min, max and abs.

The poison flag on abs is not yet taken into account.

3 years ago[CVP] Add tests for min/max/abs intrinsic comparisons (NFC)
Nikita Popov [Thu, 30 Jul 2020 20:16:11 +0000 (22:16 +0200)]
[CVP] Add tests for min/max/abs intrinsic comparisons (NFC)

3 years ago[CMake][Fuchsia] Include additional tools in the toolchain
Petr Hosek [Fri, 17 Jul 2020 02:50:34 +0000 (19:50 -0700)]
[CMake][Fuchsia] Include additional tools in the toolchain

These are needed on Windows.

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

3 years ago[flang] Fix an assert on duplicate initializations
Peter Steinfeld [Thu, 30 Jul 2020 17:51:44 +0000 (10:51 -0700)]
[flang] Fix an assert on duplicate initializations

When declaring the same variable twice with an initialization, we were failing
an internal check.  I fixed this by checking to see if the associated symbol
already had an error.

I added tests for pointer and non-pointer initialization of duplicate names.

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

3 years ago[ELF] Add --dependency-file option
Petr Hosek [Wed, 24 Jun 2020 03:00:04 +0000 (20:00 -0700)]
[ELF] Add --dependency-file option

Clang and GCC have a feature (-MD flag) to create a dependency file
in a format that build systems such as Make or Ninja can read, which
specifies all the additional inputs such .h files.

This change introduces the same functionality to lld bringing it to
feature parity with ld and gold which gained this feature recently.
See https://sourceware.org/bugzilla/show_bug.cgi?id=22843 for more
details and discussion.

The implementation corresponds to -MD -MP compiler flag where the
generated dependency file also includes phony targets which works
around the errors where the dependency is removed. This matches the
format used by ld and gold.

Fixes PR42806

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

3 years ago[SCCP] Remove dead switch cases based on range information
Nikita Popov [Sun, 19 Jul 2020 19:28:14 +0000 (21:28 +0200)]
[SCCP] Remove dead switch cases based on range information

Determine whether switch edges are feasible based on range information,
and remove non-feasible edges lateron.

This does not try to determine whether the default edge is dead,
as we'd have to determine that the range is fully covered by the
cases for that.

Another limitation here is that we don't remove dead cases that
have the same successor as a live case. I'm not handling this
because I wanted to keep the edge removal based on feasible edges
only, rather than inspecting ranges again there -- this does not
seem like a particularly useful case to handle.

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

3 years ago[lldb/Test] Use self.assertIn in TestGdbRemoteTargetXmlPacket
Jonas Devlieghere [Thu, 30 Jul 2020 18:47:55 +0000 (11:47 -0700)]
[lldb/Test] Use self.assertIn in TestGdbRemoteTargetXmlPacket

On the ARM buildbot the returned architecture is `armv8l` while
getArchitecture() just returns `arm`.

3 years ago[LAA] Avoid adding pointers to the checks if they are not needed.
Florian Hahn [Thu, 30 Jul 2020 18:12:28 +0000 (19:12 +0100)]
[LAA] Avoid adding pointers to the checks if they are not needed.

Currently we skip alias sets with only reads or a single write and no
reads, but still add the pointers to the list of pointers in RtCheck.

This can lead to cases where we try to access a pointer that does not
exist when grouping checks.  In most cases, the way we access
PositionMap masked that, as the value would default to index 0.

But in the example in PR46854 it causes a crash.

This patch updates the logic to avoid adding pointers for alias sets
that do not need any checks. It makes things slightly more verbose, by
first checking the numbers of reads/writes and bailing out early if we don't
need checks for the alias set.

I think this makes the logic a bit simpler to follow.

Reviewed By: anemet

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

3 years ago[mlir] NFC: Expose `getElementPtrType` and `getSizes` methods of AllocOpLowering.
Alexander Belyaev [Thu, 30 Jul 2020 18:16:51 +0000 (20:16 +0200)]
[mlir] NFC: Expose `getElementPtrType` and `getSizes` methods of AllocOpLowering.

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

3 years ago[InstCombine] update test checks; NFC
Sanjay Patel [Thu, 30 Jul 2020 18:16:18 +0000 (14:16 -0400)]
[InstCombine] update test checks; NFC

3 years agoFix computeHostNumPhysicalCores() for Linux on POWER and Linux on Z
Ettore Tiotto [Thu, 30 Jul 2020 15:36:09 +0000 (15:36 +0000)]
Fix computeHostNumPhysicalCores() for Linux on POWER and Linux on Z

ThinLTO is run using a single thread on Linux on Power. The
compute_thread_count() routine calls getHostNumPhysicalCores which
returns -1 by default, and so `MaxThreadCount is set to 1.

unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
    int MaxThreadCount = UseHyperThreads
          ? computeHostNumHardwareThreads()
          : sys::getHostNumPhysicalCores();
     if (MaxThreadCount <= 0)
        MaxThreadCount = 1;
   …
}
Fix: provide custom implementation of getHostNumPhysicalCores for
Linux on Power and Linux on Z.

Reviewed By: Kai, uweigand

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

3 years ago[WebAssembly] Fixed 64-bit indices in br_table
Wouter van Oortmerssen [Mon, 27 Jul 2020 21:59:31 +0000 (14:59 -0700)]
[WebAssembly] Fixed 64-bit indices in br_table

LLVM selection dag assumes "switch" indices are pointer sized, which causes problems for our 32-bit br_table. The new function ensures 32-bit operands don't get unnecessarily extended, and 64-bit operands get truncated.

Note that the changes to the existing test test exactly that: the addition of -NEXT in 2 places ensures no extension is inserted (which the test previously ignored) and that the wrap is present (previously omitted in wasm64 mode).

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

3 years ago[AMDGPU] Do not use undef on indirect source
Stanislav Mekhanoshin [Thu, 30 Jul 2020 00:17:45 +0000 (17:17 -0700)]
[AMDGPU] Do not use undef on indirect source

We are using undef on the indirect move source subreg and then
using implicit super-reg. This creates a problem in RA when
Greedy decides to split the register. It reassigns the implicit
super-reg but does not bother to change undef source because
it is really does not matter. The fix is to stop lying to RA and
drop undef flag.

This has also hit a problem in SIFoldOperands as it can fold
immediate into an indirect move since there is no undef flag
anymore. That results in multiple test failures, so added the
check for this case.

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

3 years ago[lldb] Add copy ctor/assignment operator to SBCommandInterpreterRunOptions
Jonas Devlieghere [Thu, 30 Jul 2020 17:34:32 +0000 (10:34 -0700)]
[lldb] Add copy ctor/assignment operator to SBCommandInterpreterRunOptions

3 years ago[lldb][test] Move registers-target-xml-reading target to the correct test location.
Jordan Rupprecht [Thu, 30 Jul 2020 17:25:28 +0000 (10:25 -0700)]
[lldb][test] Move registers-target-xml-reading target to the correct test location.

This test was added in D74217 (and the `.categories` file later added in ccf1c30cde6e1e763e7c9cdd48a609a805166699) around the same time I moved the test tree from `lldb/packages/Python/lldbsuite/test` to `lldb/test/API` (D71151). Since this got lost in the move, it isn't running. (I introduced an intentional syntax error, and `ninja check-lldb` passes).

I moved it to the correct location, and now it runs and passes -- locally, at least -- as `ninja check-lldb-api-tools-lldb-server-registers-target-xml-reading`.

3 years agoLoopUnroll.cpp - pass std::vector by const reference to needToInsertPhisForLCSSA...
Simon Pilgrim [Thu, 30 Jul 2020 16:37:57 +0000 (17:37 +0100)]
LoopUnroll.cpp - pass std::vector by const reference to needToInsertPhisForLCSSA helper. NFCI.

Avoid an unnecessary pass by value.

3 years ago[NewPM][PassInstrument] Add PrintPass callback to StandardInstrumentations
Yuanfang Chen [Wed, 29 Jul 2020 00:08:24 +0000 (17:08 -0700)]
[NewPM][PassInstrument] Add PrintPass callback to StandardInstrumentations

Problem:
Right now, our "Running pass" is not accurate when passes are wrapped in adaptor because adaptor is never skipped and a pass could be skipped. The other problem is that "Running pass" for a adaptor is before any "Running pass" of passes/analyses it depends on. (for example, FunctionToLoopPassAdaptor). So the order of printing is not the actual order.

Solution:
Doing things like PassManager::Debuglogging is very intrusive because we need to specify Debuglogging whenever adaptor is created. (Actually, right now we're not specifying Debuglogging for some sub-PassManagers. Check PassBuilder)

This patch move debug logging for pass as a PassInstrument callback. We could be sure that all running passes are logged and in the correct order.

This could also be used to implement hierarchy pass logging in legacy PM. We could also move logging of pass manager to this if we want.

The test fixes looks messy. It includes changes:
- Remove PassInstrumentationAnalysis
- Remove PassAdaptor
- If a PassAdaptor is for a real pass, the pass is added
- Pass reorder (to the correct order), related to PassAdaptor
- Add missing passes (due to Debuglogging not passed down)

Reviewed By: asbirlea, aeubanks

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

3 years ago[WebAssembly] Fix GCC 5 build.
Craig Topper [Thu, 30 Jul 2020 16:54:02 +0000 (09:54 -0700)]
[WebAssembly] Fix GCC 5 build.

Hans' speculative fix in b7292f2db02d37c9291afc0613a3fbce0a4ad4e8
didn't work for me. This seems to.

3 years ago[MLIR][OpenMP] Fix OpenMPIRBuilder usage after D82470
Johannes Doerfert [Thu, 30 Jul 2020 16:53:06 +0000 (11:53 -0500)]
[MLIR][OpenMP] Fix OpenMPIRBuilder usage after D82470