500605 Commits

Author SHA1 Message Date
Michael Kruse
30e983c40c
[lld] Revise IDE folder structure (#89747)
Update the folder titles for targets in the monorepository that have not
seen taken care of for some time. These are the folders that targets are
organized in Visual Studio and XCode
(`set_property(TARGET <target> PROPERTY FOLDER "<title>")`)
when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically
deduce the folder. This reduces the number of
`set_property`/`set_target_property`, but are still necessary when
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's
root CMakeLists.txt.
2024-06-04 01:31:36 +02:00
smanna12
ccaccc3367
[Clang] Prevent null pointer dereference in target attribute mangling (#94228)
This patch adds assertions in the getMangledNameImpl() function to
ensure that the expected target attributes (TargetAttr,
TargetVersionAttr, and TargetClonesAttr) are not null before they are
passed to appendAttributeMangling() to prevent potential null pointer
dereferences and improve the robustness of the attribute mangling
process.

This assertion will trigger a runtime error with a clear message in
debug build if any of the expected attributes are missing, facilitating
early and easier diagnosis and debugging of such issues related to
attribute mangling.
2024-06-03 18:20:33 -05:00
antangelo
ae1596a31a
[AArch64] Support preserve_none calling convention (#91046)
Adds AArch64 support for the `preserve_none` calling convention.
Registers X0-X7, X9-X15 and X19-X28 are caller save, and can be used to
pass arguments. Delegates to AAPCS for all other registers.

Closes #87423
2024-06-03 18:42:08 -04:00
Jon Roelofs
4ee950e75d
update_test_checks: support more arm64_32-apple-watchos triples
Having the version in `get_run_handlers` meant that a RUN line without the
version in it would not match, and therefore UTC would generate a useless
catch-all check of the form:

```
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; CHECK: {{.*}}
```

This patch also adds `arm64_32` as a base-level run handler, and assumes it
will always apply to a darwin target (which is currently the case for all
arm64_32-* triples I see in tree currently).
2024-06-03 15:34:06 -07:00
Jon Roelofs
0b4af3a5f4
[llvm][SelectionDAG] Relax llvm.ptrmask's size check on arm64_32 (#94125)
Since pointers in memory, as well as the index type are both 32 bits,
but in registers pointers are 64 bits, the mask generated by
llvm.ptrmask needs to be zero-extended.

Fixes: #94075
Fixes: rdar://125263567
2024-06-03 15:26:30 -07:00
Peter Klausler
d03cd05f07
[flang] Propagate the BIND(C) attribute into procedures from their in… (#93994)
…terfaces

In "PROCEDURE(iface) :: proc", if "iface" has the BIND(C) attribute,
then so should proc, as if the declaration had been "PROCEDURE(iface),
BIND(C) :: proc". This had been working in name resolution only in cases
where "iface" had been declared before "proc".

Note that if "iface" is declared with an empty binding name
("BIND(C,NAME='')"), "proc" does not inherit that property. Use an
explicit "BIND(C,NAME='')" on the "PROCEDURE" statement for that.

This behavior is not clearly defined in the standard, but seems to match
what some other Fortran compilers do.
2024-06-03 14:49:08 -07:00
Peter Klausler
bd815a5489
[flang][runtime][CUDA] Fix build error (#94281)
I broke the build, and now I'm fixing it.
2024-06-03 14:37:46 -07:00
Krzysztof Drewniak
e31bfc040a
[AMDGPU] Strengthen preload intrinsics to noundef and nonnull (#92801)
The various preloaded registers (workitem IDs, workgroup IDs, and
various implicit pointers) always have a finite, invariant, well-defined
value throughout a well-defined program.

In cases where the compiler infers or the user declares that some
implicit input will not be used (ex. via amdgcn-no-workitem-id-y), the
behavior of the entire program is undefined, since that misdeclaration
can cause arbitrary other preloaded-register intrinsics to access the
wrong register. This case is not expected to arise in practice, but
could occur when the no implicit argument attributes were not cleared
correctly in the presence of external functions, indrect calls, or other
means of executing un-analyzable code. Failure to detect that case would
be a bug in the attributor.

This commit updates the documentation to reflect this long-standing
reality.

Then, on the basis that all implicit arguments are defined in all
correct programs, the intrinsics that return those values are
annototated with `noundef``. Some implicit pointer arguments gain a
`nonnull`, but the kernel argument segment pointer or implicit argument
pointers don't necessarily have this property.

This will prevent spurious calls to `freeze` in front-end optimizations
that destroy user-provided ranges on built-in IDs.

(While I'm here, this commit adds a test for `noundef` on kernel
arguments which is currently unimplemented)
2024-06-03 16:37:08 -05:00
Peter Klausler
a4bc44ad67
[flang] Disallow branches into SELECT TYPE/RANK cases (#93893)
Ensure that a branch cannot be made into a case of a SELECT TYPE or
SELECT RANK construct.
2024-06-03 14:34:12 -07:00
Peter Klausler
a8f2d185b2
[flang][runtime] Resilient opening of anonymous unit (#93876)
When an I/O statement references a unit number that has not been
explicitly opened or predefined, the I/O runtime support library opens a
local "fort.N" file. If this fails, the program crashes, even when the
I/O statement has IOSTAT= or IOMSG= or ERR= control list items. Connect
the dots to enable resilience in these cases.
2024-06-03 14:23:50 -07:00
Peter Klausler
ea2c88f512
[flang] Improve handling of NULL() arguments to intrinsics (#93866)
Some intrinsics (extends_type_of, same_type_as) can accept a NULL actual
argument so long as it has a MOLD=. Some intrinsics that are marked in
the intrinsics table as accepting a NULL actual argument already should
only do so if it has a MOLD=. Distinguish table entries that accept a
NULL() only with a MOLD= from the few others that allow a bare NULL()
and update tests.

Fixes https://github.com/llvm/llvm-project/issues/93845.
2024-06-03 14:13:45 -07:00
Peter Klausler
caa0a2695e
[flang] Add warnings about undefinable actuals for ASYNCHRONOUS/VOLAT… (#93851)
…ILE dummies

There's language in the standard (F'2023 15.5.2.5 p21) disallowing an
actual argument with a vector subscript from associating with a dummy
argument with either the ASYNCHRONOUS or VOLATILE attributes. This is a
bug in the standard, as (1) these attributes are actually relevant only
over the scope of the called procedure, (2) they can be applied in
nested scopes (internal subprograms and BLOCK) within the called
procedure, and (3) can be implicit within the called procedure and its
nested scopes in the case of ASYNCHRONOUS as a side effect of using a
dummy argument in an asynchronous data transfer statement. So issue a
warning. This new warning about undefinable actual arguments being
associated with ASYNCHRONOUS and VOLATILE dummy arguments subsumes an
existing warning about passing a constant actual to a VOLATILE dummy.

Resolves https://github.com/llvm/llvm-project/issues/93600.
2024-06-03 14:02:07 -07:00
royitaqi
c2d061da7e
Re-merge A few updates around "transcript" (#92843) (#94067)
Problematic PR: https://github.com/llvm/llvm-project/pull/92843
Reverted by: https://github.com/llvm/llvm-project/pull/94088

The first PR added a test which fails in Linux builds (see the last few
comments there).
This PR contains all the changes in the first PR, plus the fix to the
said test.

---------

Co-authored-by: Roy Shi <royshi@meta.com>
2024-06-03 13:52:03 -07:00
Peter Klausler
b61d7ec16b
[flang] Relax constraints on PURE/ELEMENTAL dummy arguments (#93748)
The standard requires that dummy arguments to PURE functions be
INTENT(IN) or VALUE, but PURE subroutines are allowed to have modifiable
dummy arguments. This makes it impossible to declare atomic operations
as PURE functions, which consequently makes such atomic operations
ineligible for use in parallel constructs and DO CONCURRENT.

This patch downgrades this error to a warning by default, which can be
seen with -pedantic & al. and remain an error with -Werror.
2024-06-03 13:46:31 -07:00
William Junda Huang
5cb00785aa
Add option to generate additional debug info for expression dereferencing pointer to pointers. (#94100)
This is another attempt to land #81545, which was reverted. 

Fixed test case by adding a target triple so that clang generates the same IR for all platforms
2024-06-03 16:42:24 -04:00
Peter Klausler
930c2d9111
[flang] Adjust %REF/%VAL semantic checking (#93718)
In accordance with other compilers, don't require that a %REF() actual
argument be a modifiable variable. And move the %REF/%VAL semantic
checks to Semantics/check-call.cpp, where one would expect to find them.

Fixes https://github.com/llvm/llvm-project/issues/93489.
2024-06-03 13:35:50 -07:00
Peter Klausler
74f4034f71
[flang] Fix type inheritance for statement function dummy arguments (#93624)
The code that used existing type declarations (if any) for the names
being used as dummy arguments in a statement function definition would
apply those types only if they came from EntityDetails symbols. This
broke a case in which the type was being inherited from a Cray pointee.

Fixes https://github.com/llvm/llvm-project/issues/93484.
2024-06-03 13:25:57 -07:00
Jake Egan
037a0528bb
[libc++] Handle 0 size case for testing support operator new (#93834)
The return of malloc is implementation defined when the requested size
is 0. On platforms (such as AIX) that return a null pointer for 0 size,
operator new will throw a bad_alloc exception. operator new should
return a non null pointer for 0 size instead.
2024-06-03 16:23:08 -04:00
Fangrui Song
6ef632ad36 [BOLT,test] Fix lsda.ldscript when MAXPAGESIZE>=0x10000
The intention is to check a section name different from
.gcc_except_table . Rather than using a linker script, use llvm-objcopy
--rename-section instead.
2024-06-03 13:18:58 -07:00
Peter Klausler
c93312a63d
[flang] Handle USE-associated symbols in module procedure interface b… (#93616)
…lock specification expressions

A subroutine or function interface block is of course allowed to
USE-associate symbols into its scope and use them for specification
expressions. This usage works, but crashes the module file output
generator. Fix.

Fixes https://github.com/llvm/llvm-project/issues/93413.
2024-06-03 13:13:16 -07:00
Paul T Robinson
e783d5dbb6
[Driver] Fix the sysroot.c test properly (#94276)
A DEFAULT_SYSROOT interfered with the test, apparently. See #94055.
2024-06-03 16:09:23 -04:00
Peter Klausler
c7593344f4
[flang] Better error message for RANK(NULL()) (#93577)
We currently complain that the argument may not be a procedure, which is
confusing. Distinguish the NULL() case from other error cases (which are
indeed procedures). And clean up the utility predicates used for these
tests -- the current IsProcedure() is really just a test for a procedure
designator.
2024-06-03 12:58:39 -07:00
Owen Pan
13f6797826
[clang-format] Handle AttributeMacros in parseRecord() (#94189)
Fixes #94184.
2024-06-03 12:55:10 -07:00
Michael Jones
572b4e70cb
[libc][bazel] simplify type_traits with glob (#94079)
Previously the `type_traits` target manually listed all of the type
traits files. This patch replaces that with a glob to make the build
simpler.
2024-06-03 12:51:01 -07:00
Mircea Trofin
c49bc1a3b7 BitcodeWriter: ensure Buffer is heap allocated
PR #92983 accidentally changed the buffer allocation in
`llvm::WriteBitcodeToFile` to be allocated on the stack, which is
problematic given it's a large-ish buffer (256K)
2024-06-03 12:48:23 -07:00
Joseph Huber
cf3b37c92f [libc] Add GPU utility dependencies if present
Summary:
These tools need to be built before we can do the library creation
stage. If they are generated in the same build then this is not
guaranteed so we should add explicit dependencies.
2024-06-03 14:37:39 -05:00
Florian Hahn
07b330132c
[VPlan] Model FOR extract of exit value in VPlan. (#93395)
This patch introduces a new ExtractFromEnd VPInstruction opcode to
extract the value of a FOR for users outside the loop (i.e. in the
scalar loop's exits). This moves the first part of fixing first order
recurrences to VPlan, and removes some additional code to patch up
live-outs, which is now handled automatically.

The majority of test changes is due to changes in the order of which the
extracts are generated now. As we are now using VPTransformState to
generate the extracts, we may be able to re-use existing extracts in the
loop body in some cases. For scalable vectors, in some cases we now have
to compute the runtime VF twice, as each extract is now independent, but
those should be trivial to clean up for later passes (and in line with
other places in the code that also liberally re-compute runtime VFs).

PR: https://github.com/llvm/llvm-project/pull/93395
2024-06-03 20:20:30 +01:00
Peter Klausler
0525c201b6
[flang][preprocessing] Handle #include after & line continuation (#93382)
Some applications like to use a CPP-style #include directive to pull in
a common list of arguments, dummy arguments, or COMMON block variables
after a free-form & line continuation marker. This works naturally with
compilers that run an actual cpp pass over the input before doing
anything specific to Fortran, but it's a case that I missed with this
integrated preprocessor.
2024-06-03 12:18:30 -07:00
Peter Klausler
68f4e46c43
[flang] Adjust "doubled operator" expression extension (#93353)
Most Fortran compilers accept "doubled operators" as a language
extension. This is the use of a unary '+' or '-' operator that is not
the first unparenthesized operator in an expression, as in 'x*-y'.

This compiler has implemented this extension, but in a way that's
different from other compilers' behavior. I interpreted the unary
'+'/'-' as a unary operator in the sense of C/C++, giving it a higher
priority than any binary (dyadic) operator.

All other compilers with this extension, however, give a unary '+'/'-' a
lower precedence than exponentiation ('**'), a binary operator that
C/C++ lacks. And this interpretation makes more sense for Fortran,
anyway, where the standard conforming '-x**y' must mean '-(x**y)'
already.

This patch makes 'x*-y**z' parse as 'x*-(y**z)', not 'x*(-y)**z)', and
adds a test to ensure that it does.
2024-06-03 11:58:18 -07:00
PiJoules
e44cea597c
[libc][CPP] Add all_of and find_if_not to algorithm.h (#94058)
This is needed for the allocator implementation for malloc.
2024-06-03 11:44:44 -07:00
OverMighty
25b037bdb5
[libc][math][c23] Add {ceil,floor,round,roundeven,trunc}f16 C23 math functions (#94001) 2024-06-03 14:28:51 -04:00
Joseph Huber
2ee7f49add [libc] Correctly find LLVM binaries when built in projects mode for GPU
Summary:
You can build the GPU libc support in projects mode. There were some
issues with it not finding the correct binaries. This patch fixes that.
2024-06-03 13:08:51 -05:00
Raul Tambre
2bc098b8ab
[clang][Sema] Don't issue -Wcast-function-type-mismatch for enums with a matching underlying type (#87793)
Enums are passed as their underlying integral type so they're ABI compatible if the size matches.
Useful with C APIs that pass user-controlled values to callbacks that can be made type safe by using enumerations (e.g. GStreamer).

Discovered internally in some code after 999d4f840777bf8de26d45947192aa0728edc0fb.
2024-06-03 20:56:59 +03:00
Fangrui Song
a088c61d5c [SPIRV] Fix -Wunused-but-set-variable after #92531 2024-06-03 10:36:59 -07:00
Justin Fargnoli
3e228c8eaf
[GitHub] Add NVPTX backend labeler (#94080)
Add patterns to label NVPTX backend related changes automatically.
2024-06-03 10:27:56 -07:00
Abinaya Saravanan
4f326468bd
[InstCombine] Retain debug information on store to null instruction (#86105)
Call InsertNewInstWith() instead of InsertNewInstBefore() when creating
"store to null" instruction
2024-06-03 18:26:32 +01:00
David Spickett
0232e2b15b
[lldb] Add Python requirements.txt for test suite (#94220)
This means that CI won't have to hardcode these.
2024-06-03 18:25:05 +01:00
Jeremy Day
cb7690af09
[Support] Handle delete_pending case for Windows fs::status (#90655)
If a delete is pending on the file queried for status, a misleading
`permission_denied` error code will be returned (this is the correct
mapping of the error set by GetFileAttributesW). By querying the
underlying NTSTATUS code via ntdll's RtlGetLastNtStatus, this case can
be disambiguated. If this underlying error code indicates a pending
delete, fs::status will return a new `pending_delete` error code to be
handled by callers

Fixes #89137
2024-06-03 10:22:44 -07:00
Jordan Rupprecht
10ecdee651
Revert "fix(utils/**.py): fix comparison to None" (#94261)
Reverts llvm/llvm-project#94022

This is not actually valid bazel syntax. Buildbot failure: https://buildkite.com/llvm-project/upstream-bazel/builds/99430#018fdf11-6865-4d5d-be8e-7bfab59e3cd8
2024-06-03 12:19:50 -05:00
Joseph Huber
ebd6227378
[LLVM] Fix runtimes builds not triggering without LLVM_ENABLE_RUNTIMES (#94225)
Summary:
The runtimes builds create separate projects. Normally these use
`LLVM_EANBLE_RUNTIMES`. However, we can also use `LLVM_RUNTIME_TARGETS`
and `RUNTIMES_<target>_LLVM_ENABLE_RUNTIMES` to enable them. Currently,
if `LLVM_RUNTIME_TARGETS` isn't specified this is completely ignored.
This patch fixes the behavior so we can only specify the cross-compiling
versions.
2024-06-03 12:11:14 -05:00
Paul T Robinson
2f8675a026
[Driver] Fix a CUDA test (#94258)
See #94000 for a report of a downstream failure, this fixes it.
2024-06-03 13:09:27 -04:00
Eisuke Kawashima
f873dd2c8d
fix(utils/**.py): fix comparison to None (#94022)
from PEP8
(https://peps.python.org/pep-0008/#programming-recommendations):

> Comparisons to singletons like None should always be done with is or
is not, never the equality operators.

Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2024-06-03 12:06:48 -05:00
Raul Tambre
ffec63b6a5
[cmake] Pass -resource-dir to external projects as CMAKE_<LANG>_FLAGS_INIT instead of as a force override (#87330)
It's useful to use toolchain files for configuring runtimes builds.
Setting `CMAKE_<LANG>_FLAGS` is however forceful and precludes initialization from the _INIT variant meant to be set by toolchains.
The toolchain file still needs to append instead of just setting and be idempotent (`include_guard()`), but this way at least a special toolchain to account for LLVM won't be required.
2024-06-03 19:46:06 +03:00
Paul T Robinson
af9a247990
[Driver] Mark a test UNSUPPORTED to get the bots green again (#94253)
After #94055 this test failed on ARM/AArch64-hosted Windows, but it's
not clear why.
2024-06-03 12:39:32 -04:00
Michael Buch
aad7874000 [lldb][test][NFC] TestBreakpointSetRestart.py: split up assertion to determine which check specifically fails in CI
This test consistently fails on the public macOS ASAN CI (and isn't
reproducible locally):
```
FAIL: test_breakpoint_set_restart_dwarf
(TestBreakpointSetRestart.BreakpointSetRestart)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
line 1756, in test_method
    return attrvalue(self)
  File
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py",
line 150, in wrapper
    return func(*args, **kwargs)
  File
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/lldb/test/API/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py",
line 36, in test_breakpoint_set_restart
    self.assertTrue(bp.IsValid() and bp.GetNumLocations() == 1,
VALID_BREAKPOINT)
AssertionError: False is not true : Got a valid breakpoint
```

From this error we're not quite sure what about the breakpoint here is
the problem.

This patch splits up the assertion to narrow down the issue.
2024-06-03 17:04:16 +01:00
Vladislav Dzhidzhoev
6b7b05b559 [lldb][test] Add --make argument to dotest.py (#93883)
This argument allows to specify the path to make which is used by
LLDB API tests to compile test programs.
It might come in handy for setting up cross-platform remote runs of API tests on Windows host.

It can be used to override the make path of LLDB API tests using `LLDB_TEST_USER_ARGS` argument:
```
cmake ...
-DLLDB_TEST_USER_ARGS="...;--make;C:\\Path\\to\\make.exe;..."
...
```
2024-06-03 17:30:10 +02:00
A. Jiang
ac4cca3cb1
[libc++] Fix regression about parsing leading decimal points (#93989)
PR #77948 mistakenly rejected floating-point representation with a
leading decimal point, e.g. ".5".

This PR fixes the regression mentioned in
https://github.com/llvm/llvm-project/pull/77948#issuecomment-2141740346.
2024-06-03 11:28:58 -04:00
Nishith Kumar M Shah
9862080b1c
Pass LangOpts from CompilerInstance to DependencyScanningWorker (#93753)
This commit fixes https://github.com/llvm/llvm-project/issues/88896 by
passing LangOpts from the CompilerInstance to
DependencyScanningWorker so that the original LangOpts are
preserved/respected.
This makes for more accurate parsing/lexing when certain language
versions or features specific to versions are to be used.
2024-06-03 17:20:43 +02:00
jeanPerier
d1aa9bac3c
[flang] lower select rank (#93967)
Lower select rank according to [assumed-rank lowering design
doc](https://github.com/llvm/llvm-project/blob/main/flang/docs/AssumedRank.md).

The construct is lowered using fir.box_rank and fir.select_case
operation and, for the non pointer/allocatable case, a
fir.is_assumed_size + conditional branch before the select_case to deal
with the assumed-size case.

The way the CFG logic is generated, apart from the extra conditional
branch for assumed-size, is similar to what is done for SELECT CASE
lowering, hence the sharing of the construct level visitor. 
For the CFG parts. The main difference is that we need to keep track of
the selector to cook it and map it inside the cases (hence the new
members of the ConstructContext).

The only TODOs left are to deal with the RANK(*) case for polymorphic
entities and PDTs. I will do the polymorphic case in a distinct patch,
this patch has enough content.

Fortran::evaluate::IsSimplyContiguous change  is needed to avoid generating
copy-in/copy-out runtime calls when passing the RANK(*) associating
entity to some implicit interface.
2024-06-03 17:20:07 +02:00
Shilei Tian
4cd115ca34
[OpenMP][OMPX] Fix ompx_ballot_sync test (#94140)
The current test is not really correct because the mask is set to
0xffffffff
even if it is on an AMDGPU whose wavefront size is 64. Besides,
`__AMDGCN_WAVEFRONT_SIZE` is not set on host compilation so the
verification
happens to work.
2024-06-03 11:18:26 -04:00