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.
LLVM GN Syncbot [Wed, 15 Dec 2021 23:47:26 +0000 (23:47 +0000)]
[gn build] Port
2b4876157562
Eric Schweitz [Tue, 14 Dec 2021 17:28:53 +0000 (09:28 -0800)]
Add a new memory allocation rewrite pass.
This pass can reclassify memory allocations (fir.alloca, fir.allocmem)
based on heuristics and settings. The intention is to allow better
performance and workarounds for conditions such as environments with
limited stack space.
Currently, implements two conversions from stack to heap allocation.
1. If a stack allocation is an array larger than some threshold value
make it a heap allocation.
2. If a stack allocation is an array with a runtime evaluated size make
it a heap allocation.
Add a lit test for both suboptions.
Reviewed By: PeteSteinfeld, vdonaldson
Differential Revision: https://reviews.llvm.org/D115763
Fangrui Song [Wed, 15 Dec 2021 23:43:35 +0000 (15:43 -0800)]
[LTO][WPD] Simplify mustBeUnreachableFunction and test after D115492
An well-formed IR function definition must have an entry basic block and
a well-formed IR basic block must have one terminator so the emptiness
check can be simplified.
Also simplify the test a bit.
Reviewed By: luna
Differential Revision: https://reviews.llvm.org/D115780
Nico Weber [Wed, 15 Dec 2021 23:39:21 +0000 (18:39 -0500)]
[gn build] Remove unhelpful default for goma_dir
The default hasn't worked in over 9 months now.
Getting a friendly error message if this isn't set is more useful than getting
a bad default value.
Differential Revision: https://reviews.llvm.org/D115833
Matt Arsenault [Wed, 15 Dec 2021 23:35:01 +0000 (18:35 -0500)]
AMDGPU: Update pass pipeline test
Matt Arsenault [Sat, 11 Dec 2021 17:04:02 +0000 (12:04 -0500)]
Inliner: Correctly merge amdgpu-unsafe-fp-atomics attribute
It seems we don't have already have any target specific attributes
handled in the inliner. Include a separate tablegen file to define the
rules, similar to the target specific intrinsics.
Matt Arsenault [Sat, 11 Dec 2021 17:02:34 +0000 (12:02 -0500)]
AMDGPU: Add baseline test for unsafe fp atomics attribute inlining
Fangrui Song [Wed, 15 Dec 2021 23:30:18 +0000 (15:30 -0800)]
[ELF] ObjFile<ELFT>::initializeSymbols: avoid StringRefZ from undefined symbols
Matt Arsenault [Wed, 15 Dec 2021 16:20:33 +0000 (11:20 -0500)]
AMDGPU: Use v_accvgpr_mov_b32 when copying AGPR tuples on gfx90a
This is an optimization, but also fixes a compile failure when no free
VGPRs are available. The problem still exists for gfx908 where a
scratch register is still required. This also still exists for the
SGPR to AGPR case.
Matt Arsenault [Mon, 13 Dec 2021 20:55:13 +0000 (15:55 -0500)]
AMDGPU: Combine is.shared/is.private of null/undef
Matt Arsenault [Wed, 15 Dec 2021 16:01:03 +0000 (11:01 -0500)]
AMDGPU: Regenerate checks
Matt Arsenault [Tue, 14 Dec 2021 22:55:25 +0000 (17:55 -0500)]
AMDGPU: Remove AMDGPUFixFunctionBitcasts pass
This was a workaround for not supporting indirect calls when
instcombine didn't eliminate constant expression casts of the callee
at -O0. Indirect calls are supposed to work now, so drop the hack.
Fangrui Song [Wed, 15 Dec 2021 23:19:35 +0000 (15:19 -0800)]
[ELF] SymbolTable::insert: keep @@ in the name
* Avoid the name truncation quirk in SymbolTable::insert: the truncated name will be replaced by @@ again.
* Allow foo and foo@@v1 in different files to be diagnosed as duplicate definition error (GNU ld behavior)
* Avoid potential redundant strlen on symbol name due to StringRefZ in ObjFile<ELFT>::initializeSymbols
Andrew Smith [Wed, 15 Dec 2021 23:08:33 +0000 (23:08 +0000)]
[clang-format] Remove spurious JSON binding when DisableFormat = true
Relevant issue: https://github.com/llvm/llvm-project/issues/52705
When the `DisableFormat` option of `clang-format` is set to `true` and a JSON file is formatted, the ephemeral variable binding that is added to the top-level object is not removed from the formatted file. For example, this JSON:
```
{
"key": "value"
}
```
Is reformatted to:
```
x = {
"key": "value"
}
```
Which is not valid JSON syntax. This fix avoids the addition of this binding when `DisableFormat` is set to `true`, ensuring that it cannot be left behind when formatting is disabled.
Reviewed By: MyDeveloperDay, HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D115769
Fixes #52705
mydeveloperday [Wed, 15 Dec 2021 23:05:24 +0000 (23:05 +0000)]
[clang-format] put non-empty catch block on one line with AllowShortBlocksOnASingleLine: Empty
https://github.com/llvm/llvm-project/issues/52715
Fixes #52715
`AllowShortBlocksOnASingleLine` seems to never be checked for "Empty" as such if its used it will be considered "Always" as we only ever check `AllowShortBlocksOnASingleLine != Never`
This impacts C++ as well as C# hence the slightly duplicated test.
Reviewed By: curdeius, jbcoe
Differential Revision: https://reviews.llvm.org/D115794