Anshil Gandhi [Wed, 24 May 2023 16:37:07 +0000 (09:37 -0700)]
[AMDGPUCodegenPrepare] Add NewPM Support
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D151241
Tobias Hieta [Fri, 26 May 2023 06:11:06 +0000 (08:11 +0200)]
[NFC][Py Reformat] Reformat version-check.py in .github dir
Tobias Hieta [Fri, 26 May 2023 06:06:03 +0000 (08:06 +0200)]
[NFC] Add mlir python reformat SHA to .git-blame-ignore-revs
Tobias Hieta [Wed, 17 May 2023 14:53:39 +0000 (16:53 +0200)]
[NFC][Py Reformat] Reformat python files in mlir subdir
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
Differential Revision: https://reviews.llvm.org/D150782
Kazu Hirata [Fri, 26 May 2023 05:56:08 +0000 (22:56 -0700)]
[clang] Modernize SourceLocation (NFC)
Kazu Hirata [Fri, 26 May 2023 05:56:06 +0000 (22:56 -0700)]
[clang-tody] Fix typos in documentation
Tres Popp [Thu, 25 May 2023 14:35:45 +0000 (16:35 +0200)]
[mlir] Update cast/isa method calls to function calls
This updates the rest (at implementation) of MLIR's use of cast/isa
method calls where function calls are possible and automatic refactoring
is not. These changes occured in .td files or in macros.
Context:
- https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…"
- Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443
Tres Popp [Thu, 25 May 2023 13:56:16 +0000 (15:56 +0200)]
[mlir] Move tblgen code generation to use functional forms of cast/isa
Summary:
The method forms are deprecated. This updates the rest of the tblgen
uses of methods where a function call is available.
Context:
- https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…"
- Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443
Reviewers: rriddle
Tres Popp [Tue, 23 May 2023 09:52:31 +0000 (11:52 +0200)]
[mlir] Add CastInfo for mlir classes subclassing from PointerUnion
This is required to use the function variants of cast/isa/dyn_cast/etc
on them.
Context:
- https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…"
- Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443
Kazu Hirata [Fri, 26 May 2023 05:36:48 +0000 (22:36 -0700)]
[flang] Fix an unused variable warning
This patch fixes:
flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIROrderedAssignments.cpp:911:10:
error: unused variable 'inserted' [-Werror,-Wunused-variable]
Nikolas Klauser [Fri, 26 May 2023 05:31:40 +0000 (22:31 -0700)]
[libc++] Fix C++26 transitive includes list
Reviewed By: vitalybuka
Spies: vitalybuka, libcxx-commits
Differential Revision: https://reviews.llvm.org/D151508
Luo, Yuanke [Fri, 26 May 2023 03:47:55 +0000 (11:47 +0800)]
[X86] Add test for select folding.
When avx512 is available the lhs operand of select instruction can be
folded with mask instruction, while the rhs operand can't.
Mehdi Amini [Fri, 26 May 2023 04:50:39 +0000 (21:50 -0700)]
Fix link to the TOSA spec in the dialect doc (NFC)
Fangrui Song [Fri, 26 May 2023 04:23:23 +0000 (21:23 -0700)]
[ELF] findAllByVersion: optimize a find('@') with hasVersionSuffix. NFC
Mehdi Amini [Fri, 26 May 2023 03:58:53 +0000 (20:58 -0700)]
Revert "[MLIR] Add native Bytecode support for properties"
This reverts commit
ca5a12fd69d4acf70c08f797cbffd714dd548348
and follow-up fixes:
df34c288c428eb4b867c8075def48b3d1727d60b
07dc906883af660780cf6d0cc1044f7e74dab83e
ab80ad0095083fda062c23ac90df84c40b4332c8
837d1ce0dc8eec5b17255291b3462e6296cb369b
The first commit was incomplete and broken, I'll prepare a new version
later, in the meantime pull this work out of tree.
Vitaly Buka [Fri, 26 May 2023 03:58:52 +0000 (20:58 -0700)]
[fuzzer] Platfom specific version of PageSize
Mehdi Amini [Fri, 26 May 2023 03:39:26 +0000 (20:39 -0700)]
Bump the MLIR bytecode current revision (version 5) to match the implementation
Mehdi Amini [Fri, 26 May 2023 03:38:32 +0000 (20:38 -0700)]
Fix MLIR Bytecode backward deployment
The condition for guarding the properties section was reversed.
Eugene Burmako [Fri, 26 May 2023 03:17:00 +0000 (20:17 -0700)]
Fix MLIR back-deployment to version < 5 ; properties section should not be emitted.
This was an oversight in the development of bytecode version 5, which was
caught by downstream StableHLO compatibility tests.
Differential revision: https://reviews.llvm.org/D151531
zhanglimin [Fri, 26 May 2023 02:59:39 +0000 (19:59 -0700)]
[fuzzer] Don't hard-code page size in FuzzerUtil.h
Don't hard code the page in FuzzerUtil.h, this breaks on
e.g. LoongArch which defaults to a 16KiB page size.
Reviewed By: #sanitizers, vitalybuka
Differential Revision: https://reviews.llvm.org/D140607
Manna, Soumi [Fri, 26 May 2023 03:00:19 +0000 (20:00 -0700)]
[NFC][CLANG] Fix static code analyzer concerns
Reported by Static Code Analyzer Tool:
Inside "CGExprConstant.cpp" file, VisitObjCEncodeExpr() returns null value which is dereferenced without checking.
This patch adds an assert.
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D151280
Jason Molenda [Fri, 26 May 2023 02:12:04 +0000 (19:12 -0700)]
TestStackCoreScriptedProcess.py is timing out, skip it
The x86_64 macOS CI bot is failing because this test
times out. It was marked as expectedFail earlier today,
but that's not considered a fail so the CI runs are
red. Skipping it on Darwin for now until Ismail can
look into it.
Shilei Tian [Fri, 26 May 2023 02:12:16 +0000 (22:12 -0400)]
[Clang] Simplify test `clang/test/OpenMP/bug59160.c`
David Blaikie [Fri, 26 May 2023 02:07:08 +0000 (02:07 +0000)]
Fix test by marking it x86 specific
Jie Fu [Fri, 26 May 2023 02:02:21 +0000 (10:02 +0800)]
[mlir] Fix non-const lvalue reference to type 'uint64_t' cannot bind to type 'size_t' error (NFC)
/Users/jiefu/llvm-project/mlir/lib/Bytecode/Reader/BytecodeReader.cpp:1007:39: error: non-const lvalue reference to type 'uint64_t' (aka 'unsigned long long') cannot bind to a value of unrelated type 'size_t' (aka 'unsigned long')
if (failed(propReader.parseVarInt(count)))
^~~~~
/Users/jiefu/llvm-project/mlir/lib/Bytecode/Reader/BytecodeReader.cpp:191:39: note: passing argument to parameter 'result' here
LogicalResult parseVarInt(uint64_t &result) {
^
/Users/jiefu/llvm-project/mlir/lib/Bytecode/Reader/BytecodeReader.cpp:1033:41: error: non-const lvalue reference to type 'uint64_t' (aka 'unsigned long long') cannot bind to a value of unrelated type 'size_t' (aka 'unsigned long')
if (failed(dialectReader.readVarInt(propertiesIdx)))
^~~~~~~~~~~~~
/Users/jiefu/llvm-project/mlir/lib/Bytecode/Reader/BytecodeReader.cpp:926:38: note: passing argument to parameter 'result' here
LogicalResult readVarInt(uint64_t &result) override {
^
2 errors generated.
/Users/jiefu/llvm-project/mlir/lib/Bytecode/Reader/BytecodeReader.cpp:1033:41: error: non-const lvalue reference to type 'uint64_t' (aka 'unsigned long long') cannot bind to a value of unrelated type 'size_t' (aka 'unsigned long')
if (failed(dialectReader.readVarInt(propertiesIdx)))
^~~~~~~~~~~~~
/Users/jiefu/llvm-project/mlir/lib/Bytecode/Reader/BytecodeReader.cpp:926:38: note: passing argument to parameter 'result' here
LogicalResult readVarInt(uint64_t &result) override {
^
1 error generated.
Jason Molenda [Fri, 26 May 2023 01:05:10 +0000 (18:05 -0700)]
Revert "[fuzzer] Don't hard-code page size in FuzzerUtil.h"
This reverts commit
a2b677e8153758997a9043360cf51333eecc3c44.
reverting
Differential Revision: https://reviews.llvm.org/D140607
because <sys/auxv.h> and getauxval() are not available on macOS;
this change is breaking the mac CI bots.
David Blaikie [Fri, 26 May 2023 00:59:40 +0000 (00:59 +0000)]
llvm-symbolizer: access the base address from the skeleton CU, not the split unit
In Split DWARF, if the unit had a non-trivial base address (a real
low_pc, rather than one with fixed value 0) then computing addresses
needs to access that base address to add to any base address-relative
values. But the code was trying to access the base address in the split
unit, when it's actually in the skeleton unit. So delegate to the
skeleton if it's available.
Fixes #62941
Shilei Tian [Fri, 26 May 2023 00:40:57 +0000 (20:40 -0400)]
[Clang] Fix test case issue introduced by D141627
Jin Xin Ng [Wed, 24 May 2023 00:04:53 +0000 (00:04 +0000)]
[sanitizer] Implement __sanitizer_get_allocated_size_fast
The primary motivation for this change is to allow FreeHooks to obtain
the allocated size of the pointer being freed in a fast, efficient manner.
Differential Revision: https://reviews.llvm.org/D151360
Shilei Tian [Fri, 26 May 2023 00:18:47 +0000 (20:18 -0400)]
[Clang][OpenMP] Fix the issue that list items in `has_device_addr` are still mapped to the target device
This patch fixes the issue that list items in `has_device_addr` are still mapped
to the target device because front end emits map type `OMP_MAP_TO`.
Fix #59160.
Reviewed By: jyu2
Differential Revision: https://reviews.llvm.org/D141627
Joseph Huber [Fri, 26 May 2023 00:15:02 +0000 (19:15 -0500)]
Revert "[libc] Enable hermetic floating point tests"
This passed locally but unfortauntely it seems some tests are not ready
to be made hermetic. Revert for now until we can investigate
specifically which tests are failing and mark those as `UNIT_TEST_ONLY`.
This reverts commit
417ea79e792a87d53f5ac4f5388af4b25aa04d7d.
Joseph Huber [Wed, 24 May 2023 23:07:39 +0000 (18:07 -0500)]
[libc] Enable hermetic floating point tests
This patch enables us to run the floating point tests as hermetic.
Importantly we now use the internal versions of the `fesetround` and
`fegetround` functions.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D151123
TatWai Chong [Thu, 25 May 2023 23:47:23 +0000 (23:47 +0000)]
[mlir][tosa] Add type checking traits to the appropriate ops
Add the trait `SameOperandsAndResultElementType` and
`SameOperandsElementType` to verify ops that are known
to have the same input and output type rather than generate
an invalid tosa IR with mixed data types like:
"tosa.add"(%0, %1) : (tensor<nxbf16>, tensor<nxf32>) -> tensor<nxf32>
Thus apply tosa.cast prior if needed.
Change-Id: Ie866b84e371e3b571ec04f7abb090c216dd39c33
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D150472
yronglin [Thu, 25 May 2023 23:40:51 +0000 (07:40 +0800)]
[Clang][Attribute] Improve the AST/diagnoses fidelity of alignas and _Alignas
- Fix diagnoses when the argument to `alignas` or `_Alignas` is an incomplete type.
Before:
```
./alignas.cpp:1:15: error: invalid application of 'alignof' to an incomplete type 'void'
class alignas(void) Foo {};
~^~~~~
1 error generated.
```
Now:
```
./alignas.cpp:1:15: error: invalid application of 'alignas' to an incomplete type 'void'
class alignas(void) Foo {};
~^~~~~
1 error generated.
```
- Improve the AST fidelity of `alignas` and `_Alignas` attribute.
Before:
```
AlignedAttr 0x13f07f278 <col:7> alignas
`-ConstantExpr 0x13f07f258 <col:15, col:21> 'unsigned long'
|-value: Int 8
`-UnaryExprOrTypeTraitExpr 0x13f07f118 <col:15, col:21> 'unsigned long' alignof 'void *'
```
Now:
```
AlignedAttr 0x14288c608 <col:7> alignas 'void *'
```
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D150528
zhanglimin [Thu, 25 May 2023 23:10:42 +0000 (16:10 -0700)]
[fuzzer] Don't hard-code page size in FuzzerUtil.h
Don't hard code the page in FuzzerUtil.h, this breaks on
e.g. LoongArch which defaults to a 16KiB page size.
Reviewed By: #sanitizers, vitalybuka
Differential Revision: https://reviews.llvm.org/D140607
Spenser Bauman [Thu, 25 May 2023 23:06:50 +0000 (16:06 -0700)]
[tosa] Improve inferred shapes of TOSA operations
The TosaInferShapes pass avoids updating the shapes of tensor operators
when the consumers are not TOSA operations, limiting the efficacy of
TosaInferShapes when the IR is a mix of TOSA and other operations.
This change attempts to update the result shapes when the consumers
themselves have reasonable type/shape inference methods.
Reviewed By: eric-k256
Differential Revision: https://reviews.llvm.org/D151228
Tue Ly [Wed, 24 May 2023 21:26:55 +0000 (17:26 -0400)]
[libc][darwin] Add OSUtil for darwin arm64 target so that unit tests can be run.
Currently unit tests cannot be run on macOS due to missing OSUtil.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D151377
Tue Ly [Thu, 25 May 2023 19:54:00 +0000 (15:54 -0400)]
[libc][doc] Update math function status page to show more targets.
Show availability of math functions on each target.
Reviewed By: jeffbailey
Differential Revision: https://reviews.llvm.org/D151489
Aart Bik [Thu, 25 May 2023 21:30:58 +0000 (14:30 -0700)]
[mlir][sparse][gpu] end to end test for matmul
(1) minor bug fix in copy back [always nice to run stuff ;-)]
(2) run with and without lib (even though some fall back to CPU)
Reviewed By: wrengr
Differential Revision: https://reviews.llvm.org/D151507
Mehdi Amini [Mon, 1 May 2023 15:43:50 +0000 (08:43 -0700)]
[MLIR] Add native Bytecode support for properties
This is adding a new interface (`BytecodeOpInterface`) to allow operations to
opt-in skipping conversion to attribute and serializing properties to native
bytecode.
The scheme relies on a new section where properties are stored in sequence
{ size, serialize_properties }, ...
The operations are storing the index of a properties, a table of offset is
built when loading the properties section the first time.
Back-deployment to version prior to 4 are relying on getAttrDictionnary() which
we intend to deprecate and remove: that is putting a de-factor end-of-support
horizon for supporting deployments to version older than 4.
Differential Revision: https://reviews.llvm.org/D151065
Mehdi Amini [Tue, 23 May 2023 10:04:21 +0000 (03:04 -0700)]
Add a `-verify-roundtrip` option to `mlir-opt` intended to validate custom printer/parser completeness
Running:
MLIR_OPT_CHECK_IR_ROUNDTRIP=1 ninja check-mlir
will now exercises all of our test with a round-trip to bytecode and a comparison for equality.
Reviewed By: rriddle, ftynse, jpienaar
Differential Revision: https://reviews.llvm.org/D90088
Med Ismail Bennani [Thu, 25 May 2023 22:06:44 +0000 (15:06 -0700)]
[lldb] Disable variable watchpoints when going out of scope
If we use a variable watchpoint with a condition using a scope variable,
if we go out-of-scope, the watpoint remains active which can the
expression evaluator to fail to parse the watchpoint condition (because
of the missing varible bindings).
This was discovered after `watchpoint_callback.test` started failing on
the green dragon bot.
This patch should address that issue by setting an internal breakpoint
on the return addresss of the current frame when creating a variable
watchpoint. The breakpoint has a callback that will disable the watchpoint
if the the breakpoint execution context matches the watchpoint execution
context.
This is only enabled for local variables.
This patch also re-enables the failing test following
e1086384e584.
rdar://
109574319
Differential Revision: https://reviews.llvm.org/D151366
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
Fabian Mora [Thu, 25 May 2023 20:31:57 +0000 (20:31 +0000)]
[mlir][gpu] Add i64 & f64 support to gpu.shuffle
This patch adds support for i64, f64 values in `gpu.shuffle`, rewriting 64bit shuffles into two 32bit shuffles.
The reason behind this change is that both CUDA & HIP support this kind of shuffling.
The implementation provided by this patch is based on the LLVM IR emitted by clang for 64bit shuffles when using `-O3`.
Reviewed By: makslevental
Differential Revision: https://reviews.llvm.org/D148974
Nick Desaulniers [Thu, 25 May 2023 21:29:12 +0000 (14:29 -0700)]
[Demangle] avoid more std::string_view::substr
In D148959, I removed usage of std::string_view::substr because it may
throw, and libcxxabi cannot use such code. I missed one instance in
llvm::starts_with. That is blocking copying the code back upstream in
D148566.
Mark these helpers noexcept (as they are in C++20) as well, to remind
future travelers.
Make these changes upstream, and copy them back downstream using
libcxxabi/src/demangle/cp-to-llvm.sh.
Reviewed By: #libc_abi, MaskRay, ldionne
Differential Revision: https://reviews.llvm.org/D151260
Eugene Burmako [Thu, 25 May 2023 21:24:51 +0000 (14:24 -0700)]
[MLIR] Fixup Bazel build for Add a pattern for transforming gpu.global_id to thread + blockId * blockDim
This patch updates the Bazel build to catch up with changes in https://reviews.llvm.org/D148978.
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D151496
Nick Desaulniers [Thu, 25 May 2023 21:22:47 +0000 (14:22 -0700)]
[libcxxabi] link abort_message into unittest_demangle
unittest_demangle.pass.cpp uses the preprocessor to #include
cxa_demangle.cpp. D148566 will make more use of std::string_view in
libcxxabi rather than the home-grown StringView, but as a result of
D149092, a definition of abort_message needs to be provided.
Otherwise builds of check-cxxabi with -DLLVM_ENABLE_ASSERTIONS=ON will
fail to link with the errors:
/usr/bin/ld: /tmp/lit-tmp-0akcq37p/cc6DLdvw.o: in function `(anonymous namespace)::itanium_demangle::starts_with(std::__1::basic_string_view<char, std::__1::char_traits<char> >, char)':
unittest_demangle.pass.cpp:(.text+0x81): undefined reference to `abort_message'
/usr/bin/ld: /tmp/lit-tmp-0akcq37p/cc6DLdvw.o: in function `(anonymous namespace)::itanium_demangle::starts_with(std::__1::basic_string_view<char, std::__1::char_traits<char> >, std::__1::basic_string_view<char, std::__1::char_traits<char> >)':
unittest_demangle.pass.cpp:(.text+0x2aa): undefined reference to `abort_message'
/usr/bin/ld: unittest_demangle.pass.cpp:(.text+0x312): undefined reference to `abort_message'
/usr/bin/ld: /tmp/lit-tmp-0akcq37p/cc6DLdvw.o: in function `(anonymous namespace)::itanium_demangle::OutputBuffer::writeUnsigned(unsigned long, bool)':
unittest_demangle.pass.cpp:(.text+0x54f): undefined reference to `abort_message'
/usr/bin/ld: unittest_demangle.pass.cpp:(.text+0x5b7): undefined reference to `abort_message'
/usr/bin/ld: /tmp/lit-tmp-0akcq37p/cc6DLdvw.o:unittest_demangle.pass.cpp:(.text+0xe6e): more undefined references to `abort_message' follow
/usr/bin/ld: /home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-
f0560ea595b1-1/llvm-project/libcxx-ci/build/generic-gcc/test/Output/unittest_demangle.pass.cpp.dir/t.tmp.exe: hidden symbol `abort_message' isn't defined
Use the preprocessor further to provide the definition of abort_message
for this unittest.
Reviewed By: #libc_abi, phosek
Differential Revision: https://reviews.llvm.org/D151160
Louis Dionne [Tue, 23 May 2023 18:50:05 +0000 (11:50 -0700)]
[libc++] Add support for generated tests in the libc++ test format
A recurring problem recently has been that libc++ has several generated
tests which all need to be re-generated before committing a change. This
creates noise during code reviews and friction for contributors.
Furthermore, the way we generated most of these tests resulted in
extremely bad compilation times when using modules, because we defined
a macro before compiling each file.
This commit introduces a new kind of test called a '.gen' test. These
tests are normal shell tests, however the Lit test format will run the
test to discover the actual Lit tests it should run. This basically
allows generating a Lit test suite on the fly using arbitrary code,
which can be used in the future to generate tests like our __verbose_abort
tests and several others.
Differential Revision: https://reviews.llvm.org/D151258
Roland McGrath [Thu, 25 May 2023 21:07:24 +0000 (14:07 -0700)]
[libc] Support LIBC_COPT_USE_C_ASSERT build flag
In this mode, LIBC_ASSERT is just standard C assert.
Reviewed By: abrachet
Differential Revision: https://reviews.llvm.org/D151498
Roland McGrath [Thu, 25 May 2023 20:57:47 +0000 (13:57 -0700)]
[libc] Fix compilation issues in memory_check_utils.h
Strict warnings require explicit static_cast to counteract
default widening of types narrower than int.
Functions in header files should have vague linkage (inline
keyword), not internal linkage (static) or external linkage
(no inline keyword) even for template functions. Note these
don't use the LIBC_INLINE macro since this is only for test code.
Reviewed By: abrachet
Differential Revision: https://reviews.llvm.org/D151494
Med Ismail Bennani [Thu, 25 May 2023 20:59:26 +0000 (13:59 -0700)]
Re-revert "[lldb] Move PassthroughScriptedProcess to `lldb.scripted_process` module"
This reverts commit
429e74839506ea8ba962d24647264ed81f680bbf since it
didn't address the test failures on GreenDragon.
This patch will mark the tests as expected to fail until I can reproduce
the issue and find a solution.
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
Alexander Timofeev [Wed, 26 Apr 2023 18:58:17 +0000 (20:58 +0200)]
Don't disable loop unroll for vectorized loops on AMDGPU target
We've got a performance regression after the https://reviews.llvm.org/D115261.
Despite the loop being vectorized unroll is still required.
Reviewed By: rampitec
Differential Revision: https://reviews.llvm.org/D149281
Fabian Mora [Thu, 25 May 2023 20:23:46 +0000 (20:23 +0000)]
[mlir][gpu] Add a pattern for transforming gpu.global_id to thread + blockId * blockDim
This patch implements a rewrite pattern for transforming gpu.global_id x
to gpu.thread_id + gpu.block_id * gpu.block_dim.
Reviewed By: makslevental
Differential Revision: https://reviews.llvm.org/D148978
Congcong Cai [Thu, 25 May 2023 20:07:48 +0000 (22:07 +0200)]
[Sema] cast to CXXRecordDecl correctly when diag a default comparison method
Fixed: https://github.com/llvm/llvm-project/issues/62791
Fixed: https://github.com/llvm/llvm-project/issues/62102
in c++20, default comparison is supported. `getLexicalDeclContext` maybe cannot
get the `CXXRecord` if default comparison defined out of `CXXRecord`.
This patch want to get these information from the first function argument.
Reviewed By: #clang-language-wg, erichkeane
Differential Revision: https://reviews.llvm.org/D151365
Fangrui Song [Thu, 25 May 2023 20:05:43 +0000 (13:05 -0700)]
[ELF][test] Add -NEXT and -NOT after D150644 (–-print-memory-usage)
Zenong Zhang [Thu, 25 May 2023 19:40:56 +0000 (12:40 -0700)]
Reapply: [clang][diagnostics] Adding -Wpacked-non-pod to -Wall
Users will be informed when non-POD is not packed using -Wall. This
is also consistent with GCC.
Fixes PR#60832.
Differential Revision: https://reviews.llvm.org/D151162
Jonas Devlieghere [Thu, 25 May 2023 19:54:56 +0000 (12:54 -0700)]
[NFC] Add more lldb python reformat SHA to .git-blame-ignore-revs
Jonas Devlieghere [Thu, 25 May 2023 15:48:57 +0000 (08:48 -0700)]
[NFC][Py Reformat] Reformat python files in lldb
This is an ongoing series of commits that are reformatting our Python
code. Reformatting is done with `black` (23.1.0).
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.
RFC: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style
Differential revision: https://reviews.llvm.org/D151460
Siva Chandra Reddy [Thu, 25 May 2023 19:29:19 +0000 (19:29 +0000)]
[libc] Add macro LIBC_THREAD_LOCAL.
It resolves to thread_local on all platform except for the GPUs on which
it resolves to nothing. The use of thread_local in the source code has been
replaced with the new macro.
Reviewed By: jhuber6
Differential Revision: https://reviews.llvm.org/D151486
Artem Belevich [Thu, 25 May 2023 19:39:37 +0000 (12:39 -0700)]
[CUDA] Explicitly construct dim3() return values.
Fixes CUDA build break caused by
5c082e7e15e38a2eea1f506725ef
Jan Svoboda [Thu, 25 May 2023 16:22:38 +0000 (09:22 -0700)]
[clang] Make `FileEntryRef::getDir()` return the as-requested `DirectoryEntryRef`
For redirected file entries, `FileEntryRef::getDir()` returns the parent directory entry of the target file entry. This differs from `FileEntry::getDir()` that always returns the parent directory that was last used to look up that file.
After switching from `FileEntry` to `FileEntryRef` for umbrella headers in D142113, this discrepancy became observable and caused Clang to emit incorrect diagnostics.
This patch changes Clang so that it always associates `FileEntryRef` with the parent directory that was used to look it up. This brings its behavior closer to `FileEntry`, but without the hacky mutation.
This also ensures that `llvm::sys::path::parent_path(FileRef->getNameAsRequested()) == FileRef->getDir()->getName()`. Previously, `FileRef->getDir()` would fall underneath the redirecting VFS into the world of on-disk paths.
Reviewed By: benlangmuir, rmaz
Differential Revision: https://reviews.llvm.org/D151398
Thurston Dang [Thu, 25 May 2023 19:16:38 +0000 (19:16 +0000)]
[sanitizer] Add new symbolizer symbol
wmemchr symbol is required after https://reviews.llvm.org/D144394
(see https://lab.llvm.org/buildbot/#/builders/37/builds/22340 for error message)
Differential Revision: https://reviews.llvm.org/D151484
Peiming Liu [Thu, 25 May 2023 18:35:28 +0000 (18:35 +0000)]
[mlir][sparse] fix bugs when computing the memory size when lowering pack op.
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D151481
Artem Belevich [Mon, 22 May 2023 23:32:50 +0000 (16:32 -0700)]
[CUDA] Add CUDA wrappers over clang builtins for sm_90.
Differential Revision: https://reviews.llvm.org/D151362
Artem Belevich [Wed, 24 May 2023 00:05:30 +0000 (17:05 -0700)]
[NVPTX, CUDA] barrier intrinsics and builtins for sm_90
Differential Revision: https://reviews.llvm.org/D151363
Artem Belevich [Mon, 22 May 2023 22:14:40 +0000 (15:14 -0700)]
[CUDA] plumb through new sm_90-specific builtins.
Differential Revision: https://reviews.llvm.org/D151168
Artem Belevich [Fri, 19 May 2023 20:21:28 +0000 (13:21 -0700)]
[NVPTX] add new sm90-specific intrinsics.
Differential Revision: https://reviews.llvm.org/D151009
Artem Belevich [Wed, 24 May 2023 00:51:09 +0000 (17:51 -0700)]
[CUDA] bump supported CUDA version to 12.1/11.8
Differential Revision: https://reviews.llvm.org/D151361
Artem Belevich [Wed, 24 May 2023 19:13:41 +0000 (12:13 -0700)]
[CUDA] Relax restrictions on variadics in host-side compilation.
D150718 allows variadics during GPU compilation, but we also need to do it for
the host compilation as well, as it will see the same code.
Differential Revision: https://reviews.llvm.org/D151359
Alex Brachet [Thu, 25 May 2023 18:55:47 +0000 (18:55 +0000)]
[compiler-rt] Use ZLIB_FOUND not LLVM_ENABLE_ZLIB
LLVM_ENABLE_ZLIB is set to On by default and does not imply that ZLIB
was actually found, only being set to FORCE_ON would imply that it was
found before control reached compiler-rt/test/CMakeLists.txt. Instead,
use ZLIB_FOUND which guarantees that zlib is available.
Differential Revision: https://reviews.llvm.org/D151229
Aaron Ballman [Thu, 25 May 2023 18:50:51 +0000 (14:50 -0400)]
Revert "[clang][diagnostics] Add -Wpacked-non-pod to -Wall"
This reverts commit
9ed3d85e26d8594440bca84fe868a62ac6560ac8.
It broke some bots:
https://lab.llvm.org/buildbot/#/builders/245/builds/8876
Austin Chang [Thu, 25 May 2023 17:10:31 +0000 (12:10 -0500)]
[InstCombine] Improve bitreverse optimization
This patch utilizes the helper function implemented in D149699 and thus folds the following cases:
```
bitreverse(logic_op(x, bitreverse(y))) -> logic_op(bitreverse(x), y)
bitreverse(logic_op(bitreverse(x), y)) -> logic_op(x, bitreverse(y))
bitreverse(logic_op(bitreverse(x), bitreverse(y))) -> logic_op(x, y) in multiuse case
```
Reviewed By: goldstein.w.n, RKSimon
Differential Revision: https://reviews.llvm.org/D151246
Austin Chang [Thu, 25 May 2023 17:10:31 +0000 (12:10 -0500)]
[InstCombine] Add regression test cases for bitreverse optimization; NFC
Fold the following case on IR InstCombine pass. This patch includes the new test cases for this optimization
```
bitreverse(logic_op(x, bitreverse(y))) -> logic_op(bitreverse(x), y)
bitreverse(logic_op(bitreverse(x), y)) -> logic_op(x, bitreverse(y))
bitreverse(logic_op(bitreverse(x), bitreverse(y))) -> logic_op(x, y) with multi-use
```
Reviewed By: goldstein.w.n
Differential Revision: https://reviews.llvm.org/D151245
Rashmi Mudduluru [Thu, 25 May 2023 18:28:03 +0000 (11:28 -0700)]
[-Wunsafe-buffer-usage] Group variables associated by pointer assignments
Differential Revision: https://reviews.llvm.org/D145739
Zenong Zhang [Thu, 25 May 2023 18:17:29 +0000 (14:17 -0400)]
[clang][diagnostics] Add -Wpacked-non-pod to -Wall
Users will be informed when non-POD is not packed using -Wall. This is
also consistent with GCC.
Fixes https://github.com/llvm/llvm-project/issues/60832
Differential Revision: https://reviews.llvm.org/D151162
Chia-hung Duan [Thu, 25 May 2023 17:36:10 +0000 (17:36 +0000)]
[scudo] releaseToOSMaybe can fail if it can't allocate PageMap
PageMap is allocated with MAP_ALLOWNOMEM if there's no static buffer
left. So it can be failed and return nullptr without any assertion
triggered. Instead of crashing in the releaseToOSMaybe in the middle,
just return and let the program handles the page failure.
Reviewed By: cferris
Differential Revision: https://reviews.llvm.org/D151379
Craig Topper [Thu, 25 May 2023 18:01:19 +0000 (11:01 -0700)]
[SelectionDAG][AArch64][ARM] Remove setFlags call from DAGTypeLegalizer::SetPromotedInteger.
This was originally added to preserve FMF on SETCC. Unfortunately,
it also incorrectly preserves nuw/nsw on ADD/SUB in some cases.
There's also no guarantee the new opcode is even the same opcode
as the original node.
This patch removes the code and adds code to explicitly preserve
FMF flags in the SETCC promotion function.
The other test changes are from nuw/nsw not being preserved. I
believe for all these tests it was correct to preserve the flags,
so we need new code to preserve the flags when possible. I'll post
another patch for that since it's a riskier change.
This should unblock D150769.
Differential Revision: https://reviews.llvm.org/D151472
Shoaib Meenai [Thu, 25 May 2023 01:32:38 +0000 (18:32 -0700)]
[CodeGen] Make __clang_call_terminate have an unwind table entry
This enables unwinders to step past that frame on architectures that
don't use DWARF unwinding (such as armv7), e.g. when debugging. The
problem should theoretically be architecture-agnostic, but according to
https://discourse.llvm.org/t/51633/2 it gets masked on architectures
that use DWARF unwind info.
Fixes https://github.com/llvm/llvm-project/issues/40696
Reviewed By: efriedma, rnk
Differential Revision: https://reviews.llvm.org/D151393
Sterling Augustine [Thu, 25 May 2023 17:51:59 +0000 (10:51 -0700)]
Add missing dependency for tests.
Mark de Wever [Thu, 25 May 2023 17:45:50 +0000 (19:45 +0200)]
[libc++][test] Mark throw_format_error as noreturn.
This fixes and GCC error. This was tested in D135787.
Felipe de Azevedo Piovezan [Thu, 25 May 2023 11:24:30 +0000 (07:24 -0400)]
[lldb][nfc] Refactor methods with out parameter
Currently, the method `GetAttributeAddressRanges` takes a DWARFRangeList as a
parameter, just to immediately clear it. The method also returns the size of
this list. Such an API was obfuscating the intent of the call sites (it's not
clear from the method name what it returns) and it was obfuscating redundant
checks on the size of the list.
This commit refactors the method to return the list and to also make the call
sites use the more explicit `IsEmpty` method.
Differential Revision: https://reviews.llvm.org/D151451
Marco Elver [Thu, 25 May 2023 17:36:50 +0000 (19:36 +0200)]
Fix "[sanitizer_common] Support stripping interceptor prefixes in RenderFrame()"
RenderFrame() has several implementations, which was missed in
01cea39f8e11012ac96b36ef60bfaf2f3b64320b.
Fix the one in sanitizer_symbolizer_markup.cpp.
Reported-by: gulfem
Kelvin Li [Thu, 25 May 2023 16:47:56 +0000 (12:47 -0400)]
[flang] Don't convert actual argument if IGNORE_TKR is present for the corresponding dummy
This patch is to remove the conversion of the actual argument that
is associated with the dummy argument specified with the IGNORE_TKR
directive.
Commit on behalf of @danielcchen
Differential Revision: https://reviews.llvm.org/D151401
Matthias Springer [Thu, 25 May 2023 17:10:05 +0000 (19:10 +0200)]
[mlir][tensor] TrackingListener: Support cast-like InsertSliceOps with dynamic shape
When looking for payload op replacements, rank-expanding InsertSliceOps of dynamically-typed tensors are now supported.
Differential Revision: https://reviews.llvm.org/D151444
Kun Wu [Thu, 25 May 2023 17:12:03 +0000 (17:12 +0000)]
[MLIR][sparse][GPU] fixing windows build break caused by D151014
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D151405
Matthias Springer [Thu, 25 May 2023 17:03:17 +0000 (19:03 +0200)]
[mlir][Interfaces] ValueBoundsOpInterface: Check if two values are equal
Add a helper function that computes if two SSA values have the same value, utilizing the `ValueBoundsOpInterface` infrastructure. Two SSA values have the same value, an equality bound of 0 can be derived for their subtraction.
The helper function can also be used to determine if two tensor dimension sizes are equal.
Differential Revision: https://reviews.llvm.org/D151443
Valentin Clement [Thu, 25 May 2023 17:03:50 +0000 (10:03 -0700)]
[mlir][openacc][NFC] Fix verifier message
Reviewed By: vzakhari, jeanPerier
Differential Revision: https://reviews.llvm.org/D151382
Matthias Springer [Thu, 25 May 2023 16:50:27 +0000 (18:50 +0200)]
[mlir][Interfaces][NFC] ValueBoundsConstraintSet: Simplify constructor
Differential Revision: https://reviews.llvm.org/D151442
Arthur Eubanks [Fri, 19 May 2023 19:35:01 +0000 (12:35 -0700)]
[Inliner] Mark inlinings stopped with inlining history as noinline
The inline history makes sure that we don't keep inlining due to mutual devirtualization. But this gets forgotten between inliner invocations.
So mark the inlined calls as noinline so we respect previous inline history decisions.
This overlaps with D121084, but they're not redundant since we may not inline completely through a child SCC, but we still want a cost multiplier when that happens.
See discussions in D145516.
Reviewed By: jmorse
Differential Revision: https://reviews.llvm.org/D150989
Felipe de Azevedo Piovezan [Thu, 25 May 2023 11:23:06 +0000 (07:23 -0400)]
[lldb][nfc] Place comment in the right place
This line has been misplaced since it was introduced in 2011 by
c26e4454035a4160cffc3c865cf83be194ca38c4.
Differential Revision: https://reviews.llvm.org/D151425
Vitaly Buka [Sat, 13 May 2023 00:06:27 +0000 (17:06 -0700)]
[AST] Initialized data after TypeSourceInfo
There is no initialization of the data between allocation
and first getBeginLoc call.
allocation: llvm-project/clang/lib/AST/ASTContext.cpp:3022
use: llvm-project/clang/lib/AST/TypeLoc.cpp:222
Msan report https://reviews.llvm.org/P8306
Reviewed By: thurston
Differential Revision: https://reviews.llvm.org/D150499
Carlos Eduardo Seo [Sat, 20 May 2023 05:16:50 +0000 (05:16 +0000)]
Fix nested block constructs for SELECT CASE
In some scenarios, a SELECT CASE could cause an error while lowering to FIR.
This was caused by a spurious extra branch added after the end statement.
Fixes #62726
Differential Revision: https://reviews.llvm.org/D151118
Shafik Yaghmour [Thu, 25 May 2023 16:44:10 +0000 (09:44 -0700)]
[Clang] Switch from TransformExpr to TransformInitializer in places we need to revert initializer to it syntactic form for Sema
In some cases we are using TransformExpr instead of
TransformInitializer, this results in ExprWithCleanups being dropped and
we are not emitting a destructor as a result.
This fixes: https://github.com/llvm/llvm-project/issues/62818
Differential Revision: https://reviews.llvm.org/D151235
Matthias Springer [Thu, 25 May 2023 16:06:02 +0000 (18:06 +0200)]
[mlir][tensor] TrackingListener: Find replacement ops through cast-like InsertSliceOps
Certain InsertSliceOps, that do not use elements from the destination, are treated like casts when looking for replacement ops. Such InsertSliceOps are typically rank expansions.
Tensors with dynamic shape are not supported at the moment.
Also adds test cases for the TrackingListener.
Differential Revision: https://reviews.llvm.org/D151422
Harsh Menon [Thu, 25 May 2023 10:32:59 +0000 (03:32 -0700)]
[mlir] Return new scf.forall handle in fuse_into_containing_op
Since the scf.forall is now consumed by the fuse into
containing op, we need to return a handle to the new scf.forall.
This patch does that and also ensures that the new bbArg
added to the scf.forall is used in its body.
Differential Revision: https://reviews.llvm.org/D151418
Arthur Eubanks [Mon, 22 May 2023 18:07:51 +0000 (11:07 -0700)]
[Pipeline] Don't run EarlyFPM in LTO post link
EarlyFPM cleans up the output of the frontend. This isn't necessary in post link pipelines as the pre link pipeline already ran this.
~0.4% savings in ThinLTO builds:
https://llvm-compile-time-tracker.com/compare.php?from=
8a5d4eb775c644d8683f24817d44c510d2b853b7&to=
3580252a2162eadca0da99f1eeaa112f74a0353d&stat=instructions:u
Reviewed By: tejohnson
Differential Revision: https://reviews.llvm.org/D145403
Bjorn Pettersson [Thu, 25 May 2023 16:15:11 +0000 (18:15 +0200)]
[unittest][codegen] Avoid memory leak in recently added FindDebugLocTest unittest
Need to finalize the DIBuilder to avoid leak sanitizer errors
like this:
Direct leak of 48 byte(s) in 1 object(s) allocated from:
#0 0x55c99ea1761d in operator new(unsigned long)
#1 0x55c9a518ae49 in operator new
#2 0x55c9a518ae49 in llvm::MDTuple::getImpl(...)
#3 0x55c9a4f1b1ec in getTemporary
#4 0x55c9a4f1b1ec in llvm::DIBuilder::createFunction(...)
Jacques Pienaar [Thu, 25 May 2023 16:24:50 +0000 (09:24 -0700)]
[mlir][bytecode] Avoid recording null arglocs & realloc opnames.
For block arg locs a common case is no/uknown location (where the producer
signifies they don't care about blockarg location). Also avoid needing to
dynamically resize opnames during parsing.
Assumed to be post lazy loading change, so chose version 3.
Differential Revision: https://reviews.llvm.org/D151038
Laszlo Kindrat [Thu, 25 May 2023 13:23:49 +0000 (09:23 -0400)]
[mlir] Change the order of members in MLIRContext to ensure dialects are destroyed first
Currently, the dialects precede the registered operations in the context object, which means that the latter is destroyed first. At the same time, Operation::~Operation dereferences the registered operation when destroying properties, which can cause use-after-free (e.g. if a dialect owns an op). This patch fixes that by changing the order of the members so that dialects come after registered operations.
Differential Revision: https://reviews.llvm.org/D151440
Arthur Eubanks [Mon, 22 May 2023 23:00:18 +0000 (16:00 -0700)]
[StandardInstrumentations] Add option to dump IR to a file on crash
We already have -print-on-crash which dumps the IR to stderr on a crash, but it's more useful to dump to a file.
Introduce -print-on-crash-path to dump the IR to a file.
Making -print-on-crash a string option is confusing if you only pass -print-on-crash and it swallows up the next command line arg, which is why this is a new option.
Perhaps we could retire the dump to stderr version if people don't use it, but not sure how much people find that useful.
Reviewed By: jamieschmeiser
Differential Revision: https://reviews.llvm.org/D151170
Roy Sundahl [Thu, 9 Feb 2023 20:43:54 +0000 (12:43 -0800)]
Discussion: Darwin Sanitizers Stable ABI
# Darwin Sanitizers Stable ABI
We wish to make it possible to include the AddressSanitizer (ASan) runtime implementation in OSes and for this we need a stable ASan ABI. Based on previous discussions about this topic, our understanding is that freezing the present ABI would impose an excessive burden on other sanitizer developers and for unrelated platforms. Therefore, we propose adding a secondary stable ABI for our use and anyone else in the community seeking the same. We believe that we can define a stable ABI with minimal burden on the community, expecting only to keep existing tests running and implementing stubs when new features are added. We are okay with trading performance for stability with no impact for existing users of ASan while minimizing the maintenance burden for ASan maintainers. We wish to commit this functionality to the LLVM project to maintain it there. This new and stable ABI will abstract away the implementation details allowing new and novel approaches to ASan for developers, researchers and others.
## Details
Rather than adding a lot of conditional code to the LLVM instrumentation phase, which would incur excessive complexity and maintenance cost of adding conditional code into all places that emit a runtime call, we propose a “shim” layer which will map the unstable ABI to the stable ABI:
* A static library (.a library) shim that maps the existing ASan ABI to a generalized, smaller and stable ABI. The library would implement the __asan functions and call into the new ABI. For example:
* `void __asan_load1(uptr p) { __asan_abi_loadn(p, 1, true); }`
* `void __asan_load2(uptr p) { __asan_abi_loadn(p, 2, true); }`
* `void __asan_noabort_load16(uptr p) { __asan_abi_loadn(p, 16, false); }`
* `void __asan_poison_cxx_array_cookie(uptr p) { __asan_abi_pac(p); }`
* This “shim” library would only be used by people who opt in: A compilation flag in the Clang driver will be used to gate the use of the stable ABI workflow.
* Utilize the existing ability for the ASan instrumentation to prefer runtime calls instead of inlined direct shadow memory accesses.
* Pursue (under the new driver flag) a better separation of abstraction and implementation with:
* LLVM instrumentation: Calling out for all poisoning, checking and unpoisoning.
* Runtime: Implementing the stable ABI and being responsible of implementation details of the shadow memory.
## Maintenance
Our aim is that the maintenance burden on the sanitizer developer community be negligible. Stable ABI tests will always pass for non-Darwin platforms. Changes to the existing ABI which would require a change to the shim have been infrequent as the ASan ABI is already relatively stable. Rarely, a change that impacts the contract between LLVM and the shim will occur. Among such foreseeable changes are: 1) changes to a function signature, 2) additions of new functions, or 3) deprecation of an existing function. Following are some examples of reasonable responses to those changes:
* Example: An existing ABI function is changed to return the input parameter on success or NULL on failure. In this scenario, a reasonable change to the shim would be to modify the function signature appropriately and to simply guess at a common-sense implementation.
* `uptr __asan_load1(uptr p) { __asan_abi_loadn(p, 1, true); return p; }`
* Example: An additional function is added for performance reasons. It has a very similar function signature to other similarly named functions and logically is an extension of that same pattern. In this case it would make sense to apply the same logic as the existing entry points:
* `void __asan_load128(uptr p) { __asan_abi_loadn(p, 128, true); }`
* Example: An entry point is added to the existing ABI for which there is no obvious stable ABI implementation: In this case, doing nothing in a no-op stub would be acceptable, assuming existing features of ASan can still work without an actual implementation of this new function.
* `void __asan_prefetch(uptr p) { }`
* Example: An entrypoint in the existing ABI is deprecated and/or deleted:
* (Delete the entrypoint from the shim.)
We’re looking for buy-in for this level of support.
(Note: Upon acceptance of the general concepts herein, we will add a controlling clang flag, cmake integration, contract for the stable ABI, and the appropriate test infrastructure.)
Reviewed By: eugenis, vitalybuka, MaskRay
Differential Revision: https://reviews.llvm.org/D143675