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.
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
Philip Reames [Sun, 10 Jan 2021 20:42:08 +0000 (12:42 -0800)]
[Tests] Precommit tests from to simplify rebase
Philip Reames [Sun, 10 Jan 2021 20:26:24 +0000 (12:26 -0800)]
Precommit tests requested for D93725
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.
Philip Reames [Sun, 10 Jan 2021 20:23:22 +0000 (12:23 -0800)]
[Tests] Auto update a vectorizer test to simplify future diff
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.
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
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.
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.
Kazu Hirata [Sun, 10 Jan 2021 17:24:53 +0000 (09:24 -0800)]
[CodeGen, DebugInfo] Use llvm::find_if (NFC)
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.
Nikita Popov [Sun, 10 Jan 2021 16:08:11 +0000 (17:08 +0100)]
[ConstantFold] Add tests for fptoi.sat (NFC)
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
Nico Weber [Sun, 10 Jan 2021 14:35:00 +0000 (09:35 -0500)]
[lld/mac] llvm style fix: no else after return
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.
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
Fangrui Song [Sun, 10 Jan 2021 07:56:55 +0000 (23:56 -0800)]
[test] Improve weakref & weak_import tests
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.
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.
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.
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
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.
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
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
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
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.
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
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
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
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).
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
Jez Ng [Sat, 9 Jan 2021 16:58:19 +0000 (11:58 -0500)]
[lld-macho] Remove unnecessary llvm:: namespace prefixes
Kazu Hirata [Sat, 9 Jan 2021 17:24:59 +0000 (09:24 -0800)]
[llvm] Drop unnecessary make_range (NFC)
Kazu Hirata [Sat, 9 Jan 2021 17:24:58 +0000 (09:24 -0800)]
[Transforms] Use llvm::find_if (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.
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
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
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
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
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
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
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
Fraser Cormack [Sat, 9 Jan 2021 10:29:50 +0000 (10:29 +0000)]
[RISCV] Add tests for scalable constant-folding (NFC)
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
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
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
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
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
Fangrui Song [Sat, 9 Jan 2021 08:46:02 +0000 (00:46 -0800)]
Fix CodeGenCXX/difile_entry.cpp on Windows
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
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
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
Fangrui Song [Sat, 9 Jan 2021 07:28:22 +0000 (23:28 -0800)]
[IR] Delete unused ReplaceLast in DebugLoc::appendInlineAt
Not used after r304488
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.
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
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
Jonas Devlieghere [Sat, 9 Jan 2021 02:57:36 +0000 (18:57 -0800)]
[DWARFLinker] Link against BinaryFormat
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
Jonas Devlieghere [Fri, 8 Jan 2021 19:35:46 +0000 (11:35 -0800)]
[DWARFLinker] Print the unsupport DWARF form as part of the warning
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.
Kazu Hirata [Sat, 9 Jan 2021 02:39:55 +0000 (18:39 -0800)]
[Tablegen] Use llvm::find_if (NFC)
Kazu Hirata [Sat, 9 Jan 2021 02:39:53 +0000 (18:39 -0800)]
[Target, Transforms] Use *Set::contains (NFC)
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
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.
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.
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
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.
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
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:
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
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
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
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.
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
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
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.
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
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).
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.
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
Eugene Zhulenev [Fri, 8 Jan 2021 22:02:25 +0000 (14:02 -0800)]
[mlir] AsyncRuntime: disable mlir-runner init/disable for WIN32
Differential Revision: https://reviews.llvm.org/D94339
Aart Bik [Fri, 8 Jan 2021 18:26:57 +0000 (10:26 -0800)]
[mlir][vector] generalized masked l/s and compressed l/s with indices
Adding the ability to index the base address brings these operations closer
to the transfer read and write semantics (with lowering advantages), ensures
more consistent use in vector MLIR code (easier to read), and reduces the
amount of code duplication to lower memrefs into base addresses considerably
(making codegen less error-prone).
Reviewed By: ThomasRaoux
Differential Revision: https://reviews.llvm.org/D94278
River Riddle [Fri, 8 Jan 2021 21:24:07 +0000 (13:24 -0800)]
[mlir] Add a hook for initializing passes before execution and use it in the Canonicalizer
This revision adds a new `initialize(MLIRContext *)` hook to passes that allows for them to initialize any heavy state before the first execution of the pass. A concrete use case of this is with patterns that rely on PDL, given that PDL is compiled at run time it is imperative that compilation results are cached as much as possible. The first use of this hook is in the Canonicalizer, which has the added benefit of reducing the number of expensive accesses to the context when collecting patterns.
Differential Revision: https://reviews.llvm.org/D93147
Adrian Prantl [Fri, 8 Jan 2021 21:14:52 +0000 (13:14 -0800)]
Don't take the address of a temporary
Eugene Zhulenev [Fri, 8 Jan 2021 16:18:39 +0000 (08:18 -0800)]
[mlir:JitRunner] Use custom shared library init/destroy functions if available
Use custom mlir runner init/destroy functions to safely init and destroy shared libraries loaded by the JitRunner.
This mechanism is ignored for Windows builds (for now) because init/destroy functions are not exported, and library unloading relies on static destructors.
Re-submit https://reviews.llvm.org/D94270 with a temporary workaround for windows
Differential Revision: https://reviews.llvm.org/D94312
Hongtao Yu [Fri, 8 Jan 2021 20:58:03 +0000 (12:58 -0800)]
[Driver] Add DWARF64 flag: -gdwarf64
@ikudrin enabled support for dwarf64 in D87011. Adding a clang flag so it can be used through that compilation pass.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D90507
Martin Storsjö [Fri, 20 Nov 2020 09:33:35 +0000 (11:33 +0200)]
[compiler-rt] [sanitizer] Silence -Wframe-larger-than= for a few windows functions with large stack buffers
Also update a documentation url while touching code nearby, as
requested in review.
Differential Revision: https://reviews.llvm.org/D91853
Saleem Abdulrasool [Fri, 8 Jan 2021 20:44:32 +0000 (20:44 +0000)]
APINotes: annotate dump methods (NFC)
This annotates the dump methods in APINotes to indicate that they are
unused as they are meant for debugging purposes. This avoids an
unnecessary warning.
River Riddle [Fri, 8 Jan 2021 20:29:47 +0000 (12:29 -0800)]
[mlir][PDL] Use ODS for defining PDL types
This removes the need to define these classes and their parser/printers in C++.
Differential Revision: https://reviews.llvm.org/D94135
Matthew Voss [Fri, 8 Jan 2021 18:29:30 +0000 (10:29 -0800)]
[NFC] Specify C11 in loop-opt-setup.c
This test was failing in our internal CI, since our driver does not default to
C11. Adding this switch fixes the issue.
Differential Revision: https://reviews.llvm.org/D94327
Haojian Wu [Tue, 5 Jan 2021 09:26:20 +0000 (10:26 +0100)]
[clangd] Add go-to-def metric.
to track the number of different "special" go-to-def request.
Differential Revision: https://reviews.llvm.org/D94289
MaheshRavishankar [Fri, 8 Jan 2021 19:56:48 +0000 (11:56 -0800)]
[mlir][Linalg] NFC: Refactor fusion of LinalgOp with TensorReshapeOp by expansion.
Change the implementation of LinalgOp with TensorReshapeOp by
expansion to be more modular and easier to follow.
Differential Revision: https://reviews.llvm.org/D93748
Mircea Trofin [Thu, 7 Jan 2021 18:29:39 +0000 (10:29 -0800)]
[NFC] Disallow unused prefixes in CodeGen/AMDGPU
This adds the lit config, and cleans up remaining tests.
Differential Revision: https://reviews.llvm.org/D94245
Craig Topper [Fri, 8 Jan 2021 19:36:24 +0000 (11:36 -0800)]
[RISCV] Cleanup a few section comments in RISCVInstrInfoVPseudos.td. NFC
Raul Tambre [Fri, 8 Jan 2021 19:19:42 +0000 (21:19 +0200)]
[CMake] Fix incorrect rpath for tests if LLVM_LOCAL_RPATH isn't set
d9ce31ae7d (D94322) removed the check because I thought it was dead
due to checking the existance of a variable (which always existed).
This causes LLDB tests to fail as they set NO_INSTALL_RPATH because
they're never meant to be installed, but we still would end up using
the install rpath.
Add the check back and make it explicitly check for an empty value
to make the purpose clearer and avoid implicit test for a false/true
value.
Differential Revision: https://reviews.llvm.org/D94326
Vedant Kumar [Fri, 8 Jan 2021 19:12:08 +0000 (11:12 -0800)]
[Signal] Re-raise SIGPIPE if the handler is uninstalled
Instead of falling through to RunSignalHandlers after the SIGPIPE
handler is uninstalled and we get a SIGPIPE, re-raise the signal, just
like we do for other IntSigs.
This was discussed and informally OK'd here:
https://reviews.llvm.org/rG9a3f892d018238dce5181e458905311db8e682f5#856804
MaheshRavishankar [Fri, 8 Jan 2021 18:52:26 +0000 (10:52 -0800)]
[mlir][Linalg] Add verification checks to disallow illegal reshape ops.
The existing verification of reshape ops in linalg (linalg.reshape and
linalg.tensor_reshape) allows specification of illegal ops, where
- A dynamic dimension is expanded into multiple dynamic
dimensions. This is ill-specified.
- A static dimension is expanded into dynamic dimension or viceversa,
- The product of extents of the static dimensions in the expanded type
doesnt match the static dimension of the collapsed type.
Making all of these illegal. This also implies that some pessimization
in canonicalization due to incomplete semantics of the operation can
be dropped.
Differential Revision: https://reviews.llvm.org/D93724
Raul Tambre [Fri, 8 Jan 2021 18:18:25 +0000 (20:18 +0200)]
Re-land "[CMake] Don't enable BUILD_WITH_INSTALL_RPATH when using custom build rpath"
Reverted check for empty CMAKE_BUILD_RPATH fixed.
When `BUILD_WITH_INSTALL_RPATH` is enabled it prevents using a custom rpath only
for the build tree as the install rpath will be used. This makes it impossible to run a
runtimes build when compiling with Clang and wanting the installed rpath to be
empty (i.e. `-DCMAKE_BUILD_RPATH="<some path>" -DCMAKE_SKIP_INSTALL_RPATH=ON`).
Disable `BUILD_WITH_INSTALL_RPATH` when `CMAKE_BUILD_RPATH` is non-empty to
allow for such build scenarios.
Differential Revision: https://reviews.llvm.org/D94322
Paul C. Anagnostopoulos [Fri, 8 Jan 2021 18:20:27 +0000 (13:20 -0500)]
[TableGen] Fix use of *CurRec when CurRec is null.
I cannot build with the undefined sanitizer on Visual Studio.