523882 Commits

Author SHA1 Message Date
Nathan Ridge
9ac6a55ec5
[clang][AST] Assert that DependentNameType's Name and NNS are not null (#122418)
Also clarify the comment above DependentNameType::getIdentifier()
2025-01-14 23:06:51 -05:00
Craig Topper
da4ac13aca
[RISCV][llvm-exegesis] Simplify copying a SmallVector to a std::vector. NFC (#122988) 2025-01-14 20:04:27 -08:00
Lang Hames
9f48bb637e [JITLink] Document EHFrameEdgeFixer's handling of implicit relocations. NFC.
On platfarms where some relocations for eh-frame sections are implicit (e.g.
MachO/x86-64) EHFrameEdgeFixer is responsible for adding edges for the
implicit relocations.
2025-01-15 14:20:07 +11:00
Lang Hames
9c5001e454 [JITLink] Add convenience methods to LinkGraph to find symbols by name.
Adds new convenience methods findDefinedSymbolByName, findExternalSymbolByName
and findAbsoluteSymbolByName to the LinkGraph class. These should be used to
find symbols of the given types by name.

COFFLinkGraphBuilder and MachOPlatform are updated to take advantage of the
new methods.
2025-01-15 14:11:18 +11:00
Lang Hames
21ade5ae29 [JITLink] Fix indentation in debugging output. 2025-01-15 13:26:48 +11:00
Vitaly Buka
e7f756d468
[NFC][BoundsChecking] Address #122576 review comments (#122773) 2025-01-14 18:22:54 -08:00
Lang Hames
2a5281d0e0 [ORC-RT] Fix missing '\' line continuations in objc-imageinfo.S test.
These missing continuations were causing commands in this testcase to fail.
2025-01-15 13:21:28 +11:00
LiqinWeng
0294dab79e
[LV][VPlan] Add fast flags for selectRecipe (#121023)
Change the inheritance of class VPWidenSelectRecipe to class
VPRecipeWithIRFlags, which allows recipe of the select to pass the
fastmath flags.The patch of #119847 will add the fastmath flag to for
recipe
2025-01-15 10:10:11 +08:00
Diego Caballero
ef4800c916
[mlir][Interfaces][NFC] Update doc of ViewLikeOpInterface parser/printer handlers (#122555)
This PR addresses part of the feedback provided in #115808.
2025-01-14 17:58:52 -08:00
Longsheng Mou
565f3bd641
[mlir][linalg] Remove redundant checks for variable(NFC) (#122731)
This PR removes the redundant checks for the `supported` variable, as
it's guaranteed to be true.
2025-01-15 09:45:51 +08:00
Valentin Clement (バレンタイン クレメン)
a19919f4cd
[flang][cuda] Add cuf.device_address operation (#122975)
Introduce a new op to get the device address from a host symbol. This
simplify the current conversion and this is also in preparation for some
legalization work that need to be done in cuf kernel and cuf kernel
launch similar to
https://github.com/llvm/llvm-project/pull/122802
2025-01-14 17:38:04 -08:00
Shilei Tian
ebef44067b
[LLVM][Triple] Add an argument to specify canonical form to Triple::normalize (#122935)
Currently, the output of `Triple::normalize` can vary depending on how the
`Triple` object is constructed, producing a 3-field, 4-field, or even 5-field
string. However, there is no way to control the format of the output, as all
forms are considered canonical according to the LangRef.

This lack of control can be inconvenient when a specific format is required. To
address this, this PR introduces an argument to specify the desired format (3,
4, or 5 identifiers), with the default set to none to maintain the current
behavior. If the requested format requires more components than are available in
the actual `Data`, `"unknown"` is appended as needed.
2025-01-14 20:12:29 -05:00
Shoreshen
b665dddd70
[AMDGPU] Add tests for v_sat_pk_u8_i16 codegen (#122438)
Preparation for #121124 

This PR provides tests added into
[PR](https://github.com/llvm/llvm-project/pull/121124) that add
selection patterns for instruction `v_sat_pk`, in order to specify the
change of the tests before and after the commit.

Pre-commit tests PR for #121124 : Add selection patterns for instruction
`v_sat_pk`
2025-01-14 19:26:46 -05:00
zotnhucucbot
bc74625f50
[clang-tidy] Add an option to exclude files not present in the compile database (#120348)
A change list may include files that are not part of the compile
database, which can cause clang-tidy to fail (e.g., due to missing
included headers). To prevent false negatives, we should allow to skip
processing these files.
2025-01-15 07:59:03 +08:00
Kazu Hirata
99ab848a65
[CodeGen] Avoid repeated hash lookups (NFC) (#122861) 2025-01-14 15:27:00 -08:00
Kazu Hirata
466753b109
[AST] Avoid repeated map lookups (NFC) (#122858) 2025-01-14 15:26:36 -08:00
Kazu Hirata
a1f8ce683a
[StaticAnalyzer] Migrate away from PointerUnion::dyn_cast (NFC) (#122856)
Note that PointerUnion::dyn_cast has been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //        isa<T>, cast<T> and the llvm::dyn_cast<T>

Literal migration would result in dyn_cast_if_present (see the
definition of PointerUnion::dyn_cast), but this patch uses dyn_cast
because we expect Storage to be nonnull.
2025-01-14 15:26:08 -08:00
Kazu Hirata
e673f9d00d
[Sema] Migrate away from PointerUnion::dyn_cast (NFC) (#122855)
Note that PointerUnion::dyn_cast has been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //        isa<T>, cast<T> and the llvm::dyn_cast<T>

Literal migration would result in dyn_cast_if_present (see the
definition of PointerUnion::dyn_cast), but this patch uses dyn_cast
because we expect DeclOrVector to be nonnull.
2025-01-14 15:25:30 -08:00
Kazu Hirata
2b961b0643
[AST] Migrate away from PointerUnion::dyn_cast (NFC) (#122854)
Note that PointerUnion::dyn_cast has been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //        isa<T>, cast<T> and the llvm::dyn_cast<T>

Literal migration would result in dyn_cast_if_present (see the
definition of PointerUnion::dyn_cast), but this patch uses dyn_cast
because we expect Source to be nonnull.
2025-01-14 15:25:08 -08:00
Eli Friedman
7aec7caca3 Add explicit triple to test_type.py.
Fixes on 32-bit hosts.
2025-01-14 14:49:45 -08:00
Florian Hahn
0b3912622e [ARM] Update LV test in test/Codegen/ARM after 1de3dc7d23. 2025-01-14 22:41:31 +00:00
Min Hsu
72225ca27f Revert "Reland: "[Exegesis] Add the ability to dry-run the measurement phase (#121991)" (#122775)"
This reverts commit a39aaf35d3858a5542f532e399482c2bb0259dac and
63d3bd6d0caf8185aba49540fe2f67512fdf3a98.

Due to test failures on MacOSX.
2025-01-14 14:18:58 -08:00
Martin Storsjö
a829ebadd4
[Triple] Ignore the vendor field for MinGW, wrt LTO/IR compatibility (#122801)
For MinGW environments, the regular C/C++ toolchains usually use "w64"
for the vendor field in triples, while Rust toolchains usually use "pc"
in the vendor field.

The differences in the vendor field have no bearing on whether the IR is
compatible on this platform. (This probably goes for most other OSes as
well, but limiting the scope of the change to the specific case.)

Add a unit test for the isCompatibleWith, including some existing test
cases found in existing tests.
2025-01-15 00:18:52 +02:00
Jorge Gorbe Moya
43f203da89 [bazel] add missing dep 2025-01-14 14:17:31 -08:00
Florian Hahn
1de3dc7d23 [LV] Bail out early if BTC+1 wraps.
Currently we fail to detect the case where BTC + 1 wraps, i.e. the
vector trip count is 0, In those cases, the minimum iteration count
check will fail, and the vector code will never be executed.

Explicitly check for this condition in computeMaxVF and avoid trying to
vectorize alltogether.

Note that a number of tests needed to be updated, because the vector
loop would never be executed given the input IR.

Fixes https://github.com/llvm/llvm-project/issues/122558.
2025-01-14 22:07:38 +00:00
Valentin Clement (バレンタイン クレメン)
25f28ddd69
[flang][cuda][NFC] Fix file header 2025-01-14 14:05:57 -08:00
Eli Friedman
1682deed0f
[libclang] Add API to query more information about base classes. (#120300)
The first API is clang_visitCXXBaseClasses: this allows visiting the
base classes without going through the generic child visitor (which is
awkward, and doesn't work for template instantiations).

The second API is clang_getOffsetOfBase; this allows computing the
offset of a base in the class layout, the same way
clang_Cursor_getOffsetOfField computes the offset of a field.

Also, add a Python binding for the existing function
clang_isVirtualBase.
2025-01-14 13:57:44 -08:00
Teresa Johnson
6a214ec1ee
[MemProf] Fix an assertion when writing distributed index for aliasee (#122946)
The ThinLTO index bitcode writer uses a helper forEachSummary to manage
preparation and writing of summaries needed for each distributed index
file. For alias summaries, it invokes the provided callback for the
aliasee as well, as we at least need to produce a value id for the
alias's summary. However, all summary generation for the aliasee itself
should be skipped on calls when IsAliasee is true. We invoke the
callback again if that value's summary is to be written as well.

We were asserting in debug mode when invoking collectMemProfCallStacks,
because a given stack id index was not in the StackIdIndicesToIndex
map. It was not added because the forEachSummary invocation that records
these ids in the map (invoked from the IndexBitcodeWriter constructor)
was correctly skipping this handling when invoked for aliasees. We need
the same guard in the invocation that calls collectMemProfCallStacks.

Note that this doesn't cause any real problems in a non-asserts build
as the missing map lookup will return the default 0 value from the map,
which isn't used since we don't actually write the corresponding
summary.
2025-01-14 13:46:34 -08:00
Jerry-Ge
f09db6a3af
[TOSA] Add Tosa_Shape type and ConstShapeOp (#122547)
Adds:
1. tosa shape type to Tosa dialect e.g., !tosa.shape<4> is a type for
rank-4 shape values (size-4 array of index values)
 2. const_shape operator
3. trait TosaShapeOperator, added to tosa shape operators, and a
verifier that all operands and results of operator are tosa shapes
4. trait TosaResolvableShapeOperands, added to all tosa operators, and a
verifier that every tosa shape operand is produced by a tosa shape
operator (indicated by trait TosaShapeOperator)
5. trait TosaShapeOperatorWithSameRanks, added to
Tosa_ElementwiseShapeOp and a verifier that all operands and result
shapes have same ranks
5. changed TileOp's multiples from attribute to input, of !tosa.shape
type.
 6. add folder for tosa ConstShape operator

This patch was originally authored by Tai Ly <tai.ly@arm.com>

Signed-off-by: Jerry Ge <Jerry.Ge@arm.com>
Signed-off-by: Tai Ly <tai.ly@arm.com>
2025-01-14 13:41:08 -08:00
Justin Bogner
31249e27f0
[DirectX] Avoid deprecated PointerUnion methods (#122972)
PointerUnion's `is`, `get`, and `dyn_cast` have been deprecated in
favour of using `isa`, `cast`, and `dyn_cast` directly. Migrate these
uses over.
2025-01-14 14:37:15 -07:00
Jorge Gorbe Moya
6e14f9b40e
[bazel] minor formatting fixes (#122964)
Added `# keep sorted` to a couple of long-ish lists of files that
buildifier didn't automatically sort by default.

Changed a couple of one-element `toolchains` attributes to the
single-line format.
2025-01-14 13:27:50 -08:00
Nikolas Klauser
ef804d8f9b
[libc++] Simplify when the sized global deallocations overloads are available (#114667)
There doesn't seem to be much benefit in always providing declarations
for the sized deallocations from C++14 onwards if the user explicitly
passed `-fno-sized-deallocation` to disable them. This patch simplifies
the declarations to be available exactly when the compiler expects sized
deallocation functions to be available.
2025-01-14 16:21:03 -05:00
Michael Buch
3d24c77f14
[clang][DebugInfo] Emit DW_AT_object_pointer on function definitions with explicit this (#122897)
We currently don't emit `DW_AT_object_pointer` on function declarations
or definitions. GCC suffers from the same issue:
https://godbolt.org/z/h4jeT54G5

Fixing this will help LLDB in identifying static vs. non-static member
functions (see https://github.com/llvm/llvm-project/issues/120856).

If I interpreted the DWARFv5 spec correctly, it doesn't mandate this
attribute be present *only* for implicit object parameters:
```
If the member function entry describes a non-static member function,
then that entry has a DW_AT_object_pointer attribute whose value is a reference to
the formal parameter entry that corresponds to the object for which the
function is called.

That parameter also has a DW_AT_artificial attribute whose value is true.
```

This patch attaches the `DW_AT_object_pointer` for function
*defintions*. The declarations will be handled in a separate patch.

The part about `DW_AT_artificial` seems overly restrictive, and not true
for explicit object parameters. We probably should relax this part of
the DWARF spec.

Partially fixes https://github.com/llvm/llvm-project/issues/120974
2025-01-14 21:12:13 +00:00
alx32
93fd72cbb1
[llvm-gsymutil] Ensure gSYM creation determinism with merged functions (#122921)
We were seeing occasional test failures with expensive checks enabled.
The issue was tracked down to a `sort` which should instead be a
`stable_sort` to ensure determinism. Checked locally and the
non-determinism went away.
2025-01-14 13:07:16 -08:00
Peter Klausler
ecf264d3b4
[flang] Fix spurious error message due to inaccessible generic binding (#122810)
Generic operator/assignment checks for distinguishable specific
procedures must ignore inaccessible generic bindings.

Fixes https://github.com/llvm/llvm-project/issues/122764.
2025-01-14 13:02:21 -08:00
Peter Klausler
9629f2c4ca
[flang] Improve module file error message wording (#122787)
Instead of "Cannot read ...", distinguish true errors in finding and
parsing module files from problems with unexpected hash codes by using
"Cannot parse" or "Cannot use" wording as appropriate.
2025-01-14 13:01:56 -08:00
Peter Klausler
4a3e4b99b9
[flang] Adjust prescanner fix for preprocessing (#122779)
Commas being optional in FORMAT statements, the tokenization of things
like 3I9HHOLLERITH is tricky. After tokenizing the initial '3', we don't
want to then take apparent identifier "I9HHOLLERITH" as the next token.
So the prescanner just consumes the letter ("I") as its own token in
this context.

A recent bug report complained that this can lead to incorrect results
when (in this case) the letter is a defined preprocessing macro. I
updated the prescanner to check that the letter is actually followed by
an instance of a problematic Hollerith literal.

And this broke two tests in the Fujitsu Fortran test suite that Linaro
runs, as it couldn't detect a following Hollerith literal that wasn't on
the same source line. We can't do look-ahead line continuation
processing in NextToken(), either.

So here's a second attempt at fixing the original problem: namely, the
letter that follows a decimal integer token is checked to see whether
it's the name of a defined macro.
2025-01-14 13:01:31 -08:00
Peter Klausler
9f0f54a629
[flang] Improve error messages for module self-USE (#122747)
A module can't USE itself, either directly within the top-level module
or from one of its submodules. Add a test for this case (which we
already caught), and improve the diagnostic for the more confusing case
involving a submodule.
2025-01-14 13:00:03 -08:00
Peter Klausler
874a3ba868
[flang][runtime] Don't buffer unit 0 (#122614)
Always assume that predefined unit 0 is a terminal, so that output to it
is never buffered.
2025-01-14 12:58:42 -08:00
Peter Klausler
bf95854e9a
[flang] EOF goes to ERR= in READ(..., REC=) (#122608)
A direct access READ that tries to read past the end of the file must
recover the error via an ERR= label, not an END= label (which is not
allowed to be present).

Fixes https://github.com/llvm/llvm-project/issues/122150.
2025-01-14 12:58:16 -08:00
Peter Klausler
9696355484
[flang] Better messages and error recovery for a bad RESHAPE (#122604)
Add tests for negative array extents where necessary, motivated by a
compiler crash exposed by yet another fuzzer test, and improve overall
error message quality for RESHAPE().

Fixes https://github.com/llvm/llvm-project/issues/122060.
2025-01-14 12:57:49 -08:00
Peter Klausler
89bbaf3cf2
[flang] Fix another crash from another fuzzer test. (#122562)
Fixes https://github.com/llvm/llvm-project/issues/122045.
2025-01-14 12:57:10 -08:00
Peter Klausler
ebec4d6369
[flang] Fix use-after-free cases found by valgrind (#122394)
The expression traversal library needs to use interfaces into triplets
(and substrings) that return pointers to nested expressions, rather than
optional copies of them, since at least one semantic analysis collects a
set of references to some subexpression representation class instances,
and those references obviously can't point to local copies of objects.

Fixes https://github.com/llvm/llvm-project/issues/121999.
2025-01-14 12:56:33 -08:00
Peter Klausler
b720b6cbe9
[flang] Fix crash from fuzzy test. (#122364)
Fixes https://github.com/llvm/llvm-project/issues/122002.
2025-01-14 12:56:03 -08:00
Jinsong Ji
8d1d67ec4d
[Offload][PGO] Fix dump of array in ProfData (#122039)
Exposed by -Warray-bounds:

In file included from
../../../../../../../llvm/offload/plugins-nextgen/common/src/GlobalHandler.cpp:252:

../../../../../../../llvm/llvm/include/llvm/ProfileData/InstrProfData.inc:109:1:
error: array index 4 is past the end of the array (that has type 'const
std::remove_const<const uint16_t>::type[4]' (aka 'const unsigned
short[4]')) [-Werror,-Warray-bounds]
109 | INSTR_PROF_DATA(const uint16_t, Int16ArrayTy,
NumValueSites[IPVK_Last+1], \
| ^ ~~~~~~~~~~~

../../../../../../../llvm/offload/plugins-nextgen/common/src/GlobalHandler.cpp:250:15:
note: expanded from macro 'INSTR_PROF_DATA'
250 | outs() << ProfData.Name << " "; \
      |               ^        ~~~~

../../../../../../../llvm/llvm/include/llvm/ProfileData/InstrProfData.inc:109:1:
note: array 'NumValueSites' declared here
109 | INSTR_PROF_DATA(const uint16_t, Int16ArrayTy,
NumValueSites[IPVK_Last+1], \
      | ^

../../../../../../../llvm/offload/plugins-nextgen/common/include/GlobalHandler.h:62:3:
note: expanded from macro 'INSTR_PROF_DATA'
   62 |   std::remove_const<Type>::type Name;

Avoid accessing out-of-bound data, but skip printing array data for now.
As there is no simple way to do this without hardcoding the
NumValueSites field.

---------

Co-authored-by: Ethan Luis McDonough <ethanluismcdonough@gmail.com>
2025-01-14 15:46:27 -05:00
Eliud de León
43491f0e95
[mlir][emitc] Expose emitc dialect types (#119645)
Added C API functions for the EmitC dialect types.
2025-01-14 21:46:06 +01:00
Jorge Gorbe Moya
68c9826534 [bazel] add missing dep to //clang:static_analyzer_core_options 2025-01-14 12:18:31 -08:00
Razvan Lupusoru
11758f9ceb
[flang][acc] Add missing dependency to bbc tool (#122960)
The LLVM build here:

https://lab.llvm.org/buildbot/#/builders/89/builds/14359/steps/5/logs/stdio
is failing with error:
/usr/bin/ld: tools/flang/tools/bbc/CMakeFiles/bbc.dir/bbc.cpp.o:
undefined reference to symbol
'_ZN3fir3acc25registerOpenACCExtensionsERN4mlir15DialectRegistryE

Add missing dependency.
2025-01-14 12:01:43 -08:00
Ramkumar Ramachandra
60dc450078
SCEV: migrate to CmpPredicate (NFC) (#122907)
In preparation to teach implied-cond functions about samesign, migrate
integer-compare predicates that flow through to the functions from
CmpInst::Predicate to CmpPredicate.
2025-01-14 19:58:51 +00:00
Ramkumar Ramachandra
48757e02ba
[InstCombine] Teach foldSelectOpOp about samesign (#122723)
Follow up on 4a0d53a (PatternMatch: migrate to CmpPredicate) to get rid
of one of the FIXMEs it introduced by replacing a predicate comparison
with CmpPredicate::getMatching.
2025-01-14 19:58:17 +00:00