Thorsten Schütt [Wed, 17 May 2023 15:36:55 +0000 (17:36 +0200)]
[GlobalIsel][X86] fix legalization of G_CTLZ and G_CTPOP
Note that the builders are protected by is64Bit().
More fine-grained availibility checks.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D150790
Fangrui Song [Thu, 25 May 2023 14:35:38 +0000 (07:35 -0700)]
[ELF] x86-64: place .lrodata, .lbss, and .ldata away from code sections
The x86-64 medium code model utilizes large data sections, namely .lrodata,
.lbss, and .ldata (along with some variants of .ldata). There is a proposal to
extend the use of large data sections to the large code model as well[1].
This patch aims to place large data sections away from code sections in order to
alleviate relocation overflow pressure caused by code sections referencing
regular data sections.
```
.lrodata
.rodata
.text # if --ro-segment, MAXPAGESIZE alignment
RELRO # MAXPAGESIZE alignment
.data # MAXPAGESIZE alignment
.bss
.ldata # MAXPAGESIZE alignment
.lbss
```
In comparison to GNU ld, which places .lbss, .lrodata, and .ldata after .bss, we
place .lrodata above .rodata to minimize the number of permission transitions in
the memory image.
While GNU ld places .lbss after .bss, the subsequent sections don't reuse the
file offset bytes of BSS.
Our approach is to place .ldata and .lbss after .bss and create a PT_LOAD
segment for .bss to large data section transition in the absence of SECTIONS
commands. assignFileOffsets ensures we insert an alignment instead of allocating
space for BSS, and therefore we don't waste more than MAXPAGESIZE bytes. We have
a missing optimization to prevent all waste, but implementing it would introduce
complexity and likely be error-prone.
GNU ld's layout introduces 2 more MAXPAGESIZE alignments while ours
introduces just one.
[1]: https://groups.google.com/g/x86-64-abi/c/jnQdJeabxiU "Large data sections for the large code model"
With help from Arthur Eubanks.
Co-authored-by: James Y Knight <jyknight@google.com>
Reviewed By: aeubanks, tkoeppe
Differential Revision: https://reviews.llvm.org/D150510
Jean Perier [Thu, 25 May 2023 11:11:15 +0000 (04:11 -0700)]
[flang][hlfir] address post-commit comments from D151247 and D151251
Addresses comments not addressed in https://reviews.llvm.org/D151251
and https://reviews.llvm.org/D151247
- Fix typo in comments.
- Update an expected test output to include the fir.allocmem argument.
- Make a more generic type comparisons and cast when fetching value
back from the AnyValueStack temporary storage.
Differential Revision: https://reviews.llvm.org/D151428
Dhruv Chawla [Wed, 24 May 2023 07:25:22 +0000 (12:55 +0530)]
[NFC][DAGCombiner]: Only consider nodes with no uses for pruning when forming initial worklist
When the worklist is initially being formed, there is no need to
consider all nodes for pruning. This is because the first time calling
getNextWorklistEntry will only clear those nodes which have no uses,
with their operands being added to the worklist. However, when the worklist is
created for the first time all nodes are added anyways, so this operation
actually ends up adding no nodes.
This patch adds a parameter IsCandidateForPruning to AddToWorklist with a
default value of true to avoid having to update every call site.
Differential Revision: https://reviews.llvm.org/D151416
Aliia Khasanova [Thu, 25 May 2023 11:36:55 +0000 (13:36 +0200)]
Fix build file for https://github.com/llvm/llvm-project/commit/
12648492998bd22d268eb1d4d476c6c3acc6c43d
Differential Revision: https://reviews.llvm.org/D151427
Alexander Kornienko [Thu, 25 May 2023 12:45:28 +0000 (14:45 +0200)]
[RISCV] Fix -Wunused-variable in release builds. NFCI
Fix -Wunused-variable in release builds
Reviewed By: krasimir
Differential Revision: https://reviews.llvm.org/D151435
Simon Pilgrim [Thu, 25 May 2023 13:13:59 +0000 (14:13 +0100)]
[X86] Regenerate x86-32-intrcc.ll test checks
This will allow us to improve the diffs for D151400
Bjorn Pettersson [Thu, 25 May 2023 10:57:33 +0000 (12:57 +0200)]
[CodeGen] Fix for MachineBasicBlock::rfindDebugLoc(instr_rend())
Make sure we do not crash in rfindDebugLoc when starting at
instr_rend(). Solution is to see it as we start one MI before the
first MI, so we can start searching forward at instr_begin()
instead.
This behavior is similar to how findPrevDebugLoc(instr_end()) works.
Differential Revision: https://reviews.llvm.org/D150577
Bjorn Pettersson [Mon, 15 May 2023 12:40:00 +0000 (14:40 +0200)]
[CodeGen] Add unittest for findDebugLoc, rfindDebugLoc, findPrevDebugLoc and rfindPrevDebugLoc. NFC
- Add some unittests for the findDebugLoc, rfindDebugLoc,
findPrevDebugLoc and rfindPrevDebugLoc helpers in MachineBasicBlock.
- Clean up code comments and code formatting related to the functions
mentioned above.
This was extracted as a pre-commit to D150577, adn some of the tests
are commented out since they would crash/assert in a rather
uncontrolled way.
Alexey Lapshin [Wed, 24 May 2023 13:38:44 +0000 (15:38 +0200)]
[DWARFLinker] Set size of location expression of DW_FORM_block1 properly.
This patch fixes the problem introduced by D147066. As D147066 may change
the contents of location expression, it started to calculate final attribute
size. This patch uses more correct way to calculate size: DIEValue::sizeOf().
Differential Revision: https://reviews.llvm.org/D151348
Martin Braenne [Thu, 25 May 2023 12:02:39 +0000 (12:02 +0000)]
[clang][dataflow][NFC] Remove unused variable.
Thanks to chapuni to pointing this out on
https://reviews.llvm.org/D151183.
Differential Revision: https://reviews.llvm.org/D151430
Marco Elver [Thu, 25 May 2023 11:04:43 +0000 (13:04 +0200)]
[sanitizer_common] Fix StripFunctionName() on Windows
Also implement StripFunctionName() on Windows to properly strip
interceptor prefixes.
Reported-by: https://lab.llvm.org/buildbot#builders/127/builds/48810
Guray Ozen [Thu, 25 May 2023 09:16:46 +0000 (11:16 +0200)]
[mlir] Enable folding memref alias for `ldmatrix`
Folding mechanism does not recognize `ldmatrix` op. This work helps pass to recognize the op and fold the memref aliases.
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D151412
Tom Eccles [Tue, 23 May 2023 11:38:17 +0000 (11:38 +0000)]
[flang][hlfir] fix regression in inline elementals
InlineElementals created a regression when inlining elemental
expressions where the type of the result of the hlfir.apply does not
match the hlfir.yield.
This patch ensures the pass doesn't match in these cases, fixing the
regression.
It isn't clear to me what the /right/ solution is:
- Is it actually valid for the hlfir.apply to have a different type
(even just different array bounds?). Should this be enforced in the
verifier?
- Inserting a convert if these types don't match doesn't work because
fir.convert doesn't know how to convert a hlfir.expr. Should this be
added?
Test case is from @vzakhari
Differential Revision: https://reviews.llvm.org/D151202
John Brawn [Mon, 23 Jan 2023 17:40:59 +0000 (17:40 +0000)]
[Lex] Warn when defining or undefining any builtin macro
Currently we warn when MI->isBuiltinMacro, but this is only true for
builtin macros that require processing when expanding. Checking
SourceMgr.isWrittenInBuiltinFile in addition to this will mean that
we catch all builtin macros, though we shouldn't warn on feature test
macros.
As part of doing this I've also moved the handling of undefining from
CheckMacroName to HandleUndefDirective, as it doesn't really make
sense to handle undefining in CheckMacroName but defining in
HandleDefineDirective. It would be nice to instead handle both in
CheckMacroName, but that isn't possible as the handling of defines
requires looking at what the name is being defined to.
Differential Revision: https://reviews.llvm.org/D144654
Felipe de Azevedo Piovezan [Tue, 23 May 2023 14:27:34 +0000 (10:27 -0400)]
[IRTranslator][NFC] Refactor if/else chain into early returns
This will make it easier to add more cases in a subsequent commit and also
better conforms to the coding guidelines.
Differential Revision: https://reviews.llvm.org/D151328
LLVM GN Syncbot [Thu, 25 May 2023 10:16:02 +0000 (10:16 +0000)]
[gn build] Port
e837f4b7dbc3
Nico Weber [Thu, 25 May 2023 10:15:35 +0000 (06:15 -0400)]
[gn] port
e837f4b7dbc3 (_LIBCPP_PSTL_CPU_BACKEND_SERIAL)
Tomas Matheson [Mon, 22 May 2023 15:33:41 +0000 (16:33 +0100)]
[AArch64] add missing prfm-slc disassembly test
Differential Revision: https://reviews.llvm.org/D151109
Marco Elver [Thu, 25 May 2023 09:10:48 +0000 (11:10 +0200)]
[sanitizer_common] Check 'demangle' flag in StripFunctionName and DemangleFunctionName
To allow getting the original stack trace.
Reviewed By: dvyukov
Differential Revision: https://reviews.llvm.org/D151411
Marco Elver [Thu, 25 May 2023 09:08:06 +0000 (11:08 +0200)]
[msan] Strip __interceptor_ from reports
Showing __interceptor_ as part of the function name in reports does not
make sense and is distracting.
Strip the interceptor function name before printing.
Reviewed By: dvyukov, vitalybuka
Differential Revision: https://reviews.llvm.org/D151343
Marco Elver [Thu, 25 May 2023 09:08:00 +0000 (11:08 +0200)]
[sanitizer_common] Support stripping interceptor prefixes in RenderFrame()
Rather than having every tool pass the right interceptor prefix, just
move this logic into RenderFrame().
Note that currently there are a few cases where due to aliasing the
intercepted function -> interceptor, the unwinder sees the intercepted
function - however this is never guaranteed. In a later change this
becomes more apparent, and other non-tsan sanitizer tests would fail as
well. By making the default RenderFrame() strip interceptor prefixes, we
don't rely on the linker aliasing preferences.
Reviewed By: dvyukov, vitalybuka, MaskRay
Differential Revision: https://reviews.llvm.org/D151319
Marco Elver [Thu, 25 May 2023 09:07:55 +0000 (11:07 +0200)]
[compiler-rt] Unify Linux and *BSD interceptors more
The Linux and *BSD interceptors are almost identical, except for *BSD,
where the overridden intercepted function is not defined weak due to
some incompliant linker behaviour.
Since most of the interception machinery is shared between Linux and
*BSD (see INTERCEPT_FUNCTION macro), it makes sense to unify interceptor
definition and declarations as much as possible to ease future changes.
NFC.
Reviewed By: dvyukov, vitalybuka
Differential Revision: https://reviews.llvm.org/D151318
Marco Elver [Thu, 25 May 2023 09:07:50 +0000 (11:07 +0200)]
[compiler-rt] Introduce asm macros for interceptor trampolines
This introduces macros for asm sources to define trampolines, and
aliases to trampolines.
Because we currently do not yet have any real trampolines, this change
is a NFC.
Reviewed By: dvyukov, vitalybuka
Differential Revision: https://reviews.llvm.org/D151317
Marco Elver [Thu, 25 May 2023 09:07:36 +0000 (11:07 +0200)]
[compiler-rt] Introduce the notion of an interceptor trampoline
To make the interceptor implementation more flexible, allowing for 2
levels of indirection instead of just 1 in the current scheme (where the
intercepted function aliases the interceptor implementation), introduce
the notion of an interceptor "trampoline".
A trampoline may be a real function (and not just an alias, where
aliases of aliases do not work), which will simply forward to the
interceptor implementation; the intercepted function will then alias the
trampoline:
func -[alias]-> trampoline -[call]-> interceptor
Make the necessary changes to prepare for introducing real trampolines.
This change does not yet introduce any real trampolines, and so
trampoline == interceptor, and we currently still just have:
func -[alias]-> interceptor
NFC.
Reviewed By: dvyukov, vitalybuka, MaskRay
Differential Revision: https://reviews.llvm.org/D151316
Jean Perier [Thu, 25 May 2023 09:55:55 +0000 (11:55 +0200)]
[flang][hlfir] Generate temporary storage in Forall/Where [2/2]
Generate temporary storage inside WHERE and FORALL using the temporary
stack runtime. This covers all cases outside of LHS temporary, where the
descriptor stack will have to be used.
Reviewed By: vzakhari
Differential Revision: https://reviews.llvm.org/D151251
Jean Perier [Thu, 25 May 2023 09:17:16 +0000 (11:17 +0200)]
[flang][hlfir] Generate temporary storage in Forall/Where [1/2]
Generate temporary storage inline inside WHERE and FORALL when possible.
A following patch will use the runtime to cover the generic cases.
Reviewed By: vzakhari
Differential Revision: https://reviews.llvm.org/D151247
Serguei Katkov [Wed, 24 May 2023 04:22:54 +0000 (11:22 +0700)]
[GuardUtils] Allow intermmediate blocks between widenable branch and deopt block
Reviewed By: anna
Differential Revision: https://reviews.llvm.org/D151082
Cullen Rhodes [Thu, 25 May 2023 09:13:15 +0000 (09:13 +0000)]
[mlir] Add pass to enable Armv9 Streaming SVE mode
This patch adds a pass 'enable-arm-streaming' that enables the Armv9
Scalable Matrix Extension (SME) Streaming SVE (SSVE) mode [1] by adding
either of the following attributes to 'func.func' ops:
* arm_streaming (default)
* arm_locally_streaming
PATCH [2 / 2] in series for RFC: https://discourse.llvm.org/t/rfc-supporting-armv9-scalable-matrix-extension-sme-streaming-sve-ssve-mode-in-mlir/70678
[1] https://developer.arm.com/documentation/ddi0616/aa
Reviewed By: awarzynski, dcaballe
Differential Revision: https://reviews.llvm.org/D150934
Cullen Rhodes [Thu, 25 May 2023 08:57:19 +0000 (08:57 +0000)]
[mlir][llvm] Add arm_streaming LLVM function attributes
This patch adds two optional attributes to 'llvm.func' op for the Armv9
Streaming SVE (SSVE) mode [1] that map 1-1 with LLVM function attributes [2]:
* arm_streaming -> aarch64_pstate_sm_enabled
* arm_locally_streaming -> aarch64_pstate_sm_body
Streaming-mode is part of the interface (ABI) for functions with the
first attribute and it's the responsibility of the caller to manage
PSTATE.SM on entry/exit to functions with this attribute [3]. The LLVM
backend will emit 'smstart sm' / 'smstop sm' [4] around calls to
streaming functions.
In locally streaming functions PSTATE.SM is kept internal and managed by
the callee on entry/exit. The LLVM backend will emit 'smstart sm' /
'smstop sm' in the prologue / epilogue for functions with this
attribute.
The integration test for SSVE has been updated to no longer use the
passthrough mechanism that's intended for prototyping.
PATCH [1 / 2] in series for RFC: https://discourse.llvm.org/t/rfc-supporting-armv9-scalable-matrix-extension-sme-streaming-sve-ssve-mode-in-mlir/70678
[1] https://developer.arm.com/documentation/ddi0616/aa
[2] https://llvm.org/docs/AArch64SME.html#introduction
[3] https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#671pstatesm-interfaces
[4] https://developer.arm.com/documentation/ddi0602/2023-03/Base-Instructions/SMSTART--Enables-access-to-Streaming-SVE-mode-and-SME-architectural-state--an-alias-of-MSR--immediate--
Reviewed By: awarzynski, dcaballe, WanderAway
Differential Revision: https://reviews.llvm.org/D150932
Tobias Hieta [Thu, 25 May 2023 09:17:29 +0000 (11:17 +0200)]
[NFC] Add more python reformat SHA to .git-blame-ignore-revs
Tobias Hieta [Wed, 17 May 2023 14:59:41 +0000 (16:59 +0200)]
[NFC][Py Reformat] Reformat python files in the rest of the dirs
This is an ongoing series of commits that are reformatting our
Python code. This catches the last of the python files to
reformat. Since they where so few I bunched them together.
Reformatting is done with `black`.
If you end up having problems merging this commit because you
have made changes to a python file, the best way to handle that
is to run git checkout --ours <yourfile> and then reformat it
with black.
If you run into any problems, post to discourse about it and
we will try to help.
RFC Thread below:
https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style
Reviewed By: jhenderson, #libc, Mordante, sivachandra
Differential Revision: https://reviews.llvm.org/D150784
Tobias Hieta [Thu, 25 May 2023 09:16:01 +0000 (11:16 +0200)]
[NFC] Add libcxx python reformat SHA to .git-blame-ignore-revs
Tobias Hieta [Wed, 17 May 2023 09:09:29 +0000 (11:09 +0200)]
[NFC][Py Reformat] Reformat python files in libcxx/libcxxabi
This is an ongoing series of commits that are reformatting our
Python code.
Reformatting is done with `black`.
If you end up having problems merging this commit because you
have made changes to a python file, the best way to handle that
is to run git checkout --ours <yourfile> and then reformat it
with black.
If you run into any problems, post to discourse about it and
we will try to help.
RFC Thread below:
https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style
Reviewed By: #libc, kwk, Mordante
Differential Revision: https://reviews.llvm.org/D150763
Nikita Popov [Thu, 25 May 2023 09:11:42 +0000 (11:11 +0200)]
Revert "[SelectionDAG] Handle NSW for ADD/SUB in computeKnownBits()"
This reverts commit
b66551370fdfc6f357ae0d77237119d2b1077b62.
This has exposed a pre-existing miscompile, reported in
https://reviews.llvm.org/D150769#4370467.
Douglas Yung [Thu, 25 May 2023 09:01:50 +0000 (02:01 -0700)]
Revert "[-Wunsafe-buffer-usage] Group variables associated by pointer assignments"
This reverts commit
ee6b08e99375fc48d1e5848704a66c2e8e57eb3b.
One of the added tests warn-unsafe-buffer-usage-multi-decl-warnings.cpp does
not seem to be deterministic, and seems to be especially problematic on Windows.
Failures of this one test on llvm-clang-x86_64-sie-win:
- https://lab.llvm.org/buildbot/#/builders/216/builds/21758
- https://lab.llvm.org/buildbot/#/builders/216/builds/21761
- https://lab.llvm.org/buildbot/#/builders/216/builds/21762
- https://lab.llvm.org/buildbot/#/builders/216/builds/21765
- https://lab.llvm.org/buildbot/#/builders/216/builds/21770
- https://lab.llvm.org/buildbot/#/builders/216/builds/21771
- https://lab.llvm.org/buildbot/#/builders/216/builds/21773
- https://lab.llvm.org/buildbot/#/builders/216/builds/21776
- https://lab.llvm.org/buildbot/#/builders/216/builds/21777
- https://lab.llvm.org/buildbot/#/builders/216/builds/21778
- https://lab.llvm.org/buildbot/#/builders/216/builds/21779
Other random bot failures:
- https://lab.llvm.org/buildbot/#/builders/65/builds/9821
- https://lab.llvm.org/buildbot/#/builders/65/builds/9822
- https://lab.llvm.org/buildbot/#/builders/65/builds/9824
- https://lab.llvm.org/buildbot/#/builders/119/builds/13440
- https://lab.llvm.org/buildbot/#/builders/119/builds/13442
- https://lab.llvm.org/buildbot/#/builders/119/builds/13444
- https://lab.llvm.org/buildbot/#/builders/119/builds/13445
- https://lab.llvm.org/buildbot/#/builders/60/builds/12156
- https://lab.llvm.org/buildbot/#/builders/60/builds/12157
- https://lab.llvm.org/buildbot/#/builders/60/builds/12160
Alexandros Lamprineas [Wed, 24 May 2023 11:31:05 +0000 (12:31 +0100)]
[FuncSpec] Enable specialization of literal constants.
To do so we have to tweak the cost model such that specialization
does not trigger excessively.
Differential Revision: https://reviews.llvm.org/D150649
Martin Braenne [Tue, 23 May 2023 09:35:52 +0000 (09:35 +0000)]
[clang][dataflow] Add support for return values of reference type.
This patch changes the way `Environment::ReturnLoc` is set: Whereas previously it was set by the caller, it is now set by the callee (obviously, as we otherwise would not be able to return references).
The patch also introduces `Environment::ReturnVal`, which is used for non-reference-type return values. This allows these to be handled with the correct value category semantics; see also https://discourse.llvm.org/t/70086, which describes the ongoing migration to strict value category semantics.
Depends On D150776
Reviewed By: ymandel, xazax.hun
Differential Revision: https://reviews.llvm.org/D151194
Luke Lau [Wed, 24 May 2023 23:48:56 +0000 (00:48 +0100)]
[RISCV] Don't reduce vslidedown's VL in rotations
Even though we only need to write to the bottom NumElts - Rotation
elements for the vslidedown.vi, we can save an extra vsetivli toggle if
we just keep the wide VL.
(I may be missing something here: is there a reason why we want to explicitly keep the vslidedown narrow?)
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D151390
sgokhale [Thu, 25 May 2023 08:24:47 +0000 (13:54 +0530)]
[CodeGen][ShrinkWrap] Enable PostShrinkWrap by default
This is an attempt to reland D42600 and enabling this optimisation by default.
This also resolves the issue pointed out in the context of PGO build.
Differential Revision: https://reviews.llvm.org/D42600
Simon Tatham [Wed, 24 May 2023 08:28:33 +0000 (09:28 +0100)]
-fsanitize=function: fix alignment fault on Arm targets.
Function pointers are checked by loading a prefix structure from just
before the function's entry point. However, on Arm, the function
pointer is not always exactly equal to the address of the entry point,
because Thumb function pointers have the low bit set to tell the BX
instruction to enter them in Thumb state. So the generated code loads
from an odd address and suffers an alignment fault.
Fixed by clearing the low bit of the function pointer before
subtracting 8.
Differential Revision: https://reviews.llvm.org/D151308
Nikita Popov [Mon, 22 May 2023 12:21:56 +0000 (14:21 +0200)]
[KnownBits] Add support for nuw/nsw on shifts
Implement precise nuw/nsw support in the KnownBits implementation,
replacing the rather crude handling in ValueTracking.
Differential Revision: https://reviews.llvm.org/D151208
John Demme [Thu, 25 May 2023 08:01:51 +0000 (08:01 +0000)]
[mlir] Removing unnecessary includes from Memref dialect
`MemRefMemorySlot.cpp` had two unused includes without a cmake
dependency on the dialects they were in. Led to build failures.
Nikita Popov [Thu, 27 Apr 2023 13:11:02 +0000 (15:11 +0200)]
Reapply [SCEV] Replace IsAvailableOnEntry with block disposition
This exposed an issue in SCEVExpander/LCSSA, which has been fixed
in D150681.
-----
As far as I understand, the IsAvailableOnEntry() function basically
implements the same functionality as the properlyDominates() block
disposition. The primary difference (apart from a weaker
implementation) seems to be in this comment at the top:
// Checks if the SCEV S is available at BB. S is considered available at BB
// if S can be materialized at BB without introducing a fault.
However, I don't really understand why there would be such a
requirement. It's my understanding that SCEV explicitly does not
care about trapping udiv instructions itself, and it's the job of
SCEVExpander's isSafeToExpand() to make sure these don't get
expanded if they may trap.
Differential Revision: https://reviews.llvm.org/D149344
Kadir Cetinkaya [Wed, 24 May 2023 12:22:43 +0000 (14:22 +0200)]
[clangd] Dont run raw-lexer for OOB source locations
We can get stale source locations from preamble, make sure we don't
access those locations without checking first.
Fixes https://github.com/clangd/clangd/issues/1636.
Differential Revision: https://reviews.llvm.org/D151321
Nikita Popov [Tue, 16 May 2023 15:05:58 +0000 (17:05 +0200)]
[SCEVExpander] Remember phi nodes inserted by LCSSA construction
SCEVExpander keeps track of all instructions it inserted. However,
it currently misses some phi nodes created during LCSSA construction.
Fix this by collecting these into another argument.
This also removes the IRBuilder argument, which was added for
essentially the same purpose, but only handles the root LCSSA nodes,
not those inserted by SSAUpdater.
This was reported as a regression on D149344, but the reduced test
case also reproduces without it.
Differential Revision: https://reviews.llvm.org/D150681
Mehdi Amini [Thu, 25 May 2023 04:52:05 +0000 (21:52 -0700)]
Fix MLIR bytecode loading of resources
The bytecode reader didn't handle properly the case where resource names
conflicted and were renamed, leading to orphan handles in the IR as well
as overwriting the exiting resources.
Differential Revision: https://reviews.llvm.org/D151408
Mehdi Amini [Thu, 25 May 2023 05:01:48 +0000 (22:01 -0700)]
Specialize OwningOpRef::operator-> to work with pointers like Operation*
This just simplifies user code.
Differential Revision: https://reviews.llvm.org/D151407
Mehdi Amini [Wed, 24 May 2023 23:13:02 +0000 (16:13 -0700)]
Fix MLIR bytecode reader for unregistered dialects
At the moment we accept (in tests) unregistered dialects and in particular:
"new_processor_id_and_range"()
where there is no `.` separator. We probably will remove support for this
from the parser, but for now we're adding compatibility support in the
reader.
Differential Revision: https://reviews.llvm.org/D151386
Matthias Springer [Thu, 25 May 2023 07:22:19 +0000 (09:22 +0200)]
[mlir][IR] Improve `clone` function return type of shaped types
There are `clone` overloads that take a shape as a parameter. These overloads are guaranteed to return a ranked shaped type.
`TensorType::clone`/`BaseMemRefType::clone` used to always return a `TensorType`/`BaseMemRefType`. The variants that take a shape parameter now return a `RankedTensorType`/`MemRefType`. Better static type information can make extra casts at the call site obsolete.
E.g.:
```
{TensorType/RankedTensorType} t;
t.clone({1, 2}) // now returns RankedTensorType instead of TensorType
```
Also improve documentation for `clone`.
Differential Revision: https://reviews.llvm.org/D150865
wangpc [Thu, 25 May 2023 07:22:12 +0000 (15:22 +0800)]
[RISCV][NFC] Simplify decoding code of disassembler
The decoding parts are reduplicative, we add a macro to simplify
the code.
Reviewed By: craig.topper, kito-cheng
Differential Revision: https://reviews.llvm.org/D151309
Hristo Hristov [Tue, 23 May 2023 20:03:35 +0000 (23:03 +0300)]
[libc++][spaceship][NFC] Improved consistency - removed `inline` specifier for `operator<=>`
Removed `inline` specifier for consistency as discussed in D148416 previously.
Reviewed By: #libc, Mordante
Differential Revision: https://reviews.llvm.org/D151248
Martin Braenne [Tue, 23 May 2023 07:32:10 +0000 (07:32 +0000)]
[clang][dataflow] Add a `ControlFlowContext::build()` overload taking a `FunctionDecl`.
This is the most common use case, so it makes sense to have a specific overload for it.
Reviewed By: xazax.hun
Differential Revision: https://reviews.llvm.org/D151183
Matthias Springer [Thu, 25 May 2023 07:12:06 +0000 (09:12 +0200)]
[mlir][Transforms][NFC] GreedyPatternRewriteDriver: Add worklist class
Encapsulate all worklist-related functionality in a separate `Worklist` class. This makes the remaining code more readable and allows for custom worklist implementations (e.g., a randomized worklist for fuzzing pattern application: D142447).
Differential Revision: https://reviews.llvm.org/D151345
Petr Hosek [Tue, 16 May 2023 07:18:26 +0000 (07:18 +0000)]
[lld][ELF] Implement –print-memory-usage
This option was introduced in GNU ld in
https://sourceware.org/legacy-ml/binutils/2015-06/msg00086.html and is
often used in embedded development. This change implements this option
in LLD matching the GNU ld output verbatim.
Differential Revision: https://reviews.llvm.org/D150644
Matthias Springer [Thu, 25 May 2023 06:45:05 +0000 (08:45 +0200)]
[mlir][sparse] Fix incorrect API usage in RewritePatterns
Incorrect API usage was detected by
`MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS`.
Differential Revision: https://reviews.llvm.org/D151302
eopXD [Thu, 25 May 2023 06:47:04 +0000 (23:47 -0700)]
[Clang][RISCV] Update all RVV intrinsic auto-generated test case with new script. NFC
This commit updates all intrinsics under
`clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated` because the
new script of `update_llc_test_checks.py` is generating many new lines
differently.
This NFC commit updates the test cases in a whole batch.
Signed-off by: eop Chen <eop.chen@sifive.com>
Siva Chandra Reddy [Wed, 24 May 2023 17:42:40 +0000 (17:42 +0000)]
[libc][bazel] Add targets for fmod* and scalbn*.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D151354
Siva Chandra Reddy [Wed, 24 May 2023 05:22:40 +0000 (05:22 +0000)]
[libc] Make hermetic test depend on the unit test if it exists.
We want to do this so that build system like ninja don't end up running
the hermetic and unit tests in parallel. Running in parallel can cause
problems for tests which read/write disk files as the hermetic and unit
tests can end up stepping on each other.
Reviewed By: jhuber6
Differential Revision: https://reviews.llvm.org/D151291
Shao-Ce SUN [Thu, 25 May 2023 06:04:02 +0000 (14:04 +0800)]
[RISCV][CodeGen] Support Zdinx on RV32 codegen
This patch was split from D122918 .
Co-Author: @StephenFan @liaolucy @realqhc
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D149743
Sergei Barannikov [Wed, 24 May 2023 04:12:53 +0000 (07:12 +0300)]
[MC] Check if register is non-null before calling isSubRegisterEq (NFCI)
D151036 adds an assertions that prohibits iterating over sub- and
super-registers of a null register. This is already the case when
iterating over register units of a null register, and worked by
accident for sub- and super-registers.
Reviewed By: Amir
Differential Revision: https://reviews.llvm.org/D151285
Siva Chandra Reddy [Wed, 24 May 2023 07:28:50 +0000 (07:28 +0000)]
[libc] Rearrange error and signal tables.
This is largely a cosmetic change done with a few goals:
1. Reduce the conditionals in picking the correct set of tables for the
platform.
2. Avoid exposing, for example Linux errors, when building for non-Linux
platforms. This also prevents build failures when Linux errors are not
defined on the target non-Linux platform.
3. Some "_table" suffixes have been removed to avoid repeated
occurance of "table" like "tables/linux_error_table.h".
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D151367
Aart Bik [Thu, 25 May 2023 03:47:54 +0000 (20:47 -0700)]
[mlir][sparse][gpu] various cuSparse refinements
(1) keep all cuSparse ops on single stream without wait() in right order
(2) use more type precise memref types for COO
(3) use ToTensor on resulting memref (even though it folds away again)
Reviewed By: K-Wu
Differential Revision: https://reviews.llvm.org/D151404
Md Abdullah Shahneous Bari [Thu, 25 May 2023 04:35:08 +0000 (21:35 -0700)]
[mlir][spirv] Add OpConvertPtrToU and OpConvertUToPtr ops
Add the definitions and necessary verifications of these Ops.
Reviewed By: antiagainst
Differential Revision: https://reviews.llvm.org/D151074
Thurston Dang [Thu, 25 May 2023 04:09:35 +0000 (04:09 +0000)]
sanitizer-common: fix buildbot by temporarily disabling release_to_os test for tsan
This has been causing substantial redness in the buildbots e.g.,
https://lab.llvm.org/buildbot/#/builders/239/builds/2405
which already contained a commit to deflake the test
(https://github.com/llvm/llvm-project/commit/
3afd1b2c357fb5353084a736d885af60115d6acb).
Temporarily disabling the test to prevent this error from
hiding other potential problems.
Sergei Barannikov [Wed, 24 May 2023 05:02:50 +0000 (08:02 +0300)]
[MIPS] Check if register is non-null before calling isSuperOrSubRegisterEq (NFCI)
D151036 adds an assertions that prohibits iterating over sub- and
super-registers of a null register. This is already the case when
iterating over register units of a null register, and worked by
accident for sub- and super-registers.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D151288
Sergei Barannikov [Wed, 24 May 2023 09:57:07 +0000 (12:57 +0300)]
[CodeGen] Skip null physical register in AntiDepBreaker (NFCI)
D151036 adds an assertions that prohibits iterating over sub- and
super-registers of a null register. This is already the case when
iterating over register units of a null register, and worked by
accident for sub- and super-registers.
The only place where the assertion is currently triggering is in
CriticalAntiDepBreaker::ScanInstruction. Other places are changed
in case new assertions are added and should be harmless otherwise.
Sergei Barannikov [Thu, 25 May 2023 02:47:00 +0000 (05:47 +0300)]
Revert "[CodeGen] Skip null physical register in AntiDepBreaker (NFCI)"
This reverts commit
d41f6cff030369d99ad62bbdba732552c08d48a6.
The commit contained wrong phabricator link.
Manna, Soumi [Thu, 25 May 2023 02:13:12 +0000 (19:13 -0700)]
[NFC][CLANG] Fix issue with dereference null return value found by Coverity
Reported by Static Analyzer Tool, Coverity:
Inside "SemaDeclCXX.cpp" file, in clang::Sema::CheckExplicitlyDefaultedSpecialMember(clang::CXXMethodDecl *, clang::Sema::CXXSpecialMember, clang::SourceLocation): Return value of function which returns null is dereferenced without checking.
//returned_null: getAs returns nullptr (checked 117 out of 143 times).
// var_assigned: Assigning: Type = nullptr return value from getAs.
const FunctionProtoType *Type = MD->getType()->getAs<FunctionProtoType>();
//Dereference null return value (NULL_RETURNS)
//dereference: Dereferencing a pointer that might be nullptr Type when calling getReturnType.
ReturnType = Type->getReturnType();
//Dereference null return value (NULL_RETURNS)
//dereference: Dereferencing a pointer that might be nullptr Type when calling getParamType.
QualType ArgType = ExpectedParams ? Type->getParamType(0) : QualType();
This patch uses castAs instead of getAs which will assert if the type doesn't match.
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D151281
Rahul Kayaith [Thu, 25 May 2023 02:05:06 +0000 (22:05 -0400)]
[mlir][python] Hook up PyRegionList.__iter__ to PyRegionIterator
This fixes a -Wunused-member-function warning, at the moment
`PyRegionIterator` is never constructed by anything (the only use was
removed in D111697), and iterating over region lists is just falling
back to a generic python iterator object.
Reviewed By: stellaraccident
Differential Revision: https://reviews.llvm.org/D150244
Enna1 [Thu, 25 May 2023 02:11:02 +0000 (10:11 +0800)]
[gcov] Add nosanitize metadata to memory access instructions inserted by emitProfileNotes()
This patch adds nosantize metadata to memory access instructions inserted by gcov emitProfileNotes(), making sanitizers skip these instructions when gcov and sanitizer are used together.
Reviewed By: nickdesaulniers
Differential Revision: https://reviews.llvm.org/D150460
Rahul Kayaith [Thu, 25 May 2023 01:51:36 +0000 (21:51 -0400)]
[mlir][python] Allow specifying block arg locations
Currently blocks are always created with UnknownLoc's for their arguments. This
adds an `arg_locs` argument to all block creation APIs, which takes an optional
sequence of locations to use, one per block argument. If no locations are
supplied, the current Location context is used.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D150084
Vitaly Buka [Thu, 11 May 2023 23:53:30 +0000 (16:53 -0700)]
[NFC][sanitizer] Rename *ThreadRegistry functions
Reviewed By: thurston
Differential Revision: https://reviews.llvm.org/D150407
Hanhan Wang [Thu, 25 May 2023 00:41:29 +0000 (17:41 -0700)]
[mlir][linalg] Only apply masking on xfer_write when needed.
If the input vector sizes are as same as tensor.pad result shape, the
masking is not needed. Otherwise, the masking is needed and the masking
operands should be as same as tensor.empty op.
Reviewed By: dcaballe
Differential Revision: https://reviews.llvm.org/D151391
Vitaly Buka [Wed, 24 May 2023 23:51:12 +0000 (16:51 -0700)]
[hwasan] Fix allocator_interface implementation
__sanitizer_get_current_allocated_bytes had as body, but allocator
caches were not registered to collect stats. It's done by
SizeClassAllocator64LocalCache::Init().
Reviewed By: thurston
Differential Revision: https://reviews.llvm.org/D151389
Aart Bik [Wed, 24 May 2023 20:09:59 +0000 (13:09 -0700)]
[mlir][sparse][gpu] fixed typo in CUDA test
Test was printing same result twice
Reviewed By: K-Wu
Differential Revision: https://reviews.llvm.org/D151370
Kai Sasaki [Thu, 25 May 2023 00:19:32 +0000 (09:19 +0900)]
[mlir][linalg] Treat quant dialect type as unsupported in named conversion
Since the tosa-to-linalg conversion does not support the quant dialect type, we can treat it as unsupported instead of crash. Issue was reported https://github.com/llvm/llvm-project/issues/62367
Reviewed By: springerm
Differential Revision: https://reviews.llvm.org/D151296
Craig Topper [Thu, 25 May 2023 00:25:33 +0000 (17:25 -0700)]
[RISCV] Add a special caes to performVFMADD_VLCombine to support the multiplicand being the same value.
The one use check will fail if there are two uses in the same
instruction. Add a special case for this.
Thurston Dang [Wed, 24 May 2023 20:19:34 +0000 (20:19 +0000)]
hwasan: refactor order of macros in hwasan_platform_interceptors.h [NFC]
Currently, the header file contains all the undefs, followed by all the
define X 0. This will be inconvenient for re-enabling interceptors,
because we would need to comment out (or delete) the corresponding macros
in two different places.
This patch groups together the macros for each function.
Additionally, it adds the suggestion that interceptors should be
re-enabled by commenting out (not deleting) the macros.
Differential Revision: https://reviews.llvm.org/D151371
Vitaly Buka [Sat, 13 May 2023 01:43:53 +0000 (18:43 -0700)]
[AST] Construct Capture objects before use
Msan reports https://reviews.llvm.org/P8308
The reason is if PointerIntPair is not properly
constructed, setPointer uses Info::updatePointer
on uninitialized value.
Reviewed By: #clang, rsmith
Differential Revision: https://reviews.llvm.org/D150504
Md Abdullah Shahneous Bari [Thu, 25 May 2023 00:08:30 +0000 (17:08 -0700)]
[mlir][spirv] Support import/export Functions and GlobalVariables
"LinkageAttributes" decoration allow a SPIR-V module to import
external functions and global variables, or export functions or
global variables for other SPIR-V modules to link against and use.
Import/export capability is extremely important when using outside
libraries (e.g., intrinsic libraries).
Added decorations:
- LinkageAttributes
Reviewed By: antiagainst
Differential Revision: https://reviews.llvm.org/D148749
eopXD [Thu, 25 May 2023 00:02:48 +0000 (17:02 -0700)]
[Clang][RISCV] Update vaadd.c test case with new script. NFC
Vitaly Buka [Wed, 24 May 2023 23:48:01 +0000 (16:48 -0700)]
[sanitizer] Deflake test
Craig Topper [Wed, 24 May 2023 23:37:16 +0000 (16:37 -0700)]
[RISCV] Remove some unneeded vmacc isel patterns.
The patterns are for a vpmerge with an all 1s mask, but we are
able to handle that with a post-isel peephole recently.
Slava Zakharin [Wed, 24 May 2023 20:53:25 +0000 (13:53 -0700)]
[flang][hlfir][NFC] Make BOZ lowering a TODO.
This change just turns the unhandled BOZ fatal error into TODO
like in non-HLFIR path.
Vitaly Buka [Wed, 24 May 2023 23:19:30 +0000 (16:19 -0700)]
[sanitizer] Use atomic_fetch_add instead of load/store
Vitaly Buka [Wed, 24 May 2023 23:12:00 +0000 (16:12 -0700)]
[NFC][sanitizer] Remove unused method
Rashmi Mudduluru [Wed, 24 May 2023 22:45:56 +0000 (15:45 -0700)]
[-Wunsafe-buffer-usage] Group variables associated by pointer assignments
Differential Revision: https://reviews.llvm.org/D145739
Vitaly Buka [Wed, 24 May 2023 22:59:26 +0000 (15:59 -0700)]
[sanitizer] Lazy initialize AllocatorGlobalStats
This allow to have no InitLinkerInitialized and let AllocatorGlobalStats
accept registration before allocator initialization.
Lei Zhang [Wed, 24 May 2023 22:48:54 +0000 (17:48 -0500)]
[mlir][capi] Drop mlirShapedTypeGetTypeID
ShapedType is a virtual type rather than a concrete one.
We don't have an implmentation for this API too.
Reviewed By: makslevental
Differential Revision: https://reviews.llvm.org/D151376
Peng Sun [Wed, 24 May 2023 22:20:56 +0000 (15:20 -0700)]
[mlir][tosa] Update the limit of 62 on shift.
Aligns the shift requirement with the TOSA specification.
Reviewed By: eric-k256
Differential Revision: https://reviews.llvm.org/D151113
Nikolas Klauser [Wed, 24 May 2023 22:33:38 +0000 (15:33 -0700)]
[libc++][PSTL] Add a simple std::thread backend
This is just to test that the PSTL works with parallelization. This is not supposed to be a production-ready backend.
Reviewed By: ldionne, #libc
Spies: EricWF, arichardson, libcxx-commits
Differential Revision: https://reviews.llvm.org/D150284
Nishant Patel [Wed, 24 May 2023 22:23:19 +0000 (15:23 -0700)]
[mlir][spirv] Add a missing pattern to MathToSPIRV Conversion pass
The MathToSPIRV conversion pass missed out a pattern for converting
math::AbsIOP to spirv::CLSAbsOp
Reviewed By: antiagainst
Differential Revision: https://reviews.llvm.org/D151378
Sterling Augustine [Wed, 24 May 2023 22:11:07 +0000 (15:11 -0700)]
remove useless visibility spec from bazel build.
Amara Emerson [Wed, 24 May 2023 21:46:20 +0000 (14:46 -0700)]
Pre-commit a min/max idiom breakage test for D149918
Tai Ly [Wed, 24 May 2023 21:43:02 +0000 (14:43 -0700)]
[TOSA] Refactor TosaMakeBroadcastable pass
This refactors and exposes EqualizeRanks utility function
from within TosaMakeBroadcastable pass so it may be used to
reshape operator inputs to equal ranks.
Signed-off-by: Tai Ly <tai.ly@arm.com>
Differential Revision: https://reviews.llvm.org/D150283
Advenam Tacet [Wed, 24 May 2023 21:26:14 +0000 (14:26 -0700)]
[2a/3][ASan][libcxx] std::deque annotations
This revision is a part of a series of patches extending AddressSanitizer C++ container overflow detection capabilities by adding annotations, similar to those existing in std::vector, to std::string and `std::deque` collections. These changes allow ASan to detect cases when the instrumented program accesses memory which is internally allocated by the collection but is still not in-use (accesses before or after the stored elements for `std::deque`, or between the size and capacity bounds for `std::string`).
The motivation for the research and those changes was a bug, found by Trail of Bits, in a real code where an out-of-bounds read could happen as two strings were compared via a std::equals function that took `iter1_begin`, `iter1_end`, `iter2_begin` iterators (with a custom comparison function). When object `iter1` was longer than `iter2`, read out-of-bounds on `iter2` could happen. Container sanitization would detect it.
This revision introduces annotations for `std::deque`. Each chunk of the container can now be annotated using the `__sanitizer_annotate_double_ended_contiguous_container` function, which was added in the rG1c5ad6d2c01294a0decde43a88e9c27d7437d157. Any attempt to access poisoned memory will trigger an ASan error. Although false negatives are rare, they are possible due to limitations in the ASan API, where a few (usually up to 7) bytes before the container may remain unpoisoned. There are no false positives in the same way as with `std::vector` annotations.
This patch only supports objects (deques) that use the standard allocator. However, it can be easily extended to support all allocators, as suggested in the D146815 revision.
Furthermore, the patch includes the addition of the `is_double_ended_contiguous_container_asan_correct` function to libcxx/test/support/asan_testing.h. This function can be used to verify whether a `std::deque` object has been correctly annotated.
Finally, the patch extends the unit tests to verify ASan annotations (added LIBCPP_ASSERTs).
If a program is compiled without ASan, all helper functions will be no-ops. In binaries with ASan, there is a negligible performance impact since the code from the change is only executed when the deque container changes in size and it’s proportional to the change. It is important to note that regardless of whether or not these changes are in use, every access to the container's memory is instrumented.
Reviewed By: #libc, philnik
Spies: vitalybuka, hans, mikhail.ramalho, Enna1, #sanitizers, philnik, libcxx-commits
Differential Revision: https://reviews.llvm.org/D132092
Valentin Clement [Wed, 24 May 2023 21:00:24 +0000 (14:00 -0700)]
[flang][openacc][NFC] Remove unused function
Now that operands have moved to the new data operands lowering, this
function is not used anymore.
Reviewed By: vzakhari
Differential Revision: https://reviews.llvm.org/D151357
Matt Arsenault [Sat, 10 Dec 2022 13:28:11 +0000 (08:28 -0500)]
AMDGPU: Replace certain llvm.amdgcn.class uses with llvm.is.fpclass
Most transforms should now be performed on llvm.is.fpclass. Unlike the
generic intrinsic, this supports variable test masks.
Mehdi Amini [Wed, 24 May 2023 20:30:49 +0000 (13:30 -0700)]
Fix MLIR bytecode reading of i0 IntegerAttr
The move of the bytecode serialization to be tablegen driven in
https://reviews.llvm.org/D144820 added a new condition in the reading
path that forbid 0-sized integer, even though we still produce them.
Fix #62920
Differential Revision: https://reviews.llvm.org/D151372