PoYao Chang [Thu, 16 Dec 2021 18:32:12 +0000 (13:32 -0500)]
[libunwind] Provide a way to conveniently install libunwind headers
This adds a CMake option (defaults to OFF to not be intrusive) to activate
2 new targets `install-unwind-headers` and `install-unwind-headers-stripped`.
So, for example:
cmake -S runtimes -B build -G Ninja \
-DLLVM_ENABLE_RUNTIMES='libunwind' \
-DLIBUNWIND_INSTALL_HEADERS=ON
And then, `ninja -C build install-unwind` would install headers in addition
to good ol' dylibs and archives, i.e., targets `install-unwind*` `DEPENDS`
on `install-unwind-headers*`. On the other hand,
`ninja -C build install-unwind-headers` gives you headers only.
Differential Revision: https://reviews.llvm.org/D115535
Stuart Brady [Thu, 16 Dec 2021 18:30:58 +0000 (18:30 +0000)]
[OpenCL] Add pure attribute to vload builtins
Use the "pure" attribute (or "readonly") for the vload, vload_half and
vloada_half builtins.
Includes test changes to SemaOpenCL/fdeclare-opencl-builtins.cl to avoid
triggering unused-result warnings.
Reviewed By: svenvh
Differential Revision: https://reviews.llvm.org/D110742
Greg Clayton [Thu, 16 Dec 2021 17:59:25 +0000 (09:59 -0800)]
Added the ability to cache the finalized symbol tables subsequent debug sessions to start faster.
This is an updated version of the https://reviews.llvm.org/D113789 patch with the following changes:
- We no longer modify modification times of the cache files
- Use LLVM caching and cache pruning instead of making a new cache mechanism (See DataFileCache.h/.cpp)
- Add signature to start of each file since we are not using modification times so we can tell when caches are stale and remove and re-create the cache file as files are changed
- Add settings to control the cache size, disk percentage and expiration in days to keep cache size under control
This patch enables symbol tables to be cached in the LLDB index cache directory. All cache files are in a single directory and the files use unique names to ensure that files from the same path will re-use the same file as files get modified. This means as files change, their cache files will be deleted and updated. The modification time of each of the cache files is not modified so that access based pruning of the cache can be implemented.
The symbol table cache files start with a signature that uniquely identifies a file on disk and contains one or more of the following items:
- object file UUID if available
- object file mod time if available
- object name for BSD archive .o files that are in .a files if available
If none of these signature items are available, then the file will not be cached. This keeps temporary object files from expressions from being cached.
When the cache files are loaded on subsequent debug sessions, the signature is compare and if the file has been modified (uuid changes, mod time changes, or object file mod time changes) then the cache file is deleted and re-created.
Module caching must be enabled by the user before this can be used:
symbols.enable-lldb-index-cache (boolean) = false
(lldb) settings set symbols.enable-lldb-index-cache true
There is also a setting that allows the user to specify a module cache directory that defaults to a directory that defaults to being next to the symbols.clang-modules-cache-path directory in a temp directory:
(lldb) settings show symbols.lldb-index-cache-path
/var/folders/9p/472sr0c55l9b20x2zg36b91h0000gn/C/lldb/IndexCache
If this setting is enabled, the finalized symbol tables will be serialized and saved to disc so they can be quickly loaded next time you debug.
Each module can cache one or more files in the index cache directory. The cache file names must be unique to a file on disk and its architecture and object name for .o files in BSD archives. This allows universal mach-o files to support caching multuple architectures in the same module cache directory. Making the file based on the this info allows this cache file to be deleted and replaced when the file gets updated on disk. This keeps the cache from growing over time during the compile/edit/debug cycle and prevents out of space issues.
If the cache is enabled, the symbol table will be loaded from the cache the next time you debug if the module has not changed.
The cache also has settings to control the size of the cache on disk. Each time LLDB starts up with the index cache enable, the cache will be pruned to ensure it stays within the user defined settings:
(lldb) settings set symbols.lldb-index-cache-expiration-days <days>
A value of zero will disable cache files from expiring when the cache is pruned. The default value is 7 currently.
(lldb) settings set symbols.lldb-index-cache-max-byte-size <size>
A value of zero will disable pruning based on a total byte size. The default value is zero currently.
(lldb) settings set symbols.lldb-index-cache-max-percent <percentage-of-disk-space>
A value of 100 will allow the disc to be filled to the max, a value of zero will disable percentage pruning. The default value is zero.
Reviewed By: labath, wallace
Differential Revision: https://reviews.llvm.org/D115324
Jake Egan [Thu, 16 Dec 2021 17:34:31 +0000 (12:34 -0500)]
Adapt test to be compatible with AIX
This patch updates the following test, which is falling to match ASM lines on AIX for two reasons:
- `.debug_info` is mapped to `.dwinfo`, so the test fails to match `debug_info` before `DW_TAG_label` occurs
- AIX uses inline strings, so `DW_AT_NAME` format is different and does not match `DW_AT_decl_file` in the next line.
Reviewed By: shchenz
Differential Revision: https://reviews.llvm.org/D115695
Ben Langmuir [Fri, 10 Dec 2021 19:49:04 +0000 (11:49 -0800)]
Re-apply "Only define LLVM_EXTERNAL_VISIBILITY when building libLLVM dylib"
With a fix for BUILD_SHARED_LIBS.
Original commit message:
When building LLVM static libraries, we should not make symbols more
visible than CMAKE_CXX_VISIBILITY_PRESET, since the goal may be to have
a purely hidden llvm embedded in another library. Instead, we only
define LLVM_EXTERNAL_VISIBILITY for the dynamic library build (when
LLVM_BUILD_LLVM_DYLIB=YES or BUILD_SHARED_LIBS=YES).
Original Review: https://reviews.llvm.org/D113610
Differential Revision: https://reviews.llvm.org/D115825
Tue Ly [Mon, 13 Dec 2021 05:00:49 +0000 (00:00 -0500)]
[libc] Add documentation about how to add a math function to LLVM-libc.
Add documentation about how to add a math function to LLVM-libc.
Differential Revision: https://reviews.llvm.org/D115608
Arthur O'Dwyer [Thu, 7 Oct 2021 01:23:13 +0000 (21:23 -0400)]
[libc++] [test] Simplify sentinel_wrapper and sized_sentinel.
Remove `s.base()`; every test that wants to get the base of a "test sentinel"
should use the ADL `base(s)` from now on.
Differential Revision: https://reviews.llvm.org/D115766
Michał Górny [Thu, 16 Dec 2021 16:11:07 +0000 (17:11 +0100)]
[lldb] Silence CMake warnings about missing FindFBSDVMCore
Pass QUIET to find_package() in order to quiet the warning about missing
FindFBSDVMCore.cmake. FBSDVMCore always provides native CMake config
files, therefore providing a fallback module serves no purpose.
Differential Revision: https://reviews.llvm.org/D115882
Craig Topper [Thu, 16 Dec 2021 16:48:37 +0000 (08:48 -0800)]
[RISCV] Revert Zfhmin related changes that aren't tested and depend on f16 being a legal type.
Our Zfhmin support is only MC layer, but these are CodeGen layer
interfaces. If f16 isn't a Legal type for CodeGen with Zfhmin, then
these interfaces should keep their non-Zfh behavior.
Reviewed By: luismarques
Differential Revision: https://reviews.llvm.org/D115822
Simon Pilgrim [Thu, 16 Dec 2021 16:46:39 +0000 (16:46 +0000)]
[X86] combineAnd - don't demand operand vector elements if the other operand element is zero
If either operand has a zero element, then we don't need the equivalent element from the other operand, as no bits will be set.
Ella Ma [Thu, 16 Dec 2021 16:47:59 +0000 (17:47 +0100)]
[analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file
This error was found when analyzing MySQL with CTU enabled.
When there are space characters in the lookup name, the current
delimiter searching strategy will make the file path wrongly parsed.
And when two lookup names have the same prefix before their first space
characters, a 'multiple definitions' error will be wrongly reported.
e.g. The lookup names for the two lambda exprs in the test case are
`c:@S@G@F@G#@Sa@F@operator int (*)(char)#1` and
`c:@S@G@F@G#@Sa@F@operator bool (*)(char)#1` respectively. And their
prefixes are both `c:@S@G@F@G#@Sa@F@operator` when using the first space
character as the delimiter.
Solving the problem by adding a length for the lookup name, making the
index items in the format of `USR-Length:USR File-Path`.
Reviewed By: steakhal
Differential Revision: https://reviews.llvm.org/D102669
Julian Lettner [Thu, 16 Dec 2021 04:34:39 +0000 (20:34 -0800)]
[TSan] Make test fail more predictably
This test would hang when the system ran out of resources and we fail to
create all 300 threads.
Differential Revision: https://reviews.llvm.org/D115845
Mike Rice [Wed, 15 Dec 2021 18:23:21 +0000 (10:23 -0800)]
[clang] Cleanup unneeded Function nullptr checks [NFC]
Add an assert and avoid unneeded checks of Fn in
CodeGenFunction::GenerateCode.
Differential Revision: https://reviews.llvm.org/D115817
Matt Arsenault [Thu, 16 Dec 2021 15:05:00 +0000 (10:05 -0500)]
AMDGPU: Return result from indicatePessimisticFixpoint
I don't think this fixes anything.
Simon Pilgrim [Thu, 16 Dec 2021 16:22:39 +0000 (16:22 +0000)]
[X86] combineAnd - pull out repeated getOperand() and SDLoc() calls. NFCI.
Simon Pilgrim [Thu, 16 Dec 2021 12:14:18 +0000 (12:14 +0000)]
[X86] Rename LowerScalarImmediateShift/LowerScalarVariableShift helpers. NFC.
Rename them to LowerShiftByScalarImmediate/LowerShiftByScalarVariable to make it easier to find them wrt LowerShift()
Jamie Schmeiser [Thu, 16 Dec 2021 15:51:15 +0000 (10:51 -0500)]
Revert "A new hidden option exec-on-ir-change=exe that calls exe each time IR changes"
This reverts commit
dff0e8b4ff13af311512c369d059f1e095e83a60.
Failing build: https://lab.llvm.org/buildbot/#/builders/42/builds/2800
Tor Arne Vestbø [Thu, 16 Dec 2021 15:46:12 +0000 (16:46 +0100)]
[lldb][docs] Update instructions for building libc++
Reviewed By: sylvestre.ledru
Differential Revision: https://reviews.llvm.org/D115877
Nikita Popov [Thu, 16 Dec 2021 14:36:20 +0000 (15:36 +0100)]
[CodeGen] Avoid more pointer element type accesses
This is enough to build sqlite3 with opaque pointers.
David Spickett [Fri, 10 Dec 2021 14:35:50 +0000 (14:35 +0000)]
[llvm][docs] Describe how to work with patch series on Phabricator
Reviewed By: awarzynski, jhenderson
Differential Revision: https://reviews.llvm.org/D115519
Hans Wennborg [Tue, 19 Oct 2021 15:38:28 +0000 (17:38 +0200)]
Define __STDC_NO_THREADS__ when targeting windows-msvc (PR48704)
MSVC's libc doesn't provide thread.h, so we should set the macro to
indicate that.
We could just set it in C mode, but I noticed that Darwin sets it
unconditionally, so perhaps we should do the same here.
Differential revision: https://reviews.llvm.org/D112081
Nikita Popov [Thu, 16 Dec 2021 15:15:38 +0000 (16:15 +0100)]
[CodeGen] Always update map entry after adding initializer
With opaque pointers the pointer cast may be a no-op, such that
var and castedAddr are the same. However, we still need to update
the map entry as the underlying global changed. We could explicitly
check whether the global was replaced, but we may as well just
always update the entry.
Daniel Kiss [Thu, 16 Dec 2021 15:18:08 +0000 (16:18 +0100)]
[lld] Add cet-report and bti-report flags
Implement cet-report as supported in binutils.
bti-report has the same behaviour for AArch64-BTI.
Fixes https://github.com/llvm/llvm-project/issues/44828
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D113901
Nathan Sidwell [Tue, 12 Oct 2021 16:28:20 +0000 (09:28 -0700)]
Avoid by-value copies of referenced objects
These were detected by the new -Wauto-by-value-copy (D114989) warning, these by-value
constant copies need only be references.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D114990
Nathan Sidwell [Wed, 16 Jun 2021 17:43:43 +0000 (10:43 -0700)]
[clang] p2085 out-of-class comparison operator defaulting
This implements p2085, allowing out-of-class defaulting of comparison
operators, primarily so they need not be inline, IIUC intent. this was
mostly straigh forward, but required reimplementing
Sema::CheckExplicitlyDefaultedComparison, as now there's a case where
we have no a priori clue as to what class a defaulted comparison may
be for. We have to inspect the parameter types to find out. Eg:
class X { ... };
bool operator==(X, X) = default;
Thus reimplemented the parameter type checking, and added 'is this a
friend' functionality for the above case.
Reviewed By: mizvekov
Differential Revision: https://reviews.llvm.org/D104478
Stuart Brady [Thu, 16 Dec 2021 15:16:41 +0000 (15:16 +0000)]
Revert "[OpenCL] Add pure attribute to vload builtins"
This reverts commit
1a376bc285358037a5edc48b0d125f91bf5a69ca.
This broke clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
Valentin Clement [Thu, 16 Dec 2021 15:08:17 +0000 (16:08 +0100)]
[fir] Move Factory.h to flang/Optimizer/Builder
Move the Factory.h header file to flang/Optimizer/Builder.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D115801
Stuart Brady [Thu, 16 Dec 2021 14:55:31 +0000 (14:55 +0000)]
[OpenCL] Add pure attribute to vload builtins
Use the "pure" attribute (or "readonly") for the vload, vload_half and
vloada_half builtins.
Reviewed By: svenvh
Differential Revision: https://reviews.llvm.org/D110742
Alexander Belyaev [Thu, 16 Dec 2021 14:46:08 +0000 (15:46 +0100)]
[mlir] Add canonicalization for extract(tensor.from_elements) in 0d case.
Differential Revision: https://reviews.llvm.org/D115875
Lei Zhang [Thu, 16 Dec 2021 14:35:47 +0000 (09:35 -0500)]
[mlir][spirv] Perform partial conversion in VectorToSPIRVPass
This allows the pass to participate in progressive lowering
and it also allows us to write tests better.
Along the way, cleaned up the tests.
Reviewed By: ThomasRaoux
Differential Revision: https://reviews.llvm.org/D115756
Nikita Popov [Thu, 16 Dec 2021 14:29:26 +0000 (15:29 +0100)]
[CodeGen] Store element type in ParamValue
ParamValue is basically a union between an Address and a Value*.
To be able to reconstruct the Address, we now need to store the
pointer element type.
Florian Hahn [Thu, 16 Dec 2021 14:28:39 +0000 (14:28 +0000)]
[VPlan] Add VPBlockBase::successors() returning an iterator_range (NFC).
This will also be helpful for D115793.
Nikita Popov [Thu, 16 Dec 2021 11:59:45 +0000 (12:59 +0100)]
[CodeGen] Avoid more pointer element type accesses
Sanjay Patel [Thu, 16 Dec 2021 13:37:44 +0000 (08:37 -0500)]
[CodeGen] use saturating FP casts when compiling with "no-strict-float-cast-overflow"
We got an unintended consequence of the optimizer getting smarter when
compiling in a non-standard mode, and there's no good way to inhibit
those optimizations at a later stage. The test is based on an example
linked from D92270.
We allow the "no-strict-float-cast-overflow" exception to normal C
cast rules to preserve legacy code that does not expect overflowing
casts from FP to int to produce UB. See D46236 for details.
Differential Revision: https://reviews.llvm.org/D115804
Neumann Hon [Wed, 15 Dec 2021 22:02:31 +0000 (17:02 -0500)]
[z/OS] Implement prologue and epilogue generation for z/OS target.
This patch adds support for prologue and epilogue generation for the z/OS target under the XPLINK64 ABI for functions with a stack size of less than 1048576 bytes (huge stack frames).
Reviewed By: uweigand
Differential Revision: https://reviews.llvm.org/D114457
Jamie Schmeiser [Thu, 16 Dec 2021 14:00:09 +0000 (09:00 -0500)]
A new hidden option exec-on-ir-change=exe that calls exe each time IR changes
Summary:
A new option exec-on-ir-changed is defined that allows one to specify an
exe that is called after each pass in the opt pipeline that changes the IR.
The exec-on-ir-change=exe option saves the IR in a temporary file and calls exe
with the name of the file and the name of the pass that just changed it after
each pass alters the IR. exe is also called with the initial IR. This
can be used, for example, to determine which pass corrupts the IR by having
exe as a script that calls llc and runs a test to see after which pass the
results change. The print-changed filtering options are respected. Note that
this is only supported with the new pass manager.
Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By: aeubanks (Arthur Eubanks)
Differential Revision: https://reviews.llvm.org/D110776
Alexander Belyaev [Thu, 16 Dec 2021 13:42:27 +0000 (14:42 +0100)]
[mlir] Extend `tensor.from_elements` to support N-D case.
RFC: https://llvm.discourse.group/t/rfc-extend-tensor-fromelementsop-to-n-d/4715
Differential Revision: https://reviews.llvm.org/D115821
Kiran Chandramohan [Thu, 16 Dec 2021 13:39:29 +0000 (13:39 +0000)]
[Flang][NFC] Add test with shape for allocmem and freemem
Reviewed By: awarzynski
Differential Revision: https://reviews.llvm.org/D115797
OCHyams [Thu, 16 Dec 2021 13:41:29 +0000 (13:41 +0000)]
[Dexter] Remove the Windows dependency on lld from CMake
Currently, lld is marked as a dependency on Windows in
cross-project-tests/CMakeLists.txt which means CMake will fail if lld isn't
enabled. The idea of the cross-project-tests is that tests that don't have
their dependencies met should just be unsupported.
Remove the depenency from the CMake step and check whether Dexter's
platform-specific dependencies have been met in
cross-project-tests/lit.cfg.py. If the dependencies are met then add 'dexter'
to the available_features, otherwise don't and the dexter tests will be
"UNSUPPORTED".
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D115872
Yitzhak Mandelbaum [Thu, 16 Dec 2021 13:30:48 +0000 (13:30 +0000)]
[clang][dataflow] Fix unused-variable warning.
Nikolas Klauser [Wed, 15 Dec 2021 20:12:24 +0000 (21:12 +0100)]
[libc++] Add GCC workaround in std::char_traits<char>::length()
GCC currently does not allow `__builtin_strlen()` during constant evaluation. This PR adds a workaround in `std::char_traits<char>::length()`
Reviewed By: Quuxplusone, ldionne, #libc, Mordante
Spies: Mordante, libcxx-commits
Differential Revision: https://reviews.llvm.org/D115795
Paul Altin [Thu, 16 Dec 2021 13:24:09 +0000 (08:24 -0500)]
Allow disabling integer to floating-point narrowing conversions for cppcoreguidelines-narrowing-conversions
This change adds an option to disable warnings from the
cppcoreguidelines-narrowing-conversions check on integer to floating-
point conversions which may be narrowing.
An example of a case where this might be useful:
```
std::vector<double> v = {1, 2, 3, 4};
double mean = std::accumulate(v.cbegin(), v.cend(), 0.0) / v.size();
```
The conversion from std::size_t to double is technically narrowing on
64-bit systems, but v almost certainly does not have enough elements
for this to be a problem.
This option would allow the cppcoreguidelines-narrowing-conversions
check to be enabled on codebases which might otherwise turn it off
because of cases like the above.
Aaron Ballman [Thu, 16 Dec 2021 12:57:14 +0000 (07:57 -0500)]
Fix crash on invalid code involving late parsed inline methods
When parsing the following construct, we parse it as an erroneous
deduction guide declaration and correctly diagnose the issues with it.
template<class> struct B;
struct A { B() noexcept(false); };
However, we then go on to finish late parsing the declaration and this
expects that what we've parsed is a CXXMethodDecl. A
CXXDeductionGuideDecl is not a CXXMethodDecl (it's a FunctionDecl), and
so we assert on the cast.
This fixes the crash by switching from cast<> to dyn_cast<> and not
setting up a "this" scope when the declaration is not a CXXMethodDecl.
This fixes PR49735.
Pavel Labath [Tue, 14 Dec 2021 16:20:23 +0000 (17:20 +0100)]
[lldb] (Semi-automatically) format .swig files
I've found my recent ventures into the swig land painful because
of the strange way they are formatted. This patch attempts to alleviate
future headaches by formatting these files into something resembling the
normal llvm style.
Unfortunately, completely formatting these files automatically does not
work because clang format gets confused by swigs % syntax, so I have
employed a hybrid approach where I formatted blocks of c++ code with
clang-format and then manually massaged the code until it looked
reasonable (and compiled).
I don't expect these files to remain perfectly formatted (although, if
one's editor is configured to configure the current line/block on
request, one can get pretty good results by using it judiciously), but
at least it will prevent the (mangled form of the) old lldb style being
proliferated endlessly.
Differential Revision: https://reviews.llvm.org/D115736
Sjoerd Meijer [Thu, 16 Dec 2021 12:56:11 +0000 (12:56 +0000)]
Revert "[FuncSpec] Decouple cost/benefit analysis, allowing sorting of candidates."
This reverts commit
20b03d65364d963585bf16f175b367f3842f223a.
This shows some failed tests on a bot with expensive checks enabled that I need
to look at.
Diego Caballero [Thu, 16 Dec 2021 12:11:50 +0000 (12:11 +0000)]
[mlir] Fix Bazel build after
32fe1a8a2594
Adding missing dependences.
Sjoerd Meijer [Thu, 16 Dec 2021 11:15:53 +0000 (11:15 +0000)]
[FuncSpec] Decouple cost/benefit analysis, allowing sorting of candidates.
This mostly is the same code that is refactored to decouple the cost and
benefit analysis. The biggest change is top-level function specializeFunctions
that now drives the transformation more like this:
specializeFunctions() {
Cost = getSpecializationCost(F);
calculateGains(F, Cost);
specializeFunction(F);
}
while this is just a restructuring, it helps the functional change in
calculateGains. I.e., we now sort the candidates based on the expected
specialisation gain, which we didn't do before. For this, a book keeping struct
ArgInfo was introduced. If we have a list of N candidates, but we only want
specialise less than N as set by option -func-specialization-max-constants, we
sort the list and discard the candidates that give the least benefit.
Given a formal argument, this change results in selecting the best actual
argument(s). This is NFC'ish in that this shouldn't change the current output
(hence no test change here), but in follow ups starting with D115509, it
should and I want to go one step further and compare all functions and all
arguments, which will mostly build on top of this refactoring and change.
Differential Revision: https://reviews.llvm.org/D115458
Diego Caballero [Thu, 16 Dec 2021 09:47:41 +0000 (09:47 +0000)]
[mlir][GPU] Extend GPU kernel outlining to generate DL specification
This patch extends the GPU kernel outlining pass so that it can take in
an optional data layout specification that will be attached to the GPU
module operation generated. If the data layout specification is not provided
the default data layout is used instead.
Reviewed By: herhut, mehdi_amini
Differential Revision: https://reviews.llvm.org/D115722
Florian Hahn [Thu, 16 Dec 2021 11:28:26 +0000 (11:28 +0000)]
[PPC] Update test after
f5f421e0eefa492.
Nikita Popov [Thu, 16 Dec 2021 10:12:00 +0000 (11:12 +0100)]
[CodeGen] Avoid more pointer element type accesses
Florian Hahn [Thu, 16 Dec 2021 10:52:37 +0000 (10:52 +0000)]
[SCEV] Apply loop guards in reverse order.
This patch updates applyLoopGuards to first collect all conditions and
then applies them in reverse order. This ensures the SCEVs with the
shortest dependency chains are constructed first, limiting the required
stack size.
This fixes a crash reported in D113578.
Note that the order conditions are applied can impact the accuracy of
the result, mostly due to missing min/max simplifications when
constructing SCEVs.
The changed test highlights the impact of the evaluation order. I will
follow up with a SCEV patch to improve min/max simplifications to get
the same results for both orders.
Nikita Popov [Thu, 16 Dec 2021 10:26:13 +0000 (11:26 +0100)]
[CodeGen] Remove an unused MakeAddrLValue() overload (NFC)
This is unused and we should prefer the overloads accepting Address.
Paulo Matos [Thu, 16 Dec 2021 09:45:48 +0000 (10:45 +0100)]
[WebAssembly] Fix typechecking for else MCInst
When hitting an else clause the type Stack should be reset to as it was at the start of the if, without taking into account the Type inserted into the Stack during the then branch of the if.
Reviewed By: aardappel
Differential Revision: https://reviews.llvm.org/D115748
eopXD [Thu, 16 Dec 2021 10:06:11 +0000 (02:06 -0800)]
Revert "[LoopVersioning] Allow versionLoop to create plain branch inst when no runtime check is specified"
This reverts commit
fbf6c8ac1589a4be68ee549257f1d528937ac582.
Hsiangkai Wang [Thu, 16 Dec 2021 09:14:53 +0000 (17:14 +0800)]
[RISCV] Precommit a test for vector copy conversion under implicit-def.
Jay Foad [Wed, 8 Dec 2021 17:35:49 +0000 (17:35 +0000)]
[MachineVerifier] Undef subreg operands do not require subranges
D112556 added verification that the live interval for a subreg operand
must have subranges. This patch fixes a corner case, where if all subreg
operands for a particular register are undef uses then no subranges
are required. This matches how LiveIntervalCalc would build the live
intervals in the first place, since an undef use is not considered
to read the register.
Before this patch, CodeGen/AMDGPU/no-remat-indirect-mov.mir would fail
with -early-live-intervals:
# After Live Interval Analysis
...
*** Bad machine code: Live interval for subreg operand has no subranges ***
- function: index_vgpr_waterfall_loop
- basic block: %bb.1 (0x6a9a968) [352B;496B)
- instruction: 432B %24:vgpr_32 = V_MOV_B32_e32 undef %18.sub0:vreg_512, implicit $exec, implicit %18:vreg_512, implicit $m0
- operand 1: undef %18.sub0:vreg_512
Differential Revision: https://reviews.llvm.org/D115360
Diego Caballero [Thu, 16 Dec 2021 09:45:34 +0000 (09:45 +0000)]
[mlir][vector] Remove default value in populateVectorMultiReductionLoweringPatterns
Having a default value for the lowering strategy of the multi-reduction op has proven
to be unexpected by users. This patch is dropping the default value so that users have
to explicitly choose the lowering strategy to be applied.
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D115805
Nikita Popov [Fri, 10 Dec 2021 08:08:57 +0000 (09:08 +0100)]
[Inline] Disable deferred inlining
After the switch to the new pass manager, we have observed multiple
instances of catastrophic inlining, where the inliner produces huge
functions with many hundreds of thousands of instructions from small
input IR. We were forced to back out the switch to the new pass
manager for this reason. This patch fixes at least one of the root
cause issues.
LLVM uses a bottom-up inliner, and the fact that functions are processed
bottom-up is not just a question of optimality -- it is an imporant
requirement to prevent runaway inlining. The premise of the current
inlining approach and cost model is that after all calls inside a function
have been inlined, it may get large enough that inlining it into its
callers is no longer considered profitable. This safeguard does not
exist if inlining doesn't happen bottom-up, as inlining the callees,
and their callees, and their callees etc. will always seem individually
profitable, and the inliner can easily flatten the whole call tree.
There are instances where we necessarily have to deviate from bottom-up
inlining: When inlining in an SCC there is no natural "bottom", so
inlining effectively happens top-down. This requires special care,
and the inliner avoids exponential blowup by ensuring that functions
in the SCC grow in a balanced way and will eventually hit the threshold.
However, there is one instance where the inlining advisor explicitly
violates the bottom-up principle: Deferred inlining tries to "defer"
inlining a call if it determines that inlining the caller into all
its call-sites would be more profitable. Something very important to
understand about deferred inlining is that it doesn't make one inlining
choice in place of another -- it effectively chooses to do both. If we
have a call chain A -> B -> C and cost modelling tells us that inlining
B -> C is profitable, but we defer this and instead inline A -> B first,
then we'll now have a call A -> C, and the cost model will (a few special
cases notwithstanding) still tell us that this is profitable. So the end
result is that we inlined *both* B and C, even though under the usual
cost model function B would have been too large to further inline after
C has been integrated into it.
Because deferred inlining violates the bottom-up invariant of the inliner,
it can result in exponential inlining. The exponential-deferred-inlining.ll
test case illustrates this on a simple example (see
https://gist.github.com/nikic/
1262b5f7d27278e1b34a190ae10947f5 for a
much more catastrophic case with about 5000x size blowup). If the call
chain A -> B -> C is not a chain but a tree of calls, then we end up
deferring inlining across the tree and end up flattening everything into
the root node.
This patch proposes to address this by disabling deferred inlining
entirely (currently still behind an option). Beyond the issue of
exponential inlining, I don't think that the whole concept makes sense,
at least as long as deferred inlining still ends up inlining both call
edges.
I believe the motivation for having deferred inlining in the first place
is that you might have a small wrapper function with local linkage that
could be eliminated if inlined. This would automatically happen if there
was a single caller, due to the large "last call to local" bonus. However,
this bonus is not extended if there are multiple callers, even if we
would eventually end up inlining into all of them (if the bonus were
extended).
Now, unlike the normal inlining cost model, the deferred inlining cost
model does look at all callers, and will extend the "last call to local"
bonus if it determines that we could inline all of them as long as we
defer the current inlining decision. This makes very little sense.
The "last call to local" bonus doesn't really cost model anything.
It's basically an "infinite" bonus that ensures we always inline the
last call to a local. The fact that it's not literally infinite just
prevents inlining of huge functions, which can easily result in
scalability issues. I very much doubt that it was an intentional
cost-modelling choice to say that getting rid of a small local function
is worth adding 15000 instructions elsewhere, yet this is exactly how
this value is getting used here.
The main alternative I see to complete removal is to change deferred
inlining to an actual either/or decision. That is, to mark deferred
calls as noinline so we're actually trading off one inlining decision
against another, and not just adding a side-channel to the cost model
to do both.
Apart from fixing the catastrophic inlining case, the effect on rustc
is a modest compile-time improvement on average (up to 8% for a
parsing-type crate, where tree-like calls are expected) and pretty
neutral where run-time performance is concerned (mix of small wins
and losses, usually in the sub-1% category).
Differential Revision: https://reviews.llvm.org/D115497
Jan Svoboda [Thu, 16 Dec 2021 08:27:12 +0000 (09:27 +0100)]
[clang][deps] Squash caches for original and minimized files
The minimizing and caching filesystem used by the dependency scanner keeps minimized and original files in separate caches.
This setup is not well suited for dealing with files that are sometimes minimized and sometimes not. Such files are being stat-ed and read twice, which is wasteful and also means the two versions of the file can get "out of sync".
This patch squashes the two caches together. When a file is stat-ed or read, its original contents are populated. If a file needs to be minimized, we give the minimizer the already loaded contents instead of reading the file again.
Reviewed By: dexonsmith
Differential Revision: https://reviews.llvm.org/D115346
Lang Hames [Thu, 16 Dec 2021 06:55:02 +0000 (17:55 +1100)]
[ORC] Add custom object interface support to StaticLibaryDefinitionGenerator.
This adds a GetObjectFileInterface callback member to
StaticLibraryDefinitionGenerator, and adds an optional argument for initializing
that member to StaticLibraryDefinitionGenerator's named constructors. If not
supplied, it will default to getObjectFileInterface from ObjectFileInterface.h.
To enable testing a `-hidden-l<x>` option is added to the llvm-jitlink tool.
This allows archives to be loaded with all contained symbol visibilities demoted
to hidden.
The ObjectLinkingLayer::setOverrideObjectFlagsWithResponsibilityFlags method is
(belatedly) hooked up, and enabled in llvm-jitlink when `-hidden-l<x>` is used
so that the demotion is also applied at symbol resolution time (avoiding any
"mismatched symbol flags" crashes).
Lang Hames [Wed, 15 Dec 2021 05:58:43 +0000 (16:58 +1100)]
[llvm-jitlink] Fix a typo.
Lang Hames [Wed, 15 Dec 2021 05:56:06 +0000 (16:56 +1100)]
[llvm-jitlink] Remove unused struct member.
Yueh-Ting Chen [Thu, 16 Dec 2021 08:26:20 +0000 (00:26 -0800)]
[LoopVersioning] Allow versionLoop to create plain branch inst when no runtime check is specified
After this function call, the LLVM IR would look like the following:
```
if (true)
/* NonVersionedLoop */
else
/* VersionedLoop */
```
Reviewed By: Whitney
Differential Revision: https://reviews.llvm.org/D104631
Nikita Popov [Wed, 15 Dec 2021 08:10:18 +0000 (09:10 +0100)]
[llvm-c] Make LLVMConstGEP/LLVMConstInBoundsGEP opaque pointer compatible
Weirdly, the opaque pointer compatible variants LLVMConstGEP2 and
LLVMConstInBoundsGEP2 were already declared in the header, but not
actually implemented. This adds the missing implementations and
deprecates the incompatible functions.
Differential Revision: https://reviews.llvm.org/D115787
Marek Kurdej [Wed, 15 Dec 2021 15:34:53 +0000 (16:34 +0100)]
[clang-format] Fix tabs when using BreakBeforeTernaryOperators=false.
Fixes https://github.com/llvm/llvm-project/issues/52724.
This is rather a workaround than a correct fix. To properly fix it, we'd need to find a better way to tell when not to decrease the StartOfTokenColumn.
Reviewed By: MyDeveloperDay, owenpan
Differential Revision: https://reviews.llvm.org/D115803
Fangrui Song [Thu, 16 Dec 2021 08:27:19 +0000 (00:27 -0800)]
[ELF] maybeReportUndefined: move sym.isUndefined() check to the caller. NFC
Avoid a function call in the majority of cases.
Nikita Popov [Wed, 15 Dec 2021 11:08:11 +0000 (12:08 +0100)]
[CodeGen] Store ElementType in LValue
Store the pointer element type inside LValue so that we can
preserve it when converting it back into an Address. Storing the
pointer element type might not be strictly required here in that
we could probably re-derive it from the QualType (which would
require CGF access though), but storing it seems like the simpler
solution.
The global register case is special and does not store an element
type, as the value is not a pointer type in that case and it's not
possible to create an Address from it.
This is the main remaining part from D103465.
Differential Revision: https://reviews.llvm.org/D115791
Vitaly Buka [Thu, 16 Dec 2021 08:13:57 +0000 (00:13 -0800)]
[sanitizer] Update global_symbols.txt
Fangrui Song [Thu, 16 Dec 2021 07:59:55 +0000 (23:59 -0800)]
[ELF] parseSymbolVersion: remove unussed pos == 0 check
LLVM GN Syncbot [Thu, 16 Dec 2021 07:22:17 +0000 (07:22 +0000)]
[gn build] Port
db5aceb97939
Mircea Trofin [Wed, 15 Dec 2021 00:15:32 +0000 (16:15 -0800)]
[NFC] Expose the ReleaseModeModelRunner
The type was pretty much generic, just needed a bit of parameterization.
Differential Revision: https://reviews.llvm.org/D115764
jacquesguan [Mon, 13 Dec 2021 12:46:15 +0000 (20:46 +0800)]
[RISCV] Fold (and (not (srl X, C)), 1) to (xor (bexti X, C), 1) when have Zbs extension.
When have Zbs extension, we could use bexti to fold (and (not (srl X, C)), 1) to (xor (bexti X, C), 1).
Differential Revision: https://reviews.llvm.org/D115629
Fangrui Song [Thu, 16 Dec 2021 06:45:27 +0000 (22:45 -0800)]
[ELF] SharedFile::parse: cache symbols size for a loop. NFC
Siva Chandra Reddy [Wed, 15 Dec 2021 23:24:17 +0000 (23:24 +0000)]
[libc] Disable signal.h API and its users.
The signal.h header file from LLVM libc is incorrect. The signal API and
its users will be enabled once signal.h is fixed.
Fangrui Song [Thu, 16 Dec 2021 05:49:53 +0000 (21:49 -0800)]
[ELF] Move -l -L canonical and --library-path --library aliases
Everyone uses -l -L instead of the long option counterparts.
Make help messages attach to -L -l and (--reproduce) use them for response.txt
command line options.
eopXD [Wed, 15 Dec 2021 07:00:01 +0000 (23:00 -0800)]
[LoopIdiom] Use utility from SE instead of local rewriter
ScalarEvolution::applyLoopGuards shall do the work.
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D115784
River Riddle [Thu, 16 Dec 2021 03:47:59 +0000 (03:47 +0000)]
[PDLL] Fix GCC5 build after D115093
River Riddle [Thu, 16 Dec 2021 03:23:52 +0000 (03:23 +0000)]
[PDLL] Fix windows build after D115093
Ellis Hoag [Wed, 15 Dec 2021 23:52:00 +0000 (15:52 -0800)]
[dwarf][NFC] Move expandBundle() to MachO.h
The function `expandBundle()` is defined both in `llvm-dwarfdump.cpp` and
`llvm-gsymutil.cpp` in the exact same way. Reduce code duplication by
moving this function to the `MachOObjectFile` class.
Reviewed By: jhenderson, clayborg
Differential Revision: https://reviews.llvm.org/D115418
jacquesguan [Tue, 14 Dec 2021 11:31:31 +0000 (19:31 +0800)]
[RISCV] Fix whole vector register move instruction's vector register constraint.
According to the v-spec, the source and destination VR of vmv<nr>r.v should be aligned for the VR group size.
Differential Revision: https://reviews.llvm.org/D115720
Matthias Springer [Thu, 16 Dec 2021 02:42:41 +0000 (11:42 +0900)]
[mlir][linalg][bufferize][NFC] Pass BufferizationState into all op interface methods
This allows op interface implementations to make decisions based on dialect-specific bufferization state.
This is in preparation of fixing conflict detection of CallOps in ModuleBufferization.
Differential Revision: https://reviews.llvm.org/D115705
minglotus-6 [Thu, 16 Dec 2021 00:20:19 +0000 (00:20 +0000)]
[ThinLTO] Ignore unreachable virtual functions in WPD in thin LTO.
Differential Revision: https://reviews.llvm.org/D115648
Fangrui Song [Thu, 16 Dec 2021 02:21:48 +0000 (18:21 -0800)]
[ELF] ObjFile<ELFT>::initializeSymbols: don't call Allocate when firstGlobal==0
Calling `Allocate` with 0 size (when .symtab is absent, e.g.
`invalid/mips-invalid-options-descriptor.test`) may return a nullptr, which will
crash with -fsanitize=null (the underlying `Allocate` function is
LLVM_ATTRIBUTE_RETURNS_NONNULL).
River Riddle [Thu, 16 Dec 2021 01:50:03 +0000 (01:50 +0000)]
[PDLL] Add a `rewrite` statement to enable complex rewrites
The `rewrite` statement allows for rewriting a given root
operation with a block of nested rewriters. The root operation is
not implicitly erased or replaced, and any transformations to it
must be expressed within the nested rewrite block. The inner body
may contain any number of other rewrite statements, variables, or
expressions.
Differential Revision: https://reviews.llvm.org/D115299
River Riddle [Thu, 16 Dec 2021 01:49:46 +0000 (01:49 +0000)]
[PDLL] Add a `replace` rewrite statement for replacing operations
This statement acts as a companion to the existing `erase`
statement, and is the corresponding PDLL construct for the
`PatternRewriter::replaceOp` C++ API. This statement replaces a
given operation with a set of values.
Differential Revision: https://reviews.llvm.org/D115298
River Riddle [Thu, 16 Dec 2021 01:49:29 +0000 (01:49 +0000)]
[PDLL] Add support for tuple types and expressions
Tuples are used to group multiple elements into a single
compound value. The values in a tuple can be of any type, and
do not need to be of the same type. There is also no limit to
the number of elements held by a tuple.
Tuples will be used to support multiple results from
Constraints and Rewrites (added in a followup), and will also
make it easier to support more complex primitives (such as
range based maps that can operate on multiple values).
Differential Revision: https://reviews.llvm.org/D115297
River Riddle [Thu, 16 Dec 2021 01:49:11 +0000 (01:49 +0000)]
[PDLL] Add support for `op` Operation expressions
An operation expression in PDLL represents an MLIR operation. In
the match section of a pattern, this expression models one of
the input operations to the pattern. In the rewrite section of
a pattern, this expression models one of the operations to
create. The general structure of the operation expression is very
similar to that of the "generic form" of textual MLIR assembly:
```
let root = op<my_dialect.foo>(operands: ValueRange) {attr = attr: Attr} -> (resultTypes: TypeRange);
```
For now we only model the components that are within PDL, as PDL
gains support for blocks and regions so will this expression.
Differential Revision: https://reviews.llvm.org/D115296
River Riddle [Thu, 16 Dec 2021 01:48:54 +0000 (01:48 +0000)]
[PDLL] Add support for literal Attribute and Type expressions
This allows for using literal attributes and types within PDLL,
which simplifies building both constraints and rewriters. For
example, checking if an attribute is true is as simple as
`attr<"true">`.
Differential Revision: https://reviews.llvm.org/D115295
River Riddle [Thu, 16 Dec 2021 01:48:35 +0000 (01:48 +0000)]
[PDLL] Add support for parsing pattern metadata
This allows for overriding the metadata of a pattern and
providing information such as the benefit, bounded recursion,
and more in the future.
Differential Revision: https://reviews.llvm.org/D115294
River Riddle [Thu, 16 Dec 2021 01:48:19 +0000 (01:48 +0000)]
[mlir][PDLL] Add an initial frontend for PDLL
This is a new pattern rewrite frontend designed from the ground
up to support MLIR constructs, and to target PDL. This frontend
language was proposed in https://llvm.discourse.group/t/rfc-pdll-a-new-declarative-rewrite-frontend-for-mlir/4798
This commit starts sketching out the base structure of the
frontend, and is intended to be a minimal starting point for
building up the language. It essentially contains support for
defining a pattern, variables, and erasing an operation. The
features mentioned in the proposal RFC (including IDE support)
will be added incrementally in followup commits.
I intend to upstream the documentation for the language in a
followup when a bit more of the pieces have been landed.
Differential Revision: https://reviews.llvm.org/D115093
Julian Lettner [Thu, 16 Dec 2021 01:29:08 +0000 (17:29 -0800)]
[TSan][Darwin] Fix CheckAndProtect() for MappingAppleAarch64
In the new TSan runtime refactoring this line was changed:
```
ProtectRange(MetaShadowEnd(), TraceMemBeg());
-->
ProtectRange(MetaShadowEnd(), HeapMemBeg());
```
But for `MappingAppleAarch64` the app heap comes before the shadow,
resulting in:
```
CHECK failed: tsan_platform_posix.cpp:83 "((beg)) <= ((end))" (0xe00000000, 0x200000000)
```
rdar://
86521924
Differential Revision: https://reviews.llvm.org/D115834
Fangrui Song [Thu, 16 Dec 2021 01:59:30 +0000 (17:59 -0800)]
[ELF] Change Symbol::verdefIndex from uint32_t to uint16_t
The SHT_GNU_version index is 16-bit, so the 32-bit value is a waste.
Technically non-default version index 0x7fff uses version index 0xffff,
but it is impossible in practice.
This change decreases sizeof(SymbolUnion) from 80 to 72 on ELF64 platforms.
Memory usage decreases by 1% when linking a large executable.
Richard Smith [Thu, 16 Dec 2021 01:46:22 +0000 (17:46 -0800)]
Julian Lettner [Tue, 14 Dec 2021 23:23:48 +0000 (15:23 -0800)]
[Darwin] Remove workaround for symbolication in iOS simulator runtimes
A while ago we added some code to the sanitizer runtimes for iOS
simulators to allow `atos` (external process) to inspect the sanitized
process during report generation to enable symbolication. This was done
by setting the `__check_mach_ports_lookup` env var early during process
startup which came with a couple of complications.
This workaround is not required anymore and removing it fixes TSan in
the iOS simulator after the new TSan runtime landed.
(https://reviews.llvm.org/D112603)
Relevant/reverted revisions:
https://reviews.llvm.org/D78178
https://reviews.llvm.org/D78179
https://reviews.llvm.org/D78525
rdar://
86472733
Differential Revision: https://reviews.llvm.org/D115767
Arthur O'Dwyer [Fri, 3 Dec 2021 19:55:57 +0000 (14:55 -0500)]
[libc++] Enable the optimized _IsSame on GCC as well as Clang.
However, there's a problem on both GCC and Clang: they can't mangle
`__is_same(T,U)` if it appears anywhere that affects mangling. That's
a hard error. And it turns out that GCC puts dependent return types
into the mangling more aggressively than Clang, so for GCC's benefit
we need to avoid using raw `_IsSame` in the return type of
`swap(tuple&, tuple&)`. Therefore, make `__all` into a named type
instead of an alias.
If we ever need to support a compiler without the __is_same builtin,
we can make this an alias template for `is_same<T,U>::type`.
Differential Revision: https://reviews.llvm.org/D115100
Fangrui Song [Thu, 16 Dec 2021 01:15:31 +0000 (17:15 -0800)]
[ELF] Speed up ObjFile<ELFT>::createInputSection
* Group ".note" section name checks
* Move shouldMerge check to the caller
Vincent Lee [Thu, 9 Dec 2021 02:25:20 +0000 (18:25 -0800)]
[lld-macho] Make writing map file asynchronous
For large applications that write to map files, writing map files can take quite
a bit of time. Sorting the biggest contributors to link times, writing map files
ranks in at 2nd place, with load input files being the biggest contributor of
link times. Avoiding writing map files on the critical path (and having its own
thread) saves ~2-3 seconds when linking chromium framework on a 16-Core
Intel Xeon W.
```
base diff difference (95% CI)
sys_time 1.617 ± 0.034 1.657 ± 0.026 [ +1.5% .. +3.5%]
user_time 28.536 ± 0.245 28.609 ± 0.180 [ -0.1% .. +0.7%]
wall_time 23.833 ± 0.271 21.684 ± 0.194 [ -9.5% .. -8.5%]
samples 31 24
```
Reviewed By: #lld-macho, oontvoo, int3
Differential Revision: https://reviews.llvm.org/D115416
Arthur O'Dwyer [Thu, 16 Dec 2021 00:21:51 +0000 (19:21 -0500)]
[libc++] Reorder a comment pertaining to `struct __two`. NFC.
Fangrui Song [Thu, 16 Dec 2021 00:08:17 +0000 (16:08 -0800)]
[ELF] Symbol::replace: remove dead code
Yuanfang Chen [Thu, 16 Dec 2021 00:03:16 +0000 (16:03 -0800)]
[Verifier] Make error message precise about which variable is being diagnosed.
NFCI.