Simon Pilgrim [Wed, 31 May 2023 10:41:20 +0000 (11:41 +0100)]
[X86] getTargetConstantBitsFromNode - ensure we truncate broadcasts from wider constants.
We might be broadcasting the lower portion of a wider constant pool entry, ensure we truncate the full width of the constant back to the broadcast width.
(This also exposes an issue with how asm comments print these constants - I'll address that in a followup).
Fixes #63030
Simon Pilgrim [Wed, 31 May 2023 09:56:41 +0000 (10:56 +0100)]
[X86] Replace X32 test check prefixes with X86
We try to only use X32 for gnux32 triple test cases
Timm Bäder [Wed, 31 May 2023 11:07:19 +0000 (13:07 +0200)]
Revert "[clang][Interp] Optionally cast comparison result to non-bool"
This reverts commit
81522a012accfcc6bbf4dfa21a793aea6e4e532a.
Looks like we're not ready for this yet:
https://lab.llvm.org/buildbot/#/builders/139/builds/41797
Timm Bäder [Tue, 2 May 2023 11:35:00 +0000 (13:35 +0200)]
[clang][Interp] Optionally cast comparison result to non-bool
Our comparison opcodes always produce a Boolean value and push it on the
stack. However, the result of such a comparison in C is int, so the
later code expects an integer value on the stack.
Work around this problem by casting the boolean value to int in those
cases. This is not ideal for C however. The comparison is usually
wrapped in a IntegerToBool cast anyway.
Differential Revision: https://reviews.llvm.org/D149645
Haojian Wu [Wed, 31 May 2023 10:49:21 +0000 (12:49 +0200)]
Timm Bäder [Wed, 31 May 2023 10:27:58 +0000 (12:27 +0200)]
[clang][Interp] Add missing static_assert messages
Dhruv Chawla [Wed, 17 May 2023 13:12:11 +0000 (15:12 +0200)]
Reapply [SelectionDAG] Handle NSW for ADD/SUB in computeKnownBits()
This exposed a miscompile due to incorrect flag preservation in
integer type legalization, which has been fixed in D151472.
-----
This patch is a continuation of D150110. It separates the cases for
ADD and SUB into their own cases so that computeForAddSub can be
directly called and the NSW flag passed. This allows better
optimization when the NSW flag is enabled, and allows fixing up the
TODO that was there previously in SimplifyDemandedBits.
Differential Revision: https://reviews.llvm.org/D150769
Marco Elver [Wed, 31 May 2023 10:16:58 +0000 (12:16 +0200)]
Revert "[compiler-rt] Avoid memintrinsic calls inserted by the compiler"
This reverts commit
e614d5667f6c6fc6c645587cb9aee1a058285454.
Build bot failures:
| FAILED: lib/clang/17/lib/linux/libclang_rt.ubsan_minimal-i386.so
| : && /usr/bin/clang++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wno-unused-parameter -O3 -DNDEBUG -Wl,-z,defs -Wl,-z,nodelete -m32 -nodefaultlibs -Wl,-z,text -nostdlib++ -shared -Wl,-soname,libclang_rt.ubsan_minimal-i386.so -o lib/clang/17/lib/linux/libclang_rt.ubsan_minimal-i386.so projects/compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.i386.dir/ubsan_minimal_handlers.cpp.o -lgcc_s -lc && :
| /usr/bin/ld: projects/compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.i386.dir/ubsan_minimal_handlers.cpp.o: in function `__ubsan_handle_type_mismatch_minimal':
| /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:120: undefined reference to `__sanitizer_internal_memcpy'
| /usr/bin/ld: projects/compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.i386.dir/ubsan_minimal_handlers.cpp.o: in function `__ubsan_handle_type_mismatch_minimal_abort':
| /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:120: undefined reference to `__sanitizer_internal_memcpy'
| /usr/bin/ld: projects/compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.i386.dir/ubsan_minimal_handlers.cpp.o: in function `__ubsan_handle_alignment_assumption_minimal':
| /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:121: undefined reference to `__sanitizer_internal_memcpy'
| /usr/bin/ld: projects/compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.i386.dir/ubsan_minimal_handlers.cpp.o: in function `__ubsan_handle_alignment_assumption_minimal_abort':
| /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:121: undefined reference to `__sanitizer_internal_memcpy'
| /usr/bin/ld: projects/compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.i386.dir/ubsan_minimal_handlers.cpp.o: in function `__ubsan_handle_add_overflow_minimal':
| /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:122: undefined reference to `__sanitizer_internal_memcpy'
| /usr/bin/ld: projects/compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.i386.dir/ubsan_minimal_handlers.cpp.o:/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:122: more undefined references to `__sanitizer_internal_memcpy' follow
Link: https://lab.llvm.org/buildbot#builders/74/builds/19569
OCHyams [Thu, 25 May 2023 09:48:22 +0000 (10:48 +0100)]
[Assignment Tracking] Ignore stores to a negative offset from an alloca
Fixes crash reported in llvm.org/PR62838.
Reviewed By: jryans
Differential Revision: https://reviews.llvm.org/D151326
Timm Bäder [Mon, 17 Apr 2023 13:23:37 +0000 (15:23 +0200)]
[clang][Interp] Track frame depth
Save the depth of each InterpFrame and bail out if we're too deep.
Differential Revision: https://reviews.llvm.org/D148614
Nico Weber [Wed, 31 May 2023 10:07:38 +0000 (06:07 -0400)]
Marco Elver [Tue, 30 May 2023 09:59:22 +0000 (11:59 +0200)]
[compiler-rt] Avoid memintrinsic calls inserted by the compiler
D135716 introduced -ftrivial-auto-var-init=pattern where supported.
Unfortunately this introduces unwanted memset() for large stack arrays,
as shown by the new tests added for asan and msan (tsan already had this
test).
In general, the problem of compiler-inserted memintrinsic calls
(memset/memcpy/memmove) is not new to compiler-rt, and has been a
problem before.
To avoid introducing unwanted memintrinsic calls, we redefine
memintrinsics as __sanitizer_internal_mem* at the assembly level for
most source files automatically (where sanitizer_common_internal_defs.h
is included).
In few cases, redefining a symbol in this way causes issues for
interceptors, namely the memintrinsic interceptor themselves. For such
source files we have to selectively disable the redefinition.
Other alternatives have been considered, but simply do not work well in
the context of compiler-rt:
1. Linker --wrap: this does not work because --wrap only
applies to the final link, and would not apply when building
sanitizer static libraries.
2. Changing references to memset() via objcopy: this may work,
but due to the complexities of the build system, introducing
such a post-processing step for the right object files (in
particular object files defining memset cannot be touched)
seems infeasible.
The chosen solution works well (as shown by the tests). Other libraries
have chosen the same solution where nothing else works (see e.g. glibc's
"symbol-hacks.h").
Reviewed By: vitalybuka, dvyukov
Differential Revision: https://reviews.llvm.org/D151152
Richard Sandiford [Tue, 4 Apr 2023 13:05:13 +0000 (14:05 +0100)]
[clang] Add Parse and Sema support for RegularKeyword attributes
This patch adds the Parse and Sema support for RegularKeyword attributes,
following on from a previous patch that added Attr.td support.
The patch is quite large. However, nothing outside the tests is
specific to the first RegularKeyword attribute (__arm_streaming).
The patch should therefore be a one-off, up-front cost. Other
attributes just need an entry in Attr.td and the usual Sema support.
The approach taken in the patch is that the keywords can be used with
any language version. If standard attributes were added in language
version Y, the keyword rules for version X<Y are the same as they were
for version Y (to the extent possible). Any extensions beyond Y are
handled in the same way for both keywords and attributes. This ensures
that existing C++11 successors like C++17 are not treated differently
from versions that have yet to be defined.
Some notes on the implementation:
* The patch emits errors rather than warnings for diagnostics that
relate to keywords.
* Where possible, the patch drops “attribute” from diagnostics
relating to keywords.
* One exception to the previous point is that warnings about C++
extensions do still mention attributes. The use there seemed OK
since the diagnostics are noting a change in the production rules.
* If a diagnostic string needs to be different for keywords and
attributes, the patch standardizes on passing the attribute/
name/token followed by 0 for attributes and 1 for keywords.
* Although the patch updates warn_attribute_wrong_decl_type_str,
warn_attribute_wrong_decl_type, and warn_attribute_wrong_decl_type,
only the error forms of these strings are used for keywords.
* I couldn't trigger the warnings in checkUnusedDeclAttributes,
even for existing attributes. An assert on the warnings caused
no failures in the testsuite. I think in practice all standard
attributes would be diagnosed before this.
* The patch drops a call to standardAttributesAllowed in
ParseFunctionDeclarator. This is because MaybeParseCXX11Attributes
checks the same thing itself, where appropriate.
* The new tests are based on c2x-attributes.c and
cxx0x-attributes.cpp. The C++ test also incorporates a version of
cxx11-base-spec-attributes.cpp. The FIXMEs are carried across from
the originals.
Differential Revision: https://reviews.llvm.org/D148702
Richard Sandiford [Wed, 19 Apr 2023 10:03:42 +0000 (11:03 +0100)]
[clang] Add support for “regular” keyword attributes
Platform-specific language extensions often want to provide a way of
indicating that certain functions should be called in a different way,
compiled in a different way, or otherwise treated differently from a
“normal” function. Honoring these indications is often required for
correctness, rather being than an optimization/QoI thing.
If a function declaration has a property P that matters for correctness,
it will be ODR-incompatible with a function that does not have property P.
If a function type has a property P that affects the calling convention,
it will not be two-way compatible with a function type that does not
have property P. These properties therefore affect language semantics.
That in turn means that they cannot be treated as standard [[]]
attributes.
Until now, many of these properties have been specified using GNU-style
attributes instead. GNU attributes have traditionally been more lax
than standard attributes, with many of them having semantic meaning.
Examples include calling conventions and the vector_size attribute.
However, there is a big drawback to using GNU attributes for semantic
information: compilers that don't understand the attributes will
(by default) emit a warning rather than an error. They will go on to
compile the code as though the attributes weren't present, which will
inevitably lead to wrong code in most cases. For users who live
dangerously and disable the warning, this wrong code could even be
generated silently.
A more robust approach would be to specify the properties using
keywords, which older compilers would then reject. Some vendor-specific
extensions have already taken this approach. But traditionally, each
such keyword has been treated as a language extension in its own right.
This has three major drawbacks:
(1) The parsing rules need to be kept up-to-date as the language evolves.
(2) There are often corner cases that similar extensions handle differently.
(3) Each extension requires more custom code than a standard attribute.
The underlying problem for all three is that, unlike for true attributes,
there is no established template that extensions can reuse. The purpose
of this patch series is to try to provide such a template.
One option would have been to pick an existing keyword and do whatever
that keyword does. The problem with that is that most keywords only
apply to specific kinds of types, kinds of decls, etc., and so the
parsing rules are (for good reason) not generally applicable to all
types and decls.
Really, the “only” thing wrong with using standard attributes is that
standard attributes cannot affect semantics. In all other respects
they provide exactly what we need: a well-defined grammar that evolves
with the language, clear rules about what an attribute appertains to,
and so on.
This series therefore adds keyword “attributes” that can appear
exactly where a standard attribute can appear and that appertain
to exactly what a standard attribute would appertain to. The link is
mechanical and no opt-outs or variations are allowed. This should
make the keywords predictable for programmers who are already
familiar with standard attributes.
This does mean that these keywords will be accepted for parsing purposes
in many more places than necessary. Inappropriate uses will then be
diagnosed during semantic analysis. However, the compiler would need
to reject the keywords in those positions whatever happens, and treating
them as ostensible attributes shouldn't be any worse than the alternative.
In some cases it might even be better. For example, SME's
__arm_streaming attribute would make conceptual sense as a statement
attribute, so someone who takes a “try-it-and-see” approach might write:
__arm_streaming { …block-of-code…; }
In fact, we did consider supporting this originally. The reason for
rejecting it was that it was too difficult to implement, rather than
because it didn't make conceptual sense.
One slight disadvantage of the keyword-based approach is that it isn't
possible to use #pragma clang attribute with the keywords. Perhaps we
could add support for that in future, if it turns out to be useful.
For want of a better term, I've called the new attributes "regular"
keyword attributes (in the sense that their parsing is regular wrt
standard attributes), as opposed to "custom" keyword attributes that
have their own parsing rules.
This patch adds the Attr.td support for regular keyword attributes.
Adding an attribute with a RegularKeyword spelling causes tablegen
to define the associated tokens and to record that attributes created
with that syntax are regular keyword attributes rather than custom
keyword attributes.
A follow-on patch contains the main Parse and Sema support,
which is enabled automatically by the Attr.td definition.
Other notes:
* The series does not allow regular keyword attributes to take
arguments, but this could be added in future.
* I wondered about trying to use tablegen for
TypePrinter::printAttributedAfter too, but decided against it.
RegularKeyword is really a spelling-level classification rather
than an attribute-level classification, and in general, an attribute
could have both GNU and RegularKeyword spellings. In contrast,
printAttributedAfter is only given the attribute kind and the type
that results from applying the attribute. AFAIK, it doesn't have
access to the original attribute spelling. This means that some
attribute-specific or type-specific knowledge might be needed
to print the attribute in the best way.
* Generating the tokens automatically from Attr.td means that
pseudo's libgrammar does now depend on tablegen.
* The patch uses the SME __arm_streaming attribute as an example
for testing purposes. The attribute does not do anything at this
stage. Later SME-specific patches will add proper semantics for it,
and add other SME-related keyword attributes.
Differential Revision: https://reviews.llvm.org/D148700
Richard Sandiford [Tue, 4 Apr 2023 08:13:04 +0000 (09:13 +0100)]
[clang] Mark keywords that have their own parsing rules
This patch retroactively classifies all existing keyword attributes
as “custom” keyword attributes, in the sense that the keywords have
their own custom parsing rules. A follow-on patch will add an
alternative type of keyword.
No functional change intended.
Differential Revision: https://reviews.llvm.org/D148699
Timm Bäder [Sun, 5 Feb 2023 10:03:48 +0000 (11:03 +0100)]
[clang][Interp] Fix diagnosing uninitialized ctor record arrays
Differential Revision: https://reviews.llvm.org/D143334
Oleksandr "Alex" Zinenko [Wed, 31 May 2023 09:39:26 +0000 (11:39 +0200)]
Fix link in transform example README.md
khei4 [Wed, 31 May 2023 03:26:11 +0000 (12:26 +0900)]
[LangRef] fix the function result attributes location explanation and examples (NFC)
Differential Revision: https://reviews.llvm.org/D151772
Nikita Popov [Wed, 31 May 2023 09:18:53 +0000 (11:18 +0200)]
[IndVars] Check expansion safety in makeIVComparisonInvariant() (PR62992)
Make sure the invariant expressions are safe to expand. In
particular, we should not speculative a trapping division into
the preheader.
Fixes https://github.com/llvm/llvm-project/issues/62992.
Alex Zinenko [Wed, 31 May 2023 08:45:05 +0000 (08:45 +0000)]
[mlir] drop debug tags after TransformInterpreterPassBase
The pass attaches attributes to operations for repro generation
purposes, but never removes them. This is not desirable when the pass
actually succeeds.
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D151791
Alex Zinenko [Wed, 31 May 2023 08:58:16 +0000 (08:58 +0000)]
[mlir] fix documentation includes
Timm Bäder [Wed, 24 May 2023 15:27:08 +0000 (17:27 +0200)]
[clang][Diagnostics][NFC] Move variable decl into if statement
Nikita Popov [Wed, 31 May 2023 08:44:56 +0000 (10:44 +0200)]
[MemoryBuiltins] Handle phi nodes without operands (PR63013)
Conservatively return unknown in this degenerate case. This is
hard to hit in practice, because such phis are usually optimized
away before they reach a getObjectSize() call.
Fixes https://github.com/llvm/llvm-project/issues/63013.
Timm Bäder [Wed, 24 May 2023 06:16:04 +0000 (08:16 +0200)]
[clang][Diagnostics][NFC] Move Buf{Start,End} out of the loop
They don't change inside the loop.
Timm Bäder [Wed, 24 May 2023 07:03:26 +0000 (09:03 +0200)]
[clang][Diagnostics][NFC] Remove unnecessary StringRef
Seems unnecessary to create a StringRef here just so we can drop the
trailing null bytes. We can do that with the std::string we
create anyway.
Differential Revision: https://reviews.llvm.org/D151300
Timm Bäder [Wed, 24 May 2023 06:45:31 +0000 (08:45 +0200)]
[clang][Diagnostics] Print empty lines in multiline snippets
We should preserve empty lines in output snippets.
Differential Revision: https://reviews.llvm.org/D151301
Timm Bäder [Wed, 24 May 2023 04:44:35 +0000 (06:44 +0200)]
[clang][Diagnostics][NFC] Don't create oversized CaretLine
Instead of creating a CaretLine the size of the SourceLine, just leave
it empty at first, let HighlightRange resize it to fit all the ~, then
resize it to fit the ^. Then we can save ourselves the work to remove
the trailing whitespace again.
Differential Revision: https://reviews.llvm.org/D151286
Benjamin Chetioui [Wed, 31 May 2023 08:19:26 +0000 (08:19 +0000)]
Alex Zinenko [Wed, 31 May 2023 08:19:09 +0000 (08:19 +0000)]
[mlir] small cleanup of transform dialect docs
Timm Bäder [Mon, 22 May 2023 14:46:30 +0000 (16:46 +0200)]
[clang][Diagnostics][NFC] Remove unused Indentation parameter
printWordWrapped() is only called in one place, which passes all
parameters except `Indentation`. So, remove that parameter and use its
default value instead. Also remove the other default parameter values,
since those are unneeded.
Adrian Kuegel [Wed, 31 May 2023 08:12:06 +0000 (10:12 +0200)]
LLVM GN Syncbot [Wed, 31 May 2023 08:06:46 +0000 (08:06 +0000)]
[gn build] Port
b0bab14b8b53
Timm Bäder [Mon, 22 May 2023 14:12:21 +0000 (16:12 +0200)]
[clang][Diagnostics][NFC] Merge byte/column mapping functions into one.
They were both only called from one place and did very similar things.
Merge them into one, so we only have to iterate the source line once to
generate the SourceMap.
Differential Revision: https://reviews.llvm.org/D151100
Timm Bäder [Mon, 22 May 2023 13:39:48 +0000 (15:39 +0200)]
[clang][Diagnostics][NFC] Use getFileID() directly
Instead of calling getDecomposedLoc() and then only using the FileID.
Balázs Kéri [Wed, 31 May 2023 06:54:40 +0000 (08:54 +0200)]
[clang-tidy] Add check bugprone-unique-ptr-array-mismatch.
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D151431
Timm Bäder [Mon, 22 May 2023 13:27:24 +0000 (15:27 +0200)]
[clang][Diagnostic][NFC] Simplify emitDiagnosticLoc
We don't use the offset returned from SourceManager::getDecomposedLoc
here, so we might as well just use getFileID().
Differential Revision: https://reviews.llvm.org/D151093
Timm Bäder [Mon, 22 May 2023 11:06:56 +0000 (13:06 +0200)]
[clang][Diagnostics] Use llvm::raw_ostream::indent()
Differential Revision: https://reviews.llvm.org/D151078
Timm Bäder [Mon, 22 May 2023 11:06:25 +0000 (13:06 +0200)]
[clang][Diagnostics] Simplify emitSnippet()
Don't try to minimize the times we invoke operator<< on the output
stream by keeping a ToPrint string around. Instead, just print the
characters as we iterate over them.
Differential Revision: https://reviews.llvm.org/D151075
Matthias Springer [Wed, 31 May 2023 07:26:48 +0000 (09:26 +0200)]
[mlir][Transforms] GreedyPatternRewriteDriver: Worklist randomizer
Instead of always taking the last op from the worklist, take a random one. For testing/debugging purposes only. This feature can be used to ensure that lowering pipelines work correctly regardless of the order in which ops are processed by the GreedyPatternRewriteDriver.
The randomizer can be enabled by setting a numeric `MLIR_GREEDY_REWRITE_RANDOMIZER_SEED` option.
Note: When enabled, 27 tests are currently failing. Partly because FileCheck tests are looking for exact IR.
Discussion: https://discourse.llvm.org/t/discussion-fuzzing-pattern-application/67911
Differential Revision: https://reviews.llvm.org/D142447
Hristo Hristov [Tue, 23 May 2023 12:06:41 +0000 (15:06 +0300)]
[libc++][spaceship] Additional tests for `operator<=>` `map` and `multimap`
- Added additional tests
- Improved existing tests
- Moved misplaced test files to the correct location
Reviewed By: #libc, philnik
Differential Revision: https://reviews.llvm.org/D151205
Timm Bäder [Wed, 17 May 2023 18:23:06 +0000 (20:23 +0200)]
[clang][NFC] Refactor emitSnippet()
Rename parameters and local variables and reorder things a bit to be
closer to their first point of use.
Differential Revision: https://reviews.llvm.org/D150840
LiaoChunyu [Wed, 31 May 2023 07:04:39 +0000 (15:04 +0800)]
[RISCV] Add special case for (select cc, 1.0, 0.0) to lowerSELECT
Use sint_to_fp instead of select.
Reduce the number of branch instructions and
avoid generating TargetConstantPool for double.
(select cc, 1.0, 0.0) -> (sint_to_fp (zext cc))
https://alive2.llvm.org/ce/z/aoEcd9
https://godbolt.org/z/n543Y9v3e
(select cc, 0.0, 1.0) -> (sint_to_fp (zext (xor cc, 1)))
https://alive2.llvm.org/ce/z/zngvSB
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D151719
Vlad Serebrennikov [Wed, 31 May 2023 07:16:51 +0000 (10:16 +0300)]
[clang] Add test for CWG873
Also add missing marking to the test of related issue 621.
https://cplusplus.github.io/CWG/issues/621.html
https://cplusplus.github.io/CWG/issues/873.html
Reviewed By: #clang-language-wg, shafik
Differential Revision: https://reviews.llvm.org/D151704
Timm Bäder [Wed, 31 May 2023 07:13:19 +0000 (09:13 +0200)]
Timm Bäder [Wed, 31 May 2023 06:56:19 +0000 (08:56 +0200)]
[clang][Interp][NFC] Make InterpFrame::describe() more const-correct
Timm Bäder [Wed, 31 May 2023 06:50:38 +0000 (08:50 +0200)]
[clang][Interp][NFC] Simplify dump() indentation
Use llvm::raw_ostream::indent().
Tobias Gysi [Wed, 31 May 2023 06:48:49 +0000 (06:48 +0000)]
[mlir][llvm] Add alias and access group info to call.
The revision adds the alias analysis and access group
interfaces to the call operation.
Reviewed By: Dinistro
Differential Revision: https://reviews.llvm.org/D151693
Jianjian GUAN [Thu, 25 May 2023 06:24:22 +0000 (14:24 +0800)]
[RISCV] Add Zvfhmin extension for clang.
This patch adds the Zvfhmin extension for clang.
Reviewed By: craig.topper, michaelmaitland
Differential Revision: https://reviews.llvm.org/D150253
Bing1 Yu [Wed, 31 May 2023 06:13:48 +0000 (14:13 +0800)]
[VLIWMachineScheduler] Disable default copy ctor and copy assignment operator for VLIWSchedBoundary
class VLIWSchedBoundary manages resources such as dynamically allocated memory, it's generally a good practice to either implement a custom copy constructor or disable the default one.
Reviewed By: JamesNagurne
Differential Revision: https://reviews.llvm.org/D151699
Enna1 [Wed, 31 May 2023 06:03:53 +0000 (14:03 +0800)]
[NFC][HWASAN] make variables names for callback functions more consistent
This patch makes the variables names for callback functions more consistent. Changes no functionality.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D151605
Mark de Wever [Wed, 31 May 2023 05:55:05 +0000 (07:55 +0200)]
[libc++][CI] Escape quoting.
This should fix the Clang CI.
Craig Topper [Wed, 31 May 2023 05:45:42 +0000 (22:45 -0700)]
[RISCV] Merge emitDirectiveOptionArchPlus and emitDirectiveOptionArchMinus into a single interface. NFC
Probably going to do some other refactors after this, but this one
was easy and clearly reduces duplicate code.
Reviewed By: StephenFan
Differential Revision: https://reviews.llvm.org/D151771
Vitaly Buka [Wed, 31 May 2023 05:40:45 +0000 (22:40 -0700)]
[NFC][sanitizer] Change ArrayRef constructor
Michael Liao [Wed, 31 May 2023 05:30:56 +0000 (01:30 -0400)]
[mlir] Add the missing non-member operator decl in the same namesapce. NFC
Timm Bäder [Wed, 17 May 2023 12:04:30 +0000 (14:04 +0200)]
[clang] Show line numbers in diagnostic code snippets
Show line numbers to the left of diagnostic code snippets and increase
the numbers of lines shown from 1 to 16.
Differential Revision: https://reviews.llvm.org/D147875
Jan Svoboda [Wed, 31 May 2023 04:58:00 +0000 (21:58 -0700)]
[clang] Add test for -ftabstop diagnostics
I forgot to request a regression test in review of D151429, so adding one myself.
Shubham Sandeep Rastogi [Wed, 31 May 2023 04:46:10 +0000 (21:46 -0700)]
Revert "Fix -u option in dsymutil, to not emit an extra DW_LNE_set_address if the original line table was empty"
This reverts commit
9bd3ff8bf9e05e7bf95a4a068aa3b50813a93975.
Reverting because of test failures:
TEST 'LLVM :: tools/dsymutil/ARM/fat-dylib-update.test' FAILED
Command Output (stderr):
--
+ : 'RUN: at line 2'
+ /b/ml-opt-rel-x86-64-b1/build/bin/dsymutil -oso-prepend-path /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/tools/dsymutil/ARM/.. /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/tools/dsymutil/ARM/../Inputs/fat-test.arm.dylib -o /b/ml-opt-rel-x86-64-b1/build/test/tools/dsymutil/ARM/Output/fat-dylib-update.test.tmp.dSYM
warning: /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/tools/dsymutil/ARM/../Inputs/fat-test.arm.o: timestamp mismatch between object file (2023-05-24 23:42:39.
442778779) and debug map (2015-08-05 21:31:26.
000000000)
warning: /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/tools/dsymutil/ARM/../Inputs/fat-test.arm.o: timestamp mismatch between object file (2023-05-24 23:42:39.
442778779) and debug map (2015-08-05 21:31:26.
000000000)
error: lipo: No such file or directory
csmoe [Wed, 31 May 2023 04:43:11 +0000 (21:43 -0700)]
print user provide value in tabstop diagnostic
github issue: https://github.com/llvm/llvm-project/issues/62912
Reviewed By: jansvoboda11
Differential Revision: https://reviews.llvm.org/D151429
Jan Svoboda [Wed, 31 May 2023 04:24:51 +0000 (21:24 -0700)]
[clang][lex] NFCI: Use DirectoryEntryRef in HeaderSearch::LookupFile
This patch changes the argument type to `HeaderSearch::LookupFile()` from `const DirectoryEntry *` to `DirectoryEntryRef` in order to remove some calls to the deprecated `DirectoryEntry::getName()`.
Depends on D127660.
Reviewed By: bnbarham, benlangmuir
Differential Revision: https://reviews.llvm.org/D127663
Shubham Sandeep Rastogi [Fri, 26 May 2023 19:05:09 +0000 (12:05 -0700)]
Fix -u option in dsymutil, to not emit an extra DW_LNE_set_address if the original line table was empty
With dsymutil's -u option, only the accelerator tables should be
updated, but with https://reviews.llvm.org/D150554 the -u option will
still re-generate the line table. If the line table was empty, that is,
it was a dummy line table, with no entries in it, dsymutil will always
generate a line table with a DW_LNE_end_sequence, a funky side effect of
this is that when the line table is re-generated, it will always emit a
DW_LNE_set_address first, which will change the line table total size.
This patch addresses this by making sure that if all the line table has
in it is a DW_LNE_end_sequence, it is the same as a dummy entry.
Differential Revision: https://reviews.llvm.org/D151579
Craig Topper [Wed, 31 May 2023 04:27:36 +0000 (21:27 -0700)]
[RISCV] Strengthen some SDTypeProfiles to reduce isel table size.
Jan Svoboda [Wed, 31 May 2023 04:06:50 +0000 (21:06 -0700)]
[clang][modules] NFCI: Extract optionality out of `Module::{Header,DirectoryName}`
Most users of `Module::Header` already assume its `Entry` is populated. Enforce this assumption in the type system and handle the only case where this is not the case by wrapping the whole struct in `std::optional`. Do the same for `Module::DirectoryName`.
Depends on D151584.
Reviewed By: benlangmuir
Differential Revision: https://reviews.llvm.org/D151586
Yaxun (Sam) Liu [Tue, 9 May 2023 18:05:55 +0000 (14:05 -0400)]
[clang][Sema] Improve diagnostics for auto return type
Currently when clang fails to deduce auto return type of a function,
it does not emit any notes about why it fails. This causes difficulty
for users to fix such errors.
Actually, clang already generates the information for emitting notes
about the failed deduction. There is a TODO for actually emitting
them.
This patch tries to implement the TODO. Basically it passes the
failed template specialization candidate set from the point of
specialization failure back to the point where the deduction starts.
It is not comprehensive but would be a start for further improvement.
Reviewed by: Richard Smith, Matheus Izvekov
Differential Revision: https://reviews.llvm.org/D150212
Fixes: SWDEV-354278
Bing1 Yu [Wed, 31 May 2023 02:34:55 +0000 (10:34 +0800)]
[MC] Disable default copy ctor and copy assignment operator for CodeViewContext
class CodeViewContext manages resources such as dynamically allocated memory, it's generally a good practice to either implement a custom copy constructor or disable the default one.
Reviewed By: skan
Differential Revision: https://reviews.llvm.org/D151695
Bing1 Yu [Wed, 31 May 2023 02:33:52 +0000 (10:33 +0800)]
[MachineScheduler] Disable default copy ctor and copy assignment operator for SchedBoundary
class SchedBoundary manages resources such as dynamically allocated memory, it's generally a good practice to either implement a custom copy constructor or disable the default one.
Reviewed By: pengfei
Differential Revision: https://reviews.llvm.org/D151686
Davide Italiano [Wed, 31 May 2023 02:24:24 +0000 (19:24 -0700)]
[MachO] Add comments to explain the semantics of chained fixups structures.
Vitaly Buka [Wed, 31 May 2023 02:19:04 +0000 (19:19 -0700)]
[NFC][sanitizer] Extend ArrayRef
Shilei Tian [Wed, 31 May 2023 02:16:29 +0000 (22:16 -0400)]
[NFC][OpenMP] Remove unused variable `new_iv_saved` in `openmp/runtime/src/kmp_collapse.cpp`
Vitaly Buka [Wed, 31 May 2023 02:16:29 +0000 (19:16 -0700)]
Revert "[NFC][ASAN] Remove redundant fields of AsanThread"
Breaks Windows.
This reverts commit
8ac084728daf5b666624621562afb6d63cc01ae3.
Davide Italiano [Wed, 31 May 2023 02:15:41 +0000 (19:15 -0700)]
[MachO] Add the relocation types for auth pointers (chained fixups).
Manna, Soumi [Wed, 31 May 2023 01:58:44 +0000 (18:58 -0700)]
[NFC][CLANG] Fix nullptr dereference issue in DeduceTemplateArgumentsByTypeMatch()
DeduceTemplateArgumentsByTypeMatch() returns null value which is dereferenced without checking since getAsIncompleteArrayType() returns nullptr and we are dereferencing null pointer value for S.Context->getAsIncompleteArrayType(P) when calling getElementType().
This patch adds an assert.
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D151529
Jianjian GUAN [Tue, 30 May 2023 04:31:36 +0000 (12:31 +0800)]
[RISCV] Fix selection for some unmasked vp SDNode.
Make unmasked vp_ftrunc, vp_fceil, vp_floor and vp_fround select to unmasked instruction.
Reviewed By: frasercrmck
Differential Revision: https://reviews.llvm.org/D151676
Manna, Soumi [Wed, 31 May 2023 01:46:40 +0000 (18:46 -0700)]
[NFC][CLANG] Fix nullptr dereference issue in Type::getRVVEltType()
This patch uses castAs instead of getAs which will assert if the type
doesn't match in clang::Type::getRVVEltType(clang::ASTContext const &)
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D151721
yijia1212 [Wed, 31 May 2023 01:37:14 +0000 (01:37 +0000)]
add missing dependency for TosaToLinalg
Vitaly Buka [Mon, 8 May 2023 17:55:52 +0000 (10:55 -0700)]
[NFC][ASAN] Remove redundant fields of AsanThread
Amir Ayupov [Wed, 31 May 2023 00:28:22 +0000 (17:28 -0700)]
[BOLT] Align BranchInfo and FuncBranchData in DataAggregator::recordTrace
`DataAggregator::recordTrace` serves two purposes:
- Attaching LBR fallthrough ("trace") information to CFG (`getBranchInfo`),
which eventually gets emitted as YAML profile.
- Populating vector of offsets that gets added to `FuncBranchData`, which
eventually gets emitted as fdata profile.
`recordTrace` is invoked from `getFallthroughsInTrace` which checks its return
status and passes on the collected vector of offsets to `doTrace`.
However, if a malformed trace is passed to `recordTrace` it might partially
attach the profile to CFG and exit with false, not propagating the vector of
offsets to `doTrace`. This leads to a difference between fdata and yaml profile
collected from the same binary and the same perf file.
(Skylake LBR errata might produce such malformed traces where the last entry
is duplicated, resulting in invalid fallthrough path between the last two
entries).
There are two ways to handle this mismatch: conservative (aligned with fdata),
or aggressive (aligned with yaml). Conservative approach would discard the
trace entirely, buffering the CFG updates until all fallthroughs are confirmed.
Aggressive approach would apply CFG updates and return the matching
fallthroughs in the vector even if the trace is invalid (doesn't correspond to
a valid fallthrough path). I chose to go with the former (conservative/fdata)
approach which produces more accurate profile.
We can't rely on pre-filtering such traces early (in LBR sample processing) as
DataAggregator is used for both perf samples and pre-aggregated perf information
which loses branch stack information.
Test Plan: https://github.com/rafaelauler/bolt-tests/pull/22
Reviewed By: #bolt, rafauler
Differential Revision: https://reviews.llvm.org/D151614
Pengxuan Zheng [Tue, 30 May 2023 17:44:15 +0000 (10:44 -0700)]
[libc++] Include "bits/alltypes.h" to provide mbstate_t when using musl libc
With D148542, we ran into the following libc++ build error when using musl libc.
```
.../musl/include/bits/alltypes.h:354:16:
error: definition of type '__mbstate_t' conflicts with typedef of the same name
typedef struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t;
^
.../sysroot/usr/include/bits/types/__mbstate_t.h:21:3: note: '__mbstate_t' declared here
} __mbstate_t;
^
1 error generated.
```
This is because the mbstate_t definition in musl libc conflicts with the one
from "bits/types/mbstate_t.h", and this patch attempts to fix this build issue
when musl libc is used.
Reviewed By: iana
Differential Revision: https://reviews.llvm.org/D151740
wren romano [Tue, 30 May 2023 20:31:49 +0000 (13:31 -0700)]
[mlir][sparse] Improving SparseTensorDimSliceAttr methods
This patch makes the following changes to `SparseTensorDimSliceAttr` methods:
* Mark `isDynamic` constexpr.
* Add new helpers `getStatic` and `getStaticString` to avoid repetition.
* Moved the definitions for `getStatic{Offset,Stride,Size}` and `isCompletelyDynamic` out of the class declaration; because there's no benefit to inlining them.
* Changed `parse` to use `kDynamic` rather than literals.
* Changed `verify` to use the `isDynamic` helper.
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D150919
Jonas Devlieghere [Tue, 30 May 2023 22:54:04 +0000 (15:54 -0700)]
[lldb] Remove commented out code/logging in BreakpointSiteList (NFC)
Jim Ingham [Wed, 31 May 2023 00:12:35 +0000 (17:12 -0700)]
Fix SBValue::FindValue for file static variables
This was just a thinko. The API StackFrame::GetVariableList takes a
bool for "get_file_globals" which if true will also find file statics
and file globals. But we only were passing that as true if the
ValueType was eValueTypeVariableGlobal, which meant that we never find
file statics. It's okay if we cast too wide a net when we do
GetVariableList as later on we check against the ValueType to filter
globals from statics.
There was a test that had a whole bunch of globals and tested
FindValue on all of them, but had no statics. So I just made one of
the globals a file static, which verifies the fix.
Differential Revision: https://reviews.llvm.org/D151392
Jennifer Yu [Tue, 30 May 2023 17:20:31 +0000 (10:20 -0700)]
Fix assert "DeclRefExpr for Decl not entered in LocalDeclMap?"
Currently compiler assert when passing variable "memspace" in
omp_init_allocator.
omp_allocator_handle_t alloc=omp_init_allocator(memspace,1,traits)
The problem is memspace is not mapping to the target region. During
the call to emitAllocatorInit, calls to EmitVarDecl for "alloc", then
emit initialization of "alloc" that cause to assert.
If I understant correct, it is not necessary to emit variable
initialization, since "allocator" is private to target region.
To fix this call CGF.EmitAutoVarAlloca(allocator) instead
CGF.EmitVarDecl(allocator).
Differential Revision: https://reviews.llvm.org/D151743
LLVM GN Syncbot [Tue, 30 May 2023 23:31:47 +0000 (23:31 +0000)]
[gn build] Port
bf63b15bd4bf
Nico Weber [Tue, 30 May 2023 23:31:27 +0000 (19:31 -0400)]
[gn] port
48e5f704c55f (no more LLVM_HAVE_LIBXAR in ld64.lld)
Kazu Hirata [Tue, 30 May 2023 23:28:22 +0000 (16:28 -0700)]
[ExtractAPI] clang-format DeclarationFragments::insert
Jie Fu [Tue, 30 May 2023 23:20:24 +0000 (07:20 +0800)]
[clang][ExtractAPI] Fix -Wpessimizing-move in DeclarationFragments.h (NFC)
/Users/jiefu/llvm-project/clang/include/clang/ExtractAPI/DeclarationFragments.h:118:26: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
Fragments.insert(It, std::move(Fragment(Spelling, Kind, PreciseIdentifier,
^
/Users/jiefu/llvm-project/clang/include/clang/ExtractAPI/DeclarationFragments.h:118:26: note: remove std::move call here
Fragments.insert(It, std::move(Fragment(Spelling, Kind, PreciseIdentifier,
^~~~~~~~~~
1 error generated.
Spenser Bauman [Tue, 30 May 2023 21:45:19 +0000 (14:45 -0700)]
[mlir][tosa] Implement lowering for tosa.rfft2d
Implement a lowering for tosa.rfft2d to linalg.generic in the
TosaToLinalg transform.
Reviewed By: eric-k256
Differential Revision: https://reviews.llvm.org/D151095
Andrés Villegas [Tue, 30 May 2023 23:03:37 +0000 (16:03 -0700)]
[llvm-debuginfod][NFC] Switch to OptTable
Reviewed By: mysterymath
Differential Revision: https://reviews.llvm.org/D151273
Petr Hosek [Fri, 19 May 2023 07:35:08 +0000 (07:35 +0000)]
[CMake] Remove BOLT from Fuchsia toolchain
Fuchsia toolchain is currently broken due to
https://reviews.llvm.org/D151595. While we wait for it to be resolved,
remove BOLT to unbreak the Fuchsia toolchain build.
Differential Revision: https://reviews.llvm.org/D150939
wren romano [Tue, 30 May 2023 20:47:22 +0000 (13:47 -0700)]
[mlir][sparse] Removing unused helper function
Depends On D151505
Reviewed By: aartbik, Peiming
Differential Revision: https://reviews.llvm.org/D151522
wren romano [Tue, 30 May 2023 21:16:17 +0000 (14:16 -0700)]
[mlir][sparse] Adding new STEA::{with,without}DimSlices factories
(These factories are used in downstream code, despite not being used within the MLIR codebase.)
Depends On D151513
Reviewed By: Peiming
Differential Revision: https://reviews.llvm.org/D151518
wren romano [Tue, 30 May 2023 20:53:27 +0000 (13:53 -0700)]
[mlir][sparse] Updating STEA parser/printer to use the name "dimSlices"
Depends On D151505
Reviewed By: Peiming
Differential Revision: https://reviews.llvm.org/D151513
Dave Lee [Wed, 24 May 2023 17:30:49 +0000 (10:30 -0700)]
[lldb] Prevent dwim-print from showing kNoResult error
Expression evaluation for `void` valued expressions sets an error using the `kNoResult`
code. Like the `expression` command, `dwim-print` should also not print such errors.
Before:
```
(lldb) dwim-print (void)printf("hi\n")
hi
Error: 'unknown error'
```
After:
```
(lldb) dwim-print (void)printf("hi\n")
hi
```
rdar://
109746544
Differential Revision: https://reviews.llvm.org/D151351
Jason Molenda [Tue, 30 May 2023 22:13:36 +0000 (15:13 -0700)]
Fix a few bugs with Mach-O corefile loading, plus perf
In ProcessMachCore::LoadBinariesViaMetadata(), if we did
load some binaries via metadata in the core file, don't
then search for a userland dyld in the corefile / kernel
and throw away that binary list. Also fix a little bug
with correctly recognizing corefiles using a `main bin spec`
LC_NOTE that explicitly declare that this is a userland
corefile.
LocateSymbolFileMacOSX.cpp's Symbols::DownloadObjectAndSymbolFile
clarify the comments on how the force_lookup and how the
dbgshell_command local both have the same effect.
In PlatformDarwinKernel::LoadPlatformBinaryAndSetup, don't
log a message unless we actually found a kernel fileset.
Reorganize ObjectFileMachO::LoadCoreFileImages so that it delegates
binary searching to DynamicLoader::LoadBinaryWithUUIDAndAddress and
doesn't duplicate those searches. For searches that fail, we would
perform them multiple times in both methods. When we have the
mach-o segment vmaddrs for a binary, don't let LoadBinaryWithUUIDAndAddress
load the binary first at its mach-o header address in the Target;
we'll load the segments at the correct addresses individually later
in this method.
DynamicLoaderDarwin::ImageInfo::PutToLog fix a LLDB_LOG logging
formatter.
In DynamicLoader::LoadBinaryWithUUIDAndAddress, instead of using
Target::GetOrCreateModule as a way to find a binary already registered
in lldb's global module cache (and implicitly add it to the Target
image list), use ModuleList::GetSharedModule() which only searches
the global module cache, don't add it to the Target. We may not
want to add an unstripped binary to the Target.
Add a call to Symbols::DownloadObjectAndSymbolFile() even if
"force_symbol_search" isn't set -- this will turn into a
DebugSymbols call / Spotlight search on a macOS system, which
we want.
Only set the Module's LoadAddress if the caller asked us to do that.
Differential Revision: https://reviews.llvm.org/D150928
rdar://
109186357
Dave Lee [Tue, 30 May 2023 17:31:44 +0000 (10:31 -0700)]
[lldb] Consult summary provider before printing children of root references
When printing the root of a value, if it's a reference its children are unconditionally
printed - in contrast to pointers whose children are only printed if a sufficient
pointer depth is given.
However, the children are printed even when there's a summary provider that says not to.
If a summary provider exists, this change consults it to determine if children should be
printed.
For example, given a variable of type `std::string &`, this change has the following
effect:
Before:
```
(lldb) p string_ref
(std::string &) string_ref = "one two three four five six seven eight nine ten": {
__r_ = {
std::__1::__compressed_pair_elem<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep, 0, false> = {
__value_ = {
= {
__l = (__data_ = "one two three four five six seven eight nine ten", __size_ = 48, __cap_ = 64, __is_long_ = 1)
__s = (__data_ = "@\0p\U00000001\0`\0\00\0\0\0\0\0\0\0@", __padding_ = "\x80t<", __size_ = '\0', __is_long_ = '\x01')
__r = {
__words ={...}
}
}
}
}
}
}
```
After:
```
(lldb) p string_ref
(std::string &) string_ref = "one two three four five six seven eight nine ten"
```
rdar://
73248786
Differential Revision: https://reviews.llvm.org/D151748
Kazu Hirata [Tue, 30 May 2023 22:32:43 +0000 (15:32 -0700)]
Remove llvm::Optional
This is part of an effort to migrate from llvm::Optional to std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Differential Revision: https://reviews.llvm.org/D149128
ruturaj4 [Sat, 27 May 2023 23:54:56 +0000 (18:54 -0500)]
[clang][ExtractAPI] Modify declaration fragment methods to add a new fragment at an arbitrary offset.
ruturaj4 [Sun, 21 May 2023 17:34:56 +0000 (12:34 -0500)]
[clang][ExtractAPI] Modify declaration fragment methods to add a new fragment at an arbitrary offset.
The current implementation doesn't support merging declaration fragments at arbitrary offsets. This patch adds that support
by modifying declaration fragment methods.
Differential Revision: https://reviews.llvm.org/D151048
Amir Ayupov [Tue, 30 May 2023 21:47:14 +0000 (14:47 -0700)]
[BOLT] Add skip-non-simple for boltdiff
Extra filtering for boltdiff, excluding non-simple functions from comparison.
Reviewed By: #bolt, maksfb
Differential Revision: https://reviews.llvm.org/D151510
wren romano [Tue, 30 May 2023 20:16:29 +0000 (13:16 -0700)]
[mlir][sparse] Combining `dimOrdering`+`higherOrdering` fields into `dimToLvl`
This is a major step along the way towards the new STEA design. While a great deal of this patch is simple renaming, there are several significant changes as well. I've done my best to ensure that this patch retains the previous behavior and error-conditions, even though those are at odds with the eventual intended semantics of the `dimToLvl` mapping. Since the majority of the compiler does not yet support non-permutations, I've also added explicit assertions in places that previously had implicitly assumed it was dealing with permutations.
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D151505
Craig Topper [Tue, 30 May 2023 22:16:00 +0000 (15:16 -0700)]
[RISCV] Add some tail undisturbed vwmacc tests. NFC
These are additional tests for D151596.