platform/upstream/llvm.git
3 years ago[CSKY] Add visibility macro to fix link error
Zi Xuan Wu [Mon, 11 Jan 2021 08:18:01 +0000 (16:18 +0800)]
[CSKY] Add visibility macro to fix link error

Add LLVM_EXTERNAL_VISIBILITY macro to fix link error of
https://reviews.llvm.org/D88466#2476378

3 years agoRemove redundant casts.
Adrian Kuegel [Fri, 8 Jan 2021 14:37:06 +0000 (15:37 +0100)]
Remove redundant casts.

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

3 years ago[RISCV] Clear isCodeGenOnly flag on VMSGE(U) pseudo instructions. Remove InstAliases...
Craig Topper [Mon, 11 Jan 2021 06:35:51 +0000 (22:35 -0800)]
[RISCV] Clear isCodeGenOnly flag on VMSGE(U) pseudo instructions. Remove InstAliases that duplicate the asm strings in the pseudos.

The Pseudo class sets isCodeGenOnly=1 which causes the asm strings
in the pseudos to be ignored. I think this is why the aliases are
needed at all.

Reviewed By: frasercrmck

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

3 years ago[JITLink] Rename PostAllocationPasses to PreFixupPasses.
Lang Hames [Mon, 11 Jan 2021 07:30:09 +0000 (18:30 +1100)]
[JITLink] Rename PostAllocationPasses to PreFixupPasses.

PreFixupPasses better reflects when these passes will run.

A future patch will (re)introduce a PostAllocationPasses list that will run
after allocation, but before JITLinkContext::notifyResolved is called to notify
the rest of the JIT about the resolved symbol addresses.

3 years ago[NFC][AsmPrinter] Make comments for spill/reload more precise.
Hsiangkai Wang [Fri, 8 Jan 2021 13:07:05 +0000 (21:07 +0800)]
[NFC][AsmPrinter] Make comments for spill/reload more precise.

The size of spill/reload may be unknown for scalable vector types.
When the size is unknown, print it as "Unknown-size" instead of a very
large number.

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

3 years ago[MLIR][SPIRV] Add (de-)serialization support for SpecConstantOpeation.
ergawy [Mon, 11 Jan 2021 06:37:34 +0000 (07:37 +0100)]
[MLIR][SPIRV] Add (de-)serialization support for SpecConstantOpeation.

This commit adds support for (de-)serializing SpecConstantOpeation. One
thing worth noting is that during deserialization, we assign a fake ID to
enclosed ops inside SpecConstantOpeation. We need to do this in order
for deserialization logic to properly update ID to value map and to
later reference the created value from the sibling 'spv::YieldOp'.

Reviewed By: antiagainst

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

3 years agoCGDebugInfo: Delete unneeded UnwrapTypeForDebugInfo
Fangrui Song [Mon, 11 Jan 2021 06:22:07 +0000 (22:22 -0800)]
CGDebugInfo: Delete unneeded UnwrapTypeForDebugInfo

Tested with stage 2 -DCMAKE_BUILD_TYPE=Debug clang, byte identical.

3 years agoCGDebugInfo: Delete redundant test
Fangrui Song [Mon, 11 Jan 2021 06:09:47 +0000 (22:09 -0800)]
CGDebugInfo: Delete redundant test

3 years ago[IR Parser] Fix a crash handling zero width integer attributes.
Chris Lattner [Mon, 11 Jan 2021 02:32:57 +0000 (18:32 -0800)]
[IR Parser] Fix a crash handling zero width integer attributes.

llvm::APInt cannot hold zero bit values, therefore we shouldn't try
to form them.

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

3 years ago[PowerPC] Add variants of 64-bit vector types for vec_sel.
Esme-Yi [Mon, 11 Jan 2021 03:52:16 +0000 (03:52 +0000)]
[PowerPC] Add variants of 64-bit vector types for vec_sel.

Summary: This patch added variants of vec_sel and fixed bugzilla 46770.

Reviewed By: nemanjai

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

3 years ago[LoopUnroll] Fix a crash
Serguei Katkov [Tue, 22 Dec 2020 09:40:50 +0000 (16:40 +0700)]
[LoopUnroll] Fix a crash

Loop peeling as a last step triggers loop simplification and this
can change the loop structure. As a result all cashed values like
latch branch becomes invalid.

Patch re-structure the code to take into account the possible
changes caused by peeling.

Reviewers: dmgreen, Meinersbur, etiotto, fhahn, efriedma, bmahjour
Reviewed By: Meinersbur, fhahn
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D93686

3 years ago[RISCV] Convert most of the information about RVV Pseudos into bits in TSFlags.
Craig Topper [Mon, 11 Jan 2021 02:01:23 +0000 (18:01 -0800)]
[RISCV] Convert most of the information about RVV Pseudos into bits in TSFlags.

This patch moves all but the BaseInstr to bits in TSFlags.

For the index fields, we can just use a bit to indicate their presence.
The locations of the operands are well defined.

This reduces the llc binary by about 32K on my build. It also
removes the binary search of the table from the custom inserter.
Instead we just check that the SEW op is present.

Reviewed By: rogfer01

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

3 years ago[DAGCombine] Remove the check for unsafe-fp-math when we are checking the AFN
QingShan Zhang [Mon, 11 Jan 2021 02:25:53 +0000 (02:25 +0000)]
[DAGCombine] Remove the check for unsafe-fp-math when we are checking the AFN

We are checking the unsafe-fp-math for sqrt but not for fpow, which behaves inconsistent.
As the direction is to remove this global option, we need to remove the unsafe-fp-math
check for sqrt and update the test with afn fast-math flags.

Reviewed By: Spatel

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

3 years agoRevert "[X86][SSE] Fold unpack(hop(),hop()) -> permute(hop())"
Nico Weber [Mon, 11 Jan 2021 01:22:53 +0000 (20:22 -0500)]
Revert "[X86][SSE] Fold unpack(hop(),hop()) -> permute(hop())"

This reverts commit 80dee7965dffdfb866afa9d74f3a4a97453708b2.
Makes clang sometimes hang forever. See
https://bugs.chromium.org/p/chromium/issues/detail?id=1164786#c6 for a
stand-alone repro.

3 years ago[LoopDeletion] Break backedge of outermost loops when known not taken
Philip Reames [Sun, 10 Jan 2021 23:57:25 +0000 (15:57 -0800)]
[LoopDeletion] Break backedge of outermost loops when known not taken

This is a resubmit of dd6bb367 (which was reverted due to stage2 build failures in 7c63aac), with the additional restriction added to the transform to only consider outer most loops.

As shown in the added test case, ensuring LCSSA is up to date when deleting an inner loop is tricky as we may actually need to remove blocks from any outer loops, thus changing the exit block set.   For the moment, just avoid transforming this case.  I plan to return to this case in a follow up patch and see if we can do better.

Original commit message follows...

The basic idea is that if SCEV can prove the backedge isn't taken, we can go ahead and get rid of the backedge (and thus the loop) while leaving the rest of the control in place. This nicely handles cases with dispatch between multiple exits and internal side effects.

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

3 years agoCGDebugInfo: Delete unused DIFile* parameter
Fangrui Song [Sun, 10 Jan 2021 23:03:40 +0000 (15:03 -0800)]
CGDebugInfo: Delete unused DIFile* parameter

3 years ago[StringExtras] Add a helper class for comma-separated lists
Kazu Hirata [Sun, 10 Jan 2021 22:32:02 +0000 (14:32 -0800)]
[StringExtras] Add a helper class for comma-separated lists

This patch introduces a helper class SubsequentDelim to simplify loops
that generate a comma-separated lists.

For example, consider the following loop, taken from
llvm/lib/CodeGen/MachineBasicBlock.cpp:

    for (auto I = pred_begin(), E = pred_end(); I != E; ++I) {
      if (I != pred_begin())
        OS << ", ";
      OS << printMBBReference(**I);
    }

The new class allows us to rewrite the loop as:

    SubsequentDelim SD;
    for (auto I = pred_begin(), E = pred_end(); I != E; ++I)
      OS << SD << printMBBReference(**I);

where SD evaluates to the empty string for the first time and ", " for
subsequent iterations.

Unlike interleaveComma, defined in llvm/include/llvm/ADT/STLExtras.h,
SubsequentDelim can accommodate a wider variety of loops, including:

- those that conditionally skip certain items,
- those that need iterators to call getSuccProbability(I), and
- those that iterate over integer ranges.

As an example, this patch cleans up MachineBasicBlock::print.

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

3 years ago[OpenMP] Not set OPENMP_STANDALONE_BUILD=ON when building OpenMP along with LLVM
Shilei Tian [Sun, 10 Jan 2021 21:46:09 +0000 (16:46 -0500)]
[OpenMP] Not set OPENMP_STANDALONE_BUILD=ON when building OpenMP along with LLVM

For now, `*_STANDALONE_BUILD` is set to ON even if they're built along
with LLVM because of issues mentioned in the comments. This can cause some issues.
For example, if we build OpenMP along with LLVM, we'd like to copy those OpenMP
headers to `<prefix>/lib/clang/<version>/include` such that `clang` can find
those headers without using `-I <prefix>/include` because those headers will be
copied to `<prefix>/include` if it is built standalone.

In this patch, we fixed the dependence issue in OpenMP such that it can be built
correctly even with `OPENMP_STANDALONE_BUILD=OFF`. The issue is in the call to
`add_lit_testsuite`, where `clang` and `clang-resource-headers` are passed as
`DEPENDS`. Since we're building OpenMP along with LLVM, `clang` is set by CMake
to be the C/C++ compiler, therefore these two dependences are no longer needed,
where caused the dependence issue.

Reviewed By: jdoerfert

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

3 years ago[LLVM] Added OpenMP to `LLVM_ALL_RUNTIMES`
Shilei Tian [Sun, 10 Jan 2021 21:45:39 +0000 (16:45 -0500)]
[LLVM] Added OpenMP to `LLVM_ALL_RUNTIMES`

This patch added `openmp` to `LLVM_ALL_RUNTIMES` so that when the CMake argument `LLVM_ENABLE_RUNTIMES=all`, OpenMP can also be built.

Reviewed By: jdoerfert

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

3 years ago[NFCI][SimplifyCFG] Prefer to add Insert edges before Delete edges into DomTreeUpdate...
Roman Lebedev [Sun, 10 Jan 2021 13:25:15 +0000 (16:25 +0300)]
[NFCI][SimplifyCFG] Prefer to add Insert edges before Delete edges into DomTreeUpdater, if reasonable

This has a measurable impact on the number of DomTree recalculations.
While this doesn't handle all the cases,
it deals with the most obvious ones.

3 years ago[lldb] Fix some bugs in the Pipe class and add tests
Pavel Labath [Fri, 8 Jan 2021 19:37:09 +0000 (20:37 +0100)]
[lldb] Fix some bugs in the Pipe class and add tests

- s/createUniqueFile/createUniquePath -- we don't want to create the file,
  just the file name
- s/data()/str().c_str()/ -- paths given to system apis must be
  null-terminated

3 years ago[Tests] Precommit tests from to simplify rebase
Philip Reames [Sun, 10 Jan 2021 20:42:08 +0000 (12:42 -0800)]
[Tests] Precommit tests from to simplify rebase

3 years agoPrecommit tests requested for D93725
Philip Reames [Sun, 10 Jan 2021 20:26:24 +0000 (12:26 -0800)]
Precommit tests requested for D93725

3 years ago[test] Improve CodeGenCXX/difile_entry.cpp
Fangrui Song [Sun, 10 Jan 2021 20:24:49 +0000 (12:24 -0800)]
[test] Improve CodeGenCXX/difile_entry.cpp

The test added in D87147 did not actually test PR47391.
Use an absolute path to test the canonicalization.

3 years ago[Tests] Auto update a vectorizer test to simplify future diff
Philip Reames [Sun, 10 Jan 2021 20:23:22 +0000 (12:23 -0800)]
[Tests] Auto update a vectorizer test to simplify future diff

3 years ago[SLP] fix typo in assert
Sanjay Patel [Sun, 10 Jan 2021 18:15:04 +0000 (13:15 -0500)]
[SLP] fix typo in assert

This snuck into 0aa75fb12faa , but I didn't catch it locally.

3 years ago[SLP] put verifyFunction call behind EXPENSIVE_CHECKS
Sanjay Patel [Sun, 10 Jan 2021 17:31:05 +0000 (12:31 -0500)]
[SLP] put verifyFunction call behind EXPENSIVE_CHECKS

A severe compile-time slowdown from this call is noted in:
https://llvm.org/PR48689
My naive fix was to put it under LLVM_DEBUG ( 267ff79 ),
but that's not limiting in the way we want.
This is a quick fix (or we could just remove the call completely
and rely on some later pass to discover potentially wrong IR?).
A bigger/better fix would be to improve/limit verifyFunction()
as noted in:
https://llvm.org/PR47712

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

3 years ago[llvm] Ensure newlines at the end of files (NFC)
Kazu Hirata [Sun, 10 Jan 2021 17:24:56 +0000 (09:24 -0800)]
[llvm] Ensure newlines at the end of files (NFC)

This patch eliminates pesky "No newline at end of file" messages from
git diff.

3 years ago[MemorySSA] Remove unused dominatesUse (NFC)
Kazu Hirata [Sun, 10 Jan 2021 17:24:54 +0000 (09:24 -0800)]
[MemorySSA] Remove unused dominatesUse (NFC)

The function was introduced without a use on Feb 2, 2016 in commit
e1100f533f0a48f55e80e1152b06f5deab5f9b30.

3 years ago[CodeGen, DebugInfo] Use llvm::find_if (NFC)
Kazu Hirata [Sun, 10 Jan 2021 17:24:53 +0000 (09:24 -0800)]
[CodeGen, DebugInfo] Use llvm::find_if (NFC)

3 years ago[ConstantFold] Fold fptoi.sat intrinsics
Nikita Popov [Sun, 10 Jan 2021 16:07:14 +0000 (17:07 +0100)]
[ConstantFold] Fold fptoi.sat intrinsics

The APFloat::convertToInteger() API already implements the desired
saturation semantics.

3 years ago[ConstantFold] Add tests for fptoi.sat (NFC)
Nikita Popov [Sun, 10 Jan 2021 16:08:11 +0000 (17:08 +0100)]
[ConstantFold] Add tests for fptoi.sat (NFC)

3 years ago[STLExtras] Use return type from operator* of the wrapped iter.
Florian Hahn [Sun, 10 Jan 2021 14:41:13 +0000 (14:41 +0000)]
[STLExtras] Use return type from operator* of the wrapped iter.

Currently make_early_inc_range cannot be used with iterators with
operator* implementations that do not return a reference.

Most notably in the LLVM codebase, this means the User iterator ranges
cannot be used with make_early_inc_range, which slightly simplifies
iterating over ranges while elements are removed.

Instead of directly using BaseT::reference as return type of operator*,
this patch uses decltype to get the actual return type of the operator*
implementation in WrappedIteratorT.

This patch also updates a few places to use make use of
make_early_inc_range.

Reviewed By: dblaikie

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

3 years ago[lld/mac] llvm style fix: no else after return
Nico Weber [Sun, 10 Jan 2021 14:35:00 +0000 (09:35 -0500)]
[lld/mac] llvm style fix: no else after return

3 years ago[mlir] NFC - Drop spurious assertion on symbols during `promoteComposedSymbolsAsDims`
Nicolas Vasilache [Sun, 10 Jan 2021 14:01:54 +0000 (14:01 +0000)]
[mlir] NFC - Drop spurious assertion on symbols during `promoteComposedSymbolsAsDims`

This assertion is an old remnant from earlier days when only affine functions existed.
It is not the place of affine map composition to check whether orthogonal considerations
on what is allowed to be a symbol under the AffineScope trait.

3 years ago[CodeGen] Update transformations to use poison for shufflevector/insertelem's initial...
Juneyoung Lee [Sun, 10 Jan 2021 08:22:54 +0000 (17:22 +0900)]
[CodeGen] Update transformations to use poison for shufflevector/insertelem's initial vector elem

This patch is a part of D93817 and makes transformations in CodeGen use poison for shufflevector/insertelem's initial vector element.

The change in CodeGenPrepare.cpp is fine because the mask of shufflevector should be always zero.
It doesn't touch the second element (which is poison).

The change in InterleavedAccessPass.cpp is also fine becauses the mask is of the form <a, a+m, a+2m, .., a+km> where a+km is smaller than
the size of the first vector operand.
This is guaranteed by the caller of replaceBinOpShuffles, which is lowerInterleavedLoad.
It calls isDeInterleaveMask and isDeInterleaveMaskOfFactor to check the mask is the desirable form.
isDeInterleaveMask has the check that a+km is smaller than the vector size.
To check my understanding, I added an assertion & added a test to show that this optimization doesn't fire in such case.

Reviewed By: spatel

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

3 years ago[test] Improve weakref & weak_import tests
Fangrui Song [Sun, 10 Jan 2021 07:56:55 +0000 (23:56 -0800)]
[test] Improve weakref & weak_import tests

3 years ago[RISCV] Change ConstraintMask in RISCVII enum to be shifted left. NFC
Craig Topper [Sun, 10 Jan 2021 03:56:57 +0000 (19:56 -0800)]
[RISCV] Change ConstraintMask in RISCVII enum to be shifted left. NFC

This makes the mask align with the position of the bits in TSFlags
which is a little more logical.

I might be adding more fields to TSFlags and some might be single
bits where just ANDing with mask to test the bit would make sense.

While there rename TargetFlags in validateInstruction to reflect
that it's just the constraint bits.

3 years ago[RISCV] Use uint16_t instead of unsigned for opcodes in the RVV pseudo instruction...
Craig Topper [Sun, 10 Jan 2021 02:00:05 +0000 (18:00 -0800)]
[RISCV] Use uint16_t instead of unsigned for opcodes in the RVV pseudo instruction table.

We currently have about 7000 opcodes in the RISCVGenInstrInfo.inc
enum. We can use uint16_t to store these values. We would need to
grow by nearly 9x before we run out of space so this should last
for a little while.

This reduces the llc binary by 32K.

3 years ago[lld/mac] remove redundant null check
Nico Weber [Sun, 10 Jan 2021 02:17:59 +0000 (21:17 -0500)]
[lld/mac] remove redundant null check

This is already checked two lines up. No behavior change.

3 years agoRecommit D91678 after fixing the test breakage.
Sriraman Tallam [Sun, 10 Jan 2021 01:40:38 +0000 (17:40 -0800)]
Recommit D91678 after fixing the test breakage.

This adds a new test checking llvm-symbolizer with an object built with basic block sections.

Build a object with -fbasic-block-sections and reorder the basic blocks to be
non-contiguous. Then check if llvm-symbolizer correctly reports the symbolized
addresses. Included the source to build the object with command lines.

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

3 years ago[CodeGenModule] Drop dso_local on function declarations for ELF -fno-pic -fno-direct...
Fangrui Song [Sun, 10 Jan 2021 00:31:55 +0000 (16:31 -0800)]
[CodeGenModule] Drop dso_local on function declarations for ELF -fno-pic -fno-direct-access-external-data

ELF -fno-pic sets dso_local on a function declaration to allow direct accesses
when taking its address (similar to a data symbol). The emitted code follows the
traditional GCC/Clang -fno-pic behavior: an absolute relocation is produced.

If the function is not defined in the executable, a canonical PLT entry will be
needed at link time. This is similar to a copy relocation and is incompatible
with (-Bsymbolic or --dynamic-list linked shared objects / protected symbols in
a shared object).

This patch gives -fno-pic code a way to avoid such a canonical PLT entry.

The FIXME was about a generalization for -fpie -mpie-copy-relocations (now -fpie
-fdirect-access-external-data). While we could set dso_local to avoid GOT when
taking the address of a function declaration (there is an ignorable difference
about R_386_PC32 vs R_386_PLT32 on i386), it likely does not provide any benefit
and can just cause trouble, so we don't make the generalization.

3 years ago[RISCV] Add scalable vector icmp ISel patterns
Fraser Cormack [Sat, 9 Jan 2021 19:21:23 +0000 (19:21 +0000)]
[RISCV] Add scalable vector icmp ISel patterns

Original patch by @rogfer01.

The RVV integer comparison instructions are defined in such a way that
many LLVM operations are defined by using the "opposite" comparison
instruction and swapping the operands. This is done in this patch in
most cases, except for the mappings where the immediate range must be
adjusted to accomodate:

    va < i --> vmsle{u}.vi vd, va, i-1, vm
    va >= i --> vmsgt{u}.vi vd, va, i-1, vm

That is left for future optimization; this patch supports all operations
but in the case of the missing mappings the immediate will be moved to
a scalar register first.

Since there are so many condition codes and operand cases to check, it
was decided to reduce the test burden by only testing the "vscale x 8"
vector types.

Authored-by: Roger Ferrer Ibanez <rofirrim@gmail.com>
Co-Authored-by: Fraser Cormack <fraser@codeplay.com>
Reviewed By: craig.topper

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

3 years ago[SelectionDAG] Teach isConstOrConstSplat about ISD::SPLAT_VECTOR
Fraser Cormack [Sat, 9 Jan 2021 17:12:22 +0000 (17:12 +0000)]
[SelectionDAG] Teach isConstOrConstSplat about ISD::SPLAT_VECTOR

This improves llvm::isConstOrConstSplat by allowing it to analyze
ISD::SPLAT_VECTOR nodes, in order to allow more constant-folding of
operations using scalable vector types.

Reviewed By: craig.topper

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

3 years ago[mlir] Enhance mlir-opt show-dialects test case
Lewuathe [Sat, 9 Jan 2021 20:43:43 +0000 (20:43 +0000)]
[mlir] Enhance mlir-opt show-dialects test case

mlir-opt supports many more test cases. All available dialects supported by latest mlir-opt should be coverted in the test case.

Reviewed By: aartbik, stephenneuendorffer, mehdi_amini

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

3 years ago[clang] Add llvm-strip to test dependencies
Shoaib Meenai [Sat, 9 Jan 2021 19:57:09 +0000 (11:57 -0800)]
[clang] Add llvm-strip to test dependencies

CodeGen/thinlto_embed_bitcode.ll relies on it.

3 years ago[NFC] Disallow unused prefixes in CodeGen/X86 tests.
Mircea Trofin [Fri, 8 Jan 2021 20:21:29 +0000 (12:21 -0800)]
[NFC] Disallow unused prefixes in CodeGen/X86 tests.

Also fixed remaining tests that featured unused prefixes.

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

3 years ago[mlir][vector] modified scatter/gather syntax, pass_thru mandatory
Aart Bik [Sat, 9 Jan 2021 00:25:37 +0000 (16:25 -0800)]
[mlir][vector] modified scatter/gather syntax, pass_thru mandatory

This change makes the scatter/gather syntax more consistent with
the syntax of all the other memory operations in the Vector dialect
(order of types, use of [] for index, etc.). This will make the MLIR
code easier to read. In addition, the pass_thru parameter of the
gather has been made mandatory (there is very little benefit in
using the implicit "undefined" values).

Reviewed By: nicolasvasilache

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

3 years ago[SimplifyCFG] Keep !dgb metadata of moved instruction, if they match.
Florian Hahn [Sat, 9 Jan 2021 17:02:58 +0000 (17:02 +0000)]
[SimplifyCFG] Keep !dgb metadata of moved instruction, if they match.

Currently SimplifyCFG drops the debug locations of 'bonus' instructions.
Such instructions are moved before the first branch. The reason for the
current behavior is that this could lead to surprising debug stepping,
if the block that's folded is dead.

In case the first branch and the instructions to be folded have the same
debug location, this shouldn't be an issue and we can keep the debug
location.

Reviewed By: vsk

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

3 years ago[gn build] Make an explicit `use_lld = true` on mac use lld.darwinnew
Nico Weber [Sat, 9 Jan 2021 19:03:52 +0000 (14:03 -0500)]
[gn build] Make an explicit `use_lld = true` on mac use lld.darwinnew

use_lld defaults to true on non-mac if clang_base_path is set (i.e.
the host compiler is a locally-built clang). On mac, the lld Mach-O
port used to be unusable, but ld64.lld.darwinnew is close to usable.
When explicitly setting `use_lld = true` in a GN build on a mac host,
check-lld passes, two check-clang tests fail, and a handful check-llvm
tests fail (the latter all due to -flat_namespace not yet being implemented).

3 years ago[OpenMP] Remove copy constructor of `RTLInfoTy`
Shilei Tian [Sat, 9 Jan 2021 18:00:50 +0000 (13:00 -0500)]
[OpenMP] Remove copy constructor of `RTLInfoTy`

Multiple `RTLInfoTy` objects are stored in a list `AllRTLs`. Since
`RTLInfoTy` contains a `std::mutex`, it is by default not a copyable object.
In order to support `AllRTLs.push_back(...)` which is currently used, a customized
copy constructor is provided. Every time we need to add a new data member into
`RTLInfoTy`, we should keep in mind not forgetting to add corresponding assignment
in the copy constructor. In fact, the only use of the copy constructor is to push
the object into the list, we can of course write it in a way that first emplace
a new object back, and then use the reference to the last element. In this way we
don't need the copy constructor anymore. If the element is invalid, we just need
to pop it, and that's what this patch does.

Reviewed By: JonChesterfield

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

3 years ago[lld-macho] Remove unnecessary llvm:: namespace prefixes
Jez Ng [Sat, 9 Jan 2021 16:58:19 +0000 (11:58 -0500)]
[lld-macho] Remove unnecessary llvm:: namespace prefixes

3 years ago[llvm] Drop unnecessary make_range (NFC)
Kazu Hirata [Sat, 9 Jan 2021 17:24:59 +0000 (09:24 -0800)]
[llvm] Drop unnecessary make_range (NFC)

3 years ago[Transforms] Use llvm::find_if (NFC)
Kazu Hirata [Sat, 9 Jan 2021 17:24:58 +0000 (09:24 -0800)]
[Transforms] Use llvm::find_if (NFC)

3 years ago[SCEV] Remove unused getOrInsertCanonicalInductionVariable (NFC)
Kazu Hirata [Sat, 9 Jan 2021 17:24:56 +0000 (09:24 -0800)]
[SCEV] Remove unused getOrInsertCanonicalInductionVariable (NFC)

The last use was removed on Mar 22, 2012 in commit
f47d0af5515bee47dfd000363740fe347bb6cd18.

3 years ago[SelectionDAG] Extend immAll(Ones|Zeros)V to handle ISD::SPLAT_VECTOR
Fraser Cormack [Wed, 6 Jan 2021 08:07:41 +0000 (08:07 +0000)]
[SelectionDAG] Extend immAll(Ones|Zeros)V to handle ISD::SPLAT_VECTOR

The TableGen immAllOnesV and immAllZerosV helpers implicitly wrapped the
ISD::isBuildVectorAll(Ones|Zeros) helper functions. This was inhibiting
their use for targets such as RISC-V which use ISD::SPLAT_VECTOR. In
particular, RISC-V had to define its own 'vnot' fragment.

In order to extend the scope of these nodes to include support for
ISD::SPLAT_VECTOR, two new ISD predicate functions have been introduced:
ISD::isConstantSplatVectorAll(Ones|Zeros). These effectively supersede
the older "isBuildVector" predicates, which are now simple wrappers for
the new functions. They pass a defaulted boolean toggle which preserves
the old behaviour. It is hoped that in time all call-sites can be ported
to the "isConstantSplatVector" functions.

While the use of ISD::isBuildVectorAll(Ones|Zeros) has not changed, the
behaviour of the TableGen immAll(Ones|Zeros)V **has**. To test the new
functionality, the custom RISC-V TableGen fragment has been removed and
replaced with the built-in 'vnot'. To test their use as pattern-roots, two
splat patterns have been updated accordingly.

Reviewed By: craig.topper

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

3 years ago[OpenMP] Added the support for cache line size 256 for A64FX
Shilei Tian [Sat, 9 Jan 2021 16:58:37 +0000 (11:58 -0500)]
[OpenMP] Added the support for cache line size 256 for A64FX

Fugaku supercomputer is built with the Fujitsu A64FX microprocessor, whose cache line is 256. In current libomp, we only have cache line size 128 for PPC64 and otherwise 64. This patch added the support of cache line 256 for A64FX. It's worth noting that although A64FX is a variant of AArch64, this property is not shared. As a result, in light of UCX source code (https://github.com/openucx/ucx/blob/392443ab92626412605dee1572056f79c897c6c3/src/ucs/arch/aarch64/cpu.c#L17), we can only determine by checking whether the CPU is FUJITSU A64FX.

Reviewed By: jdoerfert, Hahnfeld

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

3 years ago[RISCV] Do not grow the stack a second time when we need to realign the stack
Roger Ferrer Ibanez [Sat, 9 Jan 2021 16:49:05 +0000 (16:49 +0000)]
[RISCV] Do not grow the stack a second time when we need to realign the stack

This is a first change needed to fix a crash in which the emergency
spill splot ends being out of reach. This happens when we run the
register scavenger after we have eliminated the frame indexes. The fix
for the actual crash will come in a later change.

This change removes an extra stack size increase we do in
RISCVFrameLowering::determineFrameLayout.

We don't have to change the size of the stack here as
PEI::calculateFrameObjectOffsets is already doing this with the right
size accounting the extra alignment.

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

3 years ago[VPlan] Keep start value of VPWidenPHIRecipe as VPValue.
Florian Hahn [Sat, 9 Jan 2021 16:34:15 +0000 (16:34 +0000)]
[VPlan] Keep start value of VPWidenPHIRecipe as VPValue.

Similar to D92129, update VPWidenPHIRecipe  to manage the start value as
VPValue. This allows adjusting the start value as a VPlan transform,
which will be used in a follow-up patch to support reductions during
epilogue vectorization.

Reviewed By: gilr

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

3 years ago[clang][Sema] Compare SourceLocations directly [NFCI]
Mikhail Maltsev [Sat, 9 Jan 2021 14:13:18 +0000 (14:13 +0000)]
[clang][Sema] Compare SourceLocations directly [NFCI]

The ordered comparison operators are defined for the SourceLocation
class, so SourceLocation objects can be compared directly. There is no
need to extract the internal representation for comparison.

Reviewed By: aprantl

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

3 years ago[mlir][spirv] Replace SPIRVOpLowering with OpConversionPattern
Lei Zhang [Sat, 9 Jan 2021 13:04:49 +0000 (08:04 -0500)]
[mlir][spirv] Replace SPIRVOpLowering with OpConversionPattern

The dialect conversion framework was enhanced to handle type
conversion automatically. OpConversionPattern already contains
a pointer to the TypeConverter. There is no need to duplicate it
in a separate subclass. This removes the only reason for a
SPIRVOpLowering subclass. It adapts to use core infrastructure
and simplifies the code.

Also added a utility function to OpConversionPattern for getting
TypeConverter as a certain subclass.

Reviewed By: hanchung

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

3 years ago[WebAssembly] Remove unreachable EH pads
Heejin Ahn [Sun, 27 Dec 2020 10:52:43 +0000 (02:52 -0800)]
[WebAssembly] Remove unreachable EH pads

This removes unreachable EH pads in LateEHPrepare. This is not for
optimization but for preparation for CFGStackify. In CFGStackify, we
determine where to place `try` marker by computing the nearest common
dominator of all predecessors of an EH pad, but when an EH pad does not
have a predecessor, it becomes tricky. We can insert an empty dummy BB
before the EH pad and place the `try` there, but removing unreachable EH
pads is simpler.

This moves an existing exception label test from eh-label.mir to
exception.mir and adds a new test there.

This also adds some comments to existing methods.

Reviewed By: dschuff, tlively

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

3 years ago[RISCV] Add tests for scalable constant-folding (NFC)
Fraser Cormack [Sat, 9 Jan 2021 10:29:50 +0000 (10:29 +0000)]
[RISCV] Add tests for scalable constant-folding (NFC)

3 years ago[Test][FileCheck] Fix use of undef var
Thomas Preud'homme [Thu, 20 Aug 2020 19:41:43 +0000 (20:41 +0100)]
[Test][FileCheck] Fix use of undef var

The test related to directives with prefix NUMEXPR-CONSTRAINT-NOMATCH
refers to the numeric variable UNSI which is defined by a directive with
prefix CHECK not enabled on the lit command-line. Rather than adding the
prefix CHECK to the lit command-line, this commit defined variable UNSI
in a new NUMEXPR-CONSTRAINT-NOMATCH prefixed directive. The directive
needs to contain more than just the variable otherwise the error message
from FileCheck is about the wrong line being matched.

Reviewed By: jhenderson

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

3 years ago[WebAssembly] Update InstPrinter support for EH
Heejin Ahn [Sun, 27 Dec 2020 09:10:53 +0000 (01:10 -0800)]
[WebAssembly] Update InstPrinter support for EH

- Updates InstPrinter to handle `catch_all`.
- Makes `rethrow` condition an early exit from the function to make the
  rest simpler.
- Unify label and catch counters. They don't need to be counted
  separately and this will help `delegate` instruction later.
- Removes `LastSeenEHInst` field. This was first introduced to handle
  when there are more than one `catch` blocks per `try`, but this was
  not implemented correctly and not being used at the moment anyway.
- Reenables all tests in cfg-stackify-eh.ll that don't deal with unwind
  destination mismatches, which will be handled in a later CL.

Reviewed By: dschuff, tlively, aardappel

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

3 years ago[mlir] AsyncRuntime: use LLVM ThreadPool to run async tasks
Eugene Zhulenev [Fri, 8 Jan 2021 23:23:59 +0000 (15:23 -0800)]
[mlir] AsyncRuntime: use LLVM ThreadPool to run async tasks

Revert https://reviews.llvm.org/D92368 after the dynamic library unloading was fixed in https://reviews.llvm.org/D94312

Reviewed By: mehdi_amini

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

3 years ago[WebAssembly] Remove exnref and br_on_exn
Heejin Ahn [Sat, 26 Dec 2020 04:23:33 +0000 (20:23 -0800)]
[WebAssembly] Remove exnref and br_on_exn

This removes `exnref` type and `br_on_exn` instruction. This is
effectively NFC because most uses of these were already removed in the
previous CLs.

Reviewed By: dschuff, tlively

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

3 years ago[WebAssembly] Update basic EH instructions for the new spec
Heejin Ahn [Sat, 26 Dec 2020 10:27:44 +0000 (02:27 -0800)]
[WebAssembly] Update basic EH instructions for the new spec

This implements basic instructions for the new spec.

- Adds new versions of instructions: `catch`, `catch_all`, and `rethrow`
- Adds support for instruction selection for the new instructions
 - `catch` needs a custom routine for the same reason `throw` needs one,
   to encode `__cpp_exception` tag symbol.
- Updates `WebAssembly::isCatch` utility function to include `catch_all`
  and Change code that compares an instruction's opcode with `catch` to
  use that function.
- LateEHPrepare
  - Previously in LateEHPrepare we added `catch` instruction to both
    `catchpad`s (for user catches) and `cleanuppad`s (for destructors).
    In the new version `catch` is generated from `llvm.catch` intrinsic
    in instruction selection phase, so we only need to add `catch_all`
    to the beginning of cleanup pads.
  - `catch` is generated from instruction selection, but we need to
    hoist the `catch` instruction to the beginning of every EH pad,
    because `catch` can be in the middle of the EH pad or even in a
    split BB from it after various code transformations.
  - Removes `addExceptionExtraction` function, which was used to
    generate `br_on_exn` before.
- CFGStackfiy: Deletes `fixUnwindMismatches` function. Running this
  function on the new instruction causes crashes, and the new version
  will be added in a later CL, whose contents will be completely
  different. So deleting the whole function will make the diff easier to
  read.
- Reenables all disabled tests in exception.ll and eh-lsda.ll and a
  single basic test in cfg-stackify-eh.ll.
- Updates existing tests to use the new assembly format. And deletes
  `br_on_exn` instructions from the tests and FileCheck lines.

Reviewed By: dschuff, tlively

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

3 years agoFix CodeGenCXX/difile_entry.cpp on Windows
Fangrui Song [Sat, 9 Jan 2021 08:46:02 +0000 (00:46 -0800)]
Fix CodeGenCXX/difile_entry.cpp on Windows

3 years agoMake -fno-pic respect -fno-direct-access-external-data
Fangrui Song [Sat, 9 Jan 2021 08:32:02 +0000 (00:32 -0800)]
Make -fno-pic respect -fno-direct-access-external-data

D92633 added -f[no-]direct-access-external-data to supersede -m[no-]pie-copy-relocations.
(The option works for -fpie but is a no-op for -fno-pic and -fpic.)

This patch makes -fno-pic -fno-direct-access-external-data drop dso_local from
global variable declarations. This usually causes the backend to emit a GOT
indirection for external data access. With a GOT relocation, the subsequent
-no-pie link will not have copy relocation even if the data symbol turns out to
be defined by a shared object.

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

3 years agoAdd -f[no-]direct-access-external-data to supersede -mpie-copy-relocations
Fangrui Song [Sat, 9 Jan 2021 08:29:09 +0000 (00:29 -0800)]
Add -f[no-]direct-access-external-data to supersede -mpie-copy-relocations

GCC r218397 "x86-64: Optimize access to globals in PIE with copy reloc" made
-fpie code emit R_X86_64_PC32 to reference external data symbols by default.
Clang adopted -mpie-copy-relocations D19996 as a flexible alternative.

The name -mpie-copy-relocations can be improved [1] and does not capture the
idea that this option can apply to -fno-pic and -fpic [2], so this patch
introduces -f[no-]direct-access-external-data and makes -mpie-copy-relocations
their aliases for compatibility.

[1]
For
```
extern int var;
int get() { return var; }
```
if var is defined in another translation unit in the link unit, there is no copy
relocation.

[2]
-fno-pic -fno-direct-access-external-data is useful to avoid copy relocations.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65888
If a shared object is linked with -Bsymbolic or --dynamic-list and exports a
data symbol, normally the data symbol cannot be accessed by -fno-pic code
(because by default an absolute relocation is produced which will lead to a copy
relocation). -fno-direct-access-external-data can prevent copy relocations.

-fpic -fdirect-access-external-data can avoid GOT indirection. This is like the
undefined counterpart of -fno-semantic-interposition. However, the user should
define var in another translation unit and link with -Bsymbolic or
--dynamic-list, otherwise the linker will error in a -shared link. Generally
the user has better tools for their goal but I want to mention that this
combination is valid.

On COFF, the behavior is like always -fdirect-access-external-data.
`__declspec(dllimport)` is needed to enable indirect access.

There is currently no plan to affect non-ELF behaviors or -fpic behaviors.

-fno-pic -fno-direct-access-external-data will be implemented in the subsequent patch.

GCC feature request https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98112

Reviewed By: tmsriram

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

3 years ago[WebAssembly] Update WasmEHPrepare for the new spec
Heejin Ahn [Sat, 26 Dec 2020 02:38:59 +0000 (18:38 -0800)]
[WebAssembly] Update WasmEHPrepare for the new spec

Clang generates `wasm.get.exception` and `wasm.get.ehselector`
intrinsics, which respectively return a caught exception value (a
pointer to some C++ exception struct) and a selector (an integer value
that tells which C++ `catch` clause the current exception matches, or
does not match any).

WasmEHPrepare is a pass that does some IR-level preparation before
instruction selection. Previously one of things we did in this pass was
to convert `wasm.get.exception` intrinsic calls to
`wasm.extract.exception` intrinsics. Their semantics were the same
except `wasm.extract.exception` did not have a token argument. We
maintained these two separate intrinsics with the same semantics because
instruction selection couldn't handle token arguments. This
`wasm.extract.exception` intrinsic was later converted to
`extract_exception` instruction in instruction selection, which was a
pseudo instruction to implement `br_on_exn`. Because `br_on_exn` pushed
an extracted value onto the value stack after the `end` instruction of a
`block`, but LLVM does not have a way of modeling that kind of behavior,
so this pseudo instruction was used to pull an extracted value out of
thin air, like this:
```
block $l0
  ...
  br_on_exn $cpp_exception $l0
  ...
end
extract_exception ;; pushes values onto the stack
```

In the new spec, we don't need this pseudo instruction anymore because
`catch` itself returns a value and we don't have `br_on_exn` anymore. In
the spec `catch` returns multiple values (like `br_on_exn`), but here we
assume it only returns a single i32, which is sufficient to support C++.

So this renames `wasm.get.exception` intrinsic to `wasm.catch`. Because
this CL does not yet contain instruction selection for `wasm.catch`
intrinsic, all `RUN` lines in exception.ll, eh-lsda.ll, and
cfg-stackify-eh.ll, and a single `RUN` line in wasm-eh.cpp (which is an
end-to-end test from C++ source to assembly) fail. So this CL
temporarily disables those `RUN` lines, and for those test files without
any valid remaining `RUN` lines, adds a dummy `RUN` line to make them
pass. These tests will be reenabled in later CLs.

Reviewed By: dschuff, tlively

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

3 years ago[IR] Delete unused ReplaceLast in DebugLoc::appendInlineAt
Fangrui Song [Sat, 9 Jan 2021 07:28:22 +0000 (23:28 -0800)]
[IR] Delete unused ReplaceLast in DebugLoc::appendInlineAt

Not used after r304488

3 years agoRevert "This adds a new test checking llvm-symbolizer with an object built with basic...
Sriraman Tallam [Sat, 9 Jan 2021 06:33:53 +0000 (22:33 -0800)]
Revert "This adds a new test checking llvm-symbolizer with an object built with basic block sections."

This reverts commit 1816de08232673e97ec41287ad3f6494bceaec43.

This breaks on ppc64 and windows  although x86-registered-target is
mentioned.  I will re-commit after fixing.

3 years agoThis adds a new test checking llvm-symbolizer with an object built with basic block...
Sriraman Tallam [Sat, 9 Jan 2021 05:52:34 +0000 (21:52 -0800)]
This adds a new test checking llvm-symbolizer with an object built with basic block sections.

Build a object with -fbasic-block-sections and reorder the basic blocks to be
non-contiguous. Then check if llvm-symbolizer correctly reports the symbolized
addresses. Included the source to build the object with command lines.

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

3 years agoPR47391: Canonicalize DIFiles
Umesh Kalappa [Sat, 9 Jan 2021 05:41:13 +0000 (21:41 -0800)]
PR47391: Canonicalize DIFiles

Like @aprantl suggested, modify to  use the canonicalized DIFile, if we
don't know the  loc info and filename for the compiler generated
functions for example static initialization functions.

Reviewed By: dblaikie, aprantl

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

3 years ago[DWARFLinker] Link against BinaryFormat
Jonas Devlieghere [Sat, 9 Jan 2021 02:57:36 +0000 (18:57 -0800)]
[DWARFLinker] Link against BinaryFormat

3 years ago[debugserver] Various plist changes
Jonas Devlieghere [Sat, 9 Jan 2021 02:53:08 +0000 (18:53 -0800)]
[debugserver] Various plist changes

 - Remove unused plists that were referenced (but unused) by Xcode.
 - Move all debugserver plists unders tools/debugserver/resources.
 - Add the ability to distinguish between com.apple.security.cs.debugger
   and com.apple.private.cs.debugger.

rdar://66082043

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

3 years ago[DWARFLinker] Print the unsupport DWARF form as part of the warning
Jonas Devlieghere [Fri, 8 Jan 2021 19:35:46 +0000 (11:35 -0800)]
[DWARFLinker] Print the unsupport DWARF form as part of the warning

3 years ago[SCEV] Remove unused getExactExistingExpansion (NFC)
Kazu Hirata [Sat, 9 Jan 2021 02:39:57 +0000 (18:39 -0800)]
[SCEV] Remove unused getExactExistingExpansion (NFC)

The last use was removed on Sep 4, 2018 in commit
2cbba5633753552a984572c8b9a5997e5c96496d.

3 years ago[Tablegen] Use llvm::find_if (NFC)
Kazu Hirata [Sat, 9 Jan 2021 02:39:55 +0000 (18:39 -0800)]
[Tablegen] Use llvm::find_if (NFC)

3 years ago[Target, Transforms] Use *Set::contains (NFC)
Kazu Hirata [Sat, 9 Jan 2021 02:39:53 +0000 (18:39 -0800)]
[Target, Transforms] Use *Set::contains (NFC)

3 years ago[RISCV] Optimize multiplication with constant
Ben Shi [Sat, 9 Jan 2021 02:37:21 +0000 (10:37 +0800)]
[RISCV] Optimize multiplication with constant

1. Break MUL with specific constant to a SLLI and an ADD/SUB on riscv32
   with the M extension.
2. Break MUL with specific constant to two SLLI and an ADD/SUB, if the
   constant needs a pair of LUI/ADDI to construct.

Reviewed by: craig.topper

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

3 years ago[clangd][NFC] Remove unnecessary copy in CodeComplete
Nathan James [Sat, 9 Jan 2021 02:32:23 +0000 (02:32 +0000)]
[clangd][NFC] Remove unnecessary copy in CodeComplete

All tests still pass with ASAN so fairly confident no use-after-free going on here.

3 years ago[X86] Remove IntrArgMemOnly from ldmxcsr intrinsic.
Craig Topper [Sat, 9 Jan 2021 01:47:12 +0000 (17:47 -0800)]
[X86] Remove IntrArgMemOnly from ldmxcsr intrinsic.

Since we're leaving this as ReadWrite with the "write" reflecting
the update to MXCSR, we shouldn't say it only writes arg memory.

Hopefully this fixes the issue reported in post-commit in D93571.

3 years ago[AMDGPU] Add volatile support to SIMemoryLegalizer
Tony [Sat, 19 Dec 2020 02:05:11 +0000 (02:05 +0000)]
[AMDGPU] Add volatile support to SIMemoryLegalizer

Treat a non-atomic volatile load and store as a relaxed atomic at
system scope for the address spaces accessed. This will ensure all
relevant caches will be bypassed.

A volatile atomic is not changed and still only bypasses caches upto
the level specified by the SyncScope operand.

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

3 years agoNever call a destroying operator delete when cleaning up from an
Richard Smith [Sat, 9 Jan 2021 00:41:31 +0000 (16:41 -0800)]
Never call a destroying operator delete when cleaning up from an
exception thrown during construction in a new-expression.

Instead, when performing deallocation function lookup for a
new-expression, ignore all destroying operator delete candidates, and
fall back to global operator delete if there is no member operator
delete other than a destroying operator delete.

Use of destroying operator delete only makes sense when there is an
object to destroy, which there isn't in this case. The language wording
doesn't cover this case; this oversight has been reported to WG21, with
the approach in this patch as the proposed fix.

3 years ago[libc][NFC] add includes for internal headers to all libc functions
Michael Jones [Sat, 9 Jan 2021 00:35:00 +0000 (00:35 +0000)]
[libc][NFC] add includes for internal headers to all libc functions

this will make sure that all of the functions are using the correct
prototypes. Explained much better in the comments of this diff:
https://reviews.llvm.org/D94195

3 years ago[libc] Switch to use a macro which does not insert a section for every libc function.
Michael Jones [Wed, 23 Dec 2020 18:46:09 +0000 (18:46 +0000)]
[libc] Switch to use a macro which does not insert a section for every libc function.

Summary:
The new macro also inserts the C alias for the C++ implementations
without needing an objcopy based post processing step. The CMake
rules have been updated to reflect this. More CMake cleanup can be
taken up in future rounds and appropriate TODOs have been added for them.

Reviewers: mcgrathr, sivachandra

Subscribers:

3 years ago[lld-macho] Fix TLV data initialization
Jez Ng [Fri, 8 Jan 2021 23:47:40 +0000 (18:47 -0500)]
[lld-macho] Fix TLV data initialization

We were mishandling the case where both `__tbss` and `__thread_data` sections were
present.

TLVP relocations should be encoded as offsets from the start of `__thread_data`,
even if the symbol is actually located in `__thread_bss`. Previously, we were
writing the offset from the start of the containing section, which doesn't
really make sense since there's no way `tlv_get_addr()` can know which section a
given `tlv$init` symbol is in at runtime.

In addition, this patch ensures that we place `__thread_data` immediately before
`__thread_bss`. This is what ld64 does, likely for performance reasons. Zerofill
sections must also be at the end of their segments; we were already doing this,
but now we ensure that `__thread_bss` occurs before `__bss`, so that it's always
possible to have it contiguous with `__thread_data`.

Fixes llvm.org/PR48657.

Reviewed By: #lld-macho, thakis

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

3 years ago[NewPM] Run ObjC ARC passes
Arthur Eubanks [Wed, 23 Dec 2020 05:41:25 +0000 (21:41 -0800)]
[NewPM] Run ObjC ARC passes

Match the legacy PM in running various ObjC ARC passes.

This requires making some module passes into function passes. These were
initially ported as module passes since they add function declarations
(e.g. https://reviews.llvm.org/D86178), but that's still up for debate
and other passes do so.

Reviewed By: ahatanak

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

3 years agoUpdate the maximum integer bitwidth in MLIR.
Andrew Lenharth [Tue, 5 Jan 2021 21:15:45 +0000 (15:15 -0600)]
Update the maximum integer bitwidth in MLIR.

Large integers are generated in Circt commonly which exceed 4kbits.  This aligns the maximum bitwidth in MLIR and LLVM.

Reviewed By: rriddle, lattner, mehdi_amini

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

3 years agoAttempt to complete an incomplete expression type when considering a
Richard Smith [Fri, 8 Jan 2021 23:17:54 +0000 (15:17 -0800)]
Attempt to complete an incomplete expression type when considering a
reference binding to an expression.

We need to know the array bound in order to determine whether the
parameter type is reference-compatible with the argument type, so we
need to trigger instantiation in this case.

3 years ago[InitLLVM] Ensure SIGPIPE handler installed before sigaction()
Vedant Kumar [Fri, 8 Jan 2021 19:08:52 +0000 (11:08 -0800)]
[InitLLVM] Ensure SIGPIPE handler installed before sigaction()

The pipe signal handler must be installed before any other handlers are
registered. This is because the Unix RegisterHandlers function does not
perform a sigaction() for SIGPIPE unless a one-shot handler is present,
to allow long-lived processes (like lldb) to fully opt-out of llvm's
SIGPIPE handling and ignore the signal safely.

Fixes a bug introduced in D70277.

Tested by running Nick's test case:

% xcrun ./bin/clang -E -fno-integrated-cc1 x.c | tee foo.txt | head

I verified that child cc1 process exits with IO_ERR, and that the parent
recognizes the error code, exiting cleanly.

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

3 years ago[libc++] NFC: Document the Differential queries to avoid duplicating work
Louis Dionne [Fri, 8 Jan 2021 22:23:16 +0000 (17:23 -0500)]
[libc++] NFC: Document the Differential queries to avoid duplicating work

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

3 years ago[mlir][PassManager] Properly set the initialization generation when cloning a pass...
River Riddle [Fri, 8 Jan 2021 22:41:14 +0000 (14:41 -0800)]
[mlir][PassManager] Properly set the initialization generation when cloning a pass manager

Fixes a bug where dynamic pass pipelines of cloned pass managers weren't being initialized properly.

3 years ago[libc++] Mark [P0809] "LWG2831: Comparing Unordered Containers" as Nothing To Do.
Arthur O'Dwyer [Sat, 26 Dec 2020 01:39:36 +0000 (20:39 -0500)]
[libc++] Mark [P0809] "LWG2831: Comparing Unordered Containers" as Nothing To Do.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0809r0.pdf

This issue/paper simply removed some library UB because vendors were
already doing the right thing. libc++ has always done the right thing
(in this respect).

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

3 years ago[libc++] Mark [P0475] "LWG2511: guaranteed copy elision for piecewise construction...
Arthur O'Dwyer [Fri, 25 Dec 2020 21:22:54 +0000 (16:22 -0500)]
[libc++] Mark [P0475] "LWG2511: guaranteed copy elision for piecewise construction" as Complete.

The point of LWG2511 is basically just to make sure that we use
`tuple<Args&&...>` instead of `tuple<Args...>` in a couple of places
inside `scoped_allocator_adaptor` and inside `pair`.
As far as I can tell, this has been true for libc++
since EricWF's D27612 (and maybe even earlier than that).

3 years agoRe-enable __cpp_lib_constexpr_functional.
Arthur O'Dwyer [Fri, 8 Jan 2021 22:28:19 +0000 (17:28 -0500)]
Re-enable __cpp_lib_constexpr_functional.

I accidentally disabled this feature-test macro in my D93830,
due to a rebasing conflict. It had been enabled by my D93815,
and should have remained enabled.

3 years ago[libc++/abi] Re-remove unnecessary null pointer checks from operator delete
Louis Dionne [Thu, 17 Dec 2020 18:26:47 +0000 (13:26 -0500)]
[libc++/abi] Re-remove unnecessary null pointer checks from operator delete

In 7cd67904f776, we removed the unnecessary nullptr checks from the libc++abi
definition of operator delete, but we forgot to update the definition in
libc++ (damn code duplication!). Then, in d4a1e03c5fb5, I synced the
definitions across libc++ and libc++abi, but I did it the wrong way around.
I re-added the if() checks to libc++abi instead of removing them from libc++.

In ef74f0fdc339, we re-removed the if() check from operator delete, but
only in libc++abi. This patch corrects this mess and removes it
consistently in libc++ and libc++abi.

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