[Clang][C2y] Make the 'if' declaration extension warning on by default
Declarations in the condition of 'if' and 'switch' statements (N3356)
were previously only diagnosed in pre-C2y modes under -pedantic, since
the C compatibility warnings default to Extension. Promote the
diagnostic to an ExtWarn so users on older language modes are told
they are relying on a C2y extension; -Wno-c2y-extensions silences it.
Co-Authored-By: Claude Fable 5.1 <noreply at anthropic.com>
[Clang][C2y] Simplify condition-declaration diagnostics in C
Key the diagnostics on whether a declaration is permitted as the
condition (only as the sole clause of an 'if' or 'switch'), so the two
"expected expression" emissions collapse into one and the first-clause
check is no longer nested inside the branching. No functional change.
Co-Authored-By: Claude Fable 5.1 <noreply at anthropic.com>
[lldb][OpenBSD] Fix sysctl usage for process info (#122534)
The OpenBSD Host code used FreeBSD-style sysctl MIBs, which don't
match OpenBSD's interface, so process lookups failed.
- GetOpenBSDProcessArgs: use {CTL_KERN, KERN_PROC_ARGS, pid,
KERN_PROC_ARGV}. OpenBSD returns a NULL-terminated argv array
whose pointers point into the returned buffer, so iterate it
directly.
- GetOpenBSDProcessUserAndGroup, FindProcessesImpl: KERN_PROC
takes a 6-element MIB on OpenBSD, with the kinfo_proc element
size and element count as the last two entries.
[mlir] Detect hasLoop cycles with a single DFS
Calling isRegionReachable for every region the traversal popped made
hasLoop quadratic in the number of region successor edges. Use one
iterative depth-first search from the entry regions instead, in a new
canReachCycle helper. Reaching a region that is still on the DFS path
is a loop, reaching a finished one is not. Each region is queried at
most once, the search stops at the first loop, and the stack holds
one pointer-sized item per entry so small ops need no heap
allocation.
Both traversals now get a region's successors from
RegionBranchOpInterface::getSuccessorRegions(Region &) instead of
asking each terminator with null operand attributes. The in-tree
terminators that override getSuccessorRegions (scf.condition and
cir.condition) return the same regions as their parent op when no
operand is constant.
Restore the dropped debug output. Rename the multi-branch test and
[6 lines not shown]
[lldb] Don't take the module mutex to build a section list (#233524)
`ObjectFilePECOFF::CreateSections` takes the module mutex while
`Module::GetSectionList` holds `m_sections_mutex` (#205226), but
`Module::GetSymbolFile` holds the module mutex and asks for the section
list, so two targets loading the same DLL can deadlock.
`ObjectFile::GetSectionList` has the same inversion for every object
file format: it holds the object file's section mutex and waits for the
module mutex.
This patch makes both build through the object file's section mutex and
then `m_sections_mutex`, and drops the module mutex from
`CreateSections` in PECOFF and COFF.
The new unit tests hang without this patch. Part of #233425.
[LoopPeel] Only peel last iter if requested by shouldPeelLastIter. (#234130)
countToEliminateCompares also bumped DesiredPeelCountLast whenever it
increased the number of iterations to peel from the front. This value is
only used when peeling the front is rejected because the loop has
already been peeled, in which case we tried to peel more than a single
iteration from the end, or peel the end of a loop that does not support
it, triggering an assertion in peelLoop.
Only set DesiredPeelCountLast when shouldPeelLastIteration determined
that peeling the last iteration is possible and profitable.
Fixes https://github.com/llvm/llvm-project/issues/231037
[ARM] Add -verify-machineinstrs in test (#234127)
One of the testcase added in PR #225747
crashes with -verify-machineinstrs.
Removed the specific test to unblock the CI.
[CodeGen] Update the dominator tree in LiveIntervalTest's testSplitAt (#234113)
TestPassT claims to preserve all analyses, including the
MachineDominatorTree that LiveIntervals requires transitively, but
testSplitAt changed the CFG without updating it.
Found by the extra verification in #98314.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[mlir] Detect hasLoop cycles with a single DFS
Calling isRegionReachable for every region the traversal popped made
hasLoop quadratic in the number of region successor edges. Use one
iterative depth-first search from the entry regions instead, in a new
canReachCycle helper. Reaching a region that is still on the DFS path
is a loop, reaching a finished one is not. Each region is queried at
most once, the search stops at the first loop, and the stack holds
one pointer-sized item per entry so small ops need no heap
allocation.
Both traversals now get a region's successors from
RegionBranchOpInterface::getSuccessorRegions(Region &) instead of
asking each terminator with null operand attributes. The in-tree
terminators that override getSuccessorRegions (scf.condition and
cir.condition) return the same regions as their parent op when no
operand is constant.
Restore the dropped debug output. Rename the multi-branch test and
[6 lines not shown]
[mlir] Detect hasLoop cycles with a single DFS
Calling isRegionReachable for every region the traversal popped made
hasLoop quadratic in the number of region successor edges. Use one
iterative depth-first search from the entry regions instead, in a new
canReachCycle helper. Reaching a region that is still on the DFS path
is a loop, reaching a finished one is not. Each region is queried at
most once, the search stops at the first loop, and the stack holds
one pointer-sized item per entry so small ops need no heap
allocation.
Both traversals now get a region's successors from
RegionBranchOpInterface::getSuccessorRegions(Region &) instead of
asking each terminator with null operand attributes. The in-tree
terminators that override getSuccessorRegions (scf.condition and
cir.condition) return the same regions as their parent op when no
operand is constant.
Restore the dropped debug output. Rename the multi-branch test and
[6 lines not shown]
[mlir][SymbolTable] Handle unknown symbol users in SymbolUserMap (#227918)
This PR fixes #226052 treating unknown users record the symbol table
having this specific users instead use the assertion.
Please see my comment here explaining where the bug was introduced!
[here](https://github.com/llvm/llvm-project/issues/226052#issuecomment-5922633002).
[PowerPC] Use an unversioned FreeBSD triple in pr47373.ll (#233652)
pr47373.ll was added in 27714075848e with powerpc64-unknown-freebsd13.0,
but at the time llc defaulted to ELFv1 for all big-endian ppc64
triples, so the generated checks were ELFv1 even though FreeBSD 13
uses ELFv2. 4b09cb2b16eb made llc select ELFv2 for FreeBSD 13+ and
worked around the resulting failure by changing the triple to
freebsd12.0.
Use powerpc64-unknown-freebsd and regenerate the checks. The test
covers vector FDIV lowering without VSX, which is unaffected by the
ABI.
[lldb] Fix a lock-order deadlock in OptionValueFileSpecList::Clone (#233507)
`OptionValueFileSpecList::Clone` locks `m_rmutex` and then copies its
`OptionValue` base, which locks `m_mutex`, while
`OptionValue::GetFileSpecListValue` takes the same two locks in the
opposite order. When several debuggers create targets at once, this
deadlocks on the global `target.debug-file-search-paths` setting and
`TestMultipleDebuggers.py` times out (#233425).
This patch removes the `Clone` override. The copy constructor already
locks `m_rmutex` on its own. The new unit test hangs 10/10 without the
patch, and the test's driver went from 3 hangs in 1920 runs to 0 in 3840
on Windows.
[Flang] Avoid deep template recursion (#233865)
The names of all runtime functions is stored as variadic template
parameters of a `RuntimeTableEntry`, but the preprocessor macro that
creates the template instantiation (`FirMacroExpandKey`) expands to
exactly 50 characters. A recursive function `filter` then was used to
strip the unnecessary trailing `'\0'` characters out of the variadic
template. On the msvc compiler this 50x template recursion hits a
hard-coded limit
([C1202](https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/fatal-error-c1202)).
#218985 exposed this limted because this 50x template recursion started
to happen in a deeper context, maybe because the instantiation order
stopped making use of a previous memoization.
The updated code is non-recursive, using a constexpr loop instead of
template recursion.
This should fix
[flang-x86_64-windows](https://lab.llvm.org/buildbot/#/builders/166)
[2 lines not shown]
[mlir][tosa] Lower concat to tensor.concat (#231726)
Lower `tosa.concat` directly to `tensor.concat` instead of expanding it
into `tensor.empty` and `tensor.insert_slice` operations.
Update the TosaToTensor conversion tests to check the resulting concat
operations.
[lldb][test] Disable TestLldbGdbServer.py test_Hg_fails_on_minus_one_pid (#234129)
On Windows. It is flaky in GitHub CI and likely not specific to one
architecture. See #138085.
Relates to #232235.
[LoopPeel] Add tests for peeling last iter of already peeled loops. (#234128)
Add tests where peeling from the front is rejected because the loop has
already been peeled, with and without a compare that can be eliminated
by peeling the last iteration.
Aided by Opus 5.5
[AArch64][llvm] Fix incorrect diagnostic (index/immediate in simm9)
Improve the error message in the simm9 diagnostics and use the word
'immediate' instead of 'index'. This was noticed when creating the
CFLT instructions for Armv9.8-A, but would have caused a lot of
unrelated churn if merged as part of that change.
Co-authored-by: Martin Wehking <martin.wehking at arm.com>
[mlir][SPIR-V] Add Volatile function parameter round-trip tests (#232195)
The deserializer accepts Volatile function parameter decorations since
#230611 made it keep every unit decoration. Add round-trip tests for
function definitions and imported declarations, including Volatile
combined with Alignment and FuncParamAttr decorations, so the Volatile
path is covered explicitly.
[lldb][test] Make TestMultipleDebuggers check every debug session (#233526)
`multi-process-driver` exits 0 once every session finishes, even if they
failed, and on Windows they all failed at their first stop:
`SBFrame::GetFunctionName` returns `int foo(void)`, not `foo` or
`foo()`.
This patch checks which breakpoint the selected thread stopped at
instead of the name of thread 0's function, fails a session when
`SBTarget::Launch` fails, and exits 1 when a session fails.
It sets `plugin.process.gdb-remote.packet-timeout` to 600 like dotest,
since 13 of 1920 runs on a loaded host failed with "failed to get reply
to handshake packet within timeout of 6.0 seconds", and prints the
timeout message, which the loop never reached.
With https://github.com/llvm/llvm-project/pull/233524, 1920 runs of 32
parallel drivers pass on Windows with lldb-server.
Reland "[libc] Implement cpp::unique_ptr utility" (#233800)
This patch reapplies #206701 (reverted in #212644 due to failures on the
asan bots). The asan failures (allocation mismatches) are fixed by
changing the test to use new(AllocChecker) for allocating memory.
The original commit message was:
Implemented cpp::unique_ptr and cpp::default_delete in
libc/src/__support/CPP/unique_ptr.h for internal use within LLVM-libc.
* Added cpp::default_delete and its array specialization.
* Implemented cpp::unique_ptr with support for custom deleters and
array specialization.
* Applied LIBC_TRIVIAL_ABI to unique_ptr and LIBC_NO_UNIQUE_ADDRESS to
the
deleter to enable empty member optimization and register-passing ABI.
* Defined portable LIBC_NO_UNIQUE_ADDRESS and LIBC_TRIVIAL_ABI macros in
attributes.h.
[20 lines not shown]
[AMDGPU][SwLowerLDS] Lower non-kernels with LDS instructions and assign kernel IDs to their callers (#228043)
**Issue:**
- #227985 rebases flat to LDS casts onto the malloc buffer, but only in
functions the pass lowers. A non-kernel was lowered only if it used an
LDS global or was a direct callee of an LDS-using kernel taking an
`addrspace(3)` argument.
**This patch:**
- Lowers every non-kernel with LDS memory instructions or `flat <-> LDS`
casts. The predicate is shared with `getLDSMemoryInstructions`.
- Finds the kernels that reach them with a transitive call graph walk.
Indirect calls may reach any address taken non-kernel, matching
`AMDGPUMemoryUtils::getTransitiveUsesOfLDS`.
- Assigns a kernel ID to each such kernel, even one without LDS. Its
base table entry is `null` and its offset table row is `poison`. It can
only reach the LDS path with a pointer that is not LDS, which is
invalid.
[5 lines not shown]
[AArch64] Fix SDAG lowering of small ints on the stack (#230142)
This commit fixes a bug in AArch64's SelectionDAG lowering of arguments
and call operands.
Specifically, in the Darwin calling convention, integers smaller than
i32 which were members of aggregates would be incorrectly lowered to
4-byte stack slots. This contrasted with the GlobalISel lowering of this
calling convention, which correctly assigned them to 1- or 2-byte slots.
For aggregate types, we were checking against the original type which,
since it isn't a simple type, was falling back to the i32 rule. The fix
is to instead consider each individual component of an aggregate.
In and of itself, this issue could go unnoticed as it was internally
consistent. We spotted it when a function lowered by GISel called a
function which itself fell back to SDAG lowering, resulting in an ABI
mismatch.
See #218676 which looks related.
[mlir] Detect hasLoop cycles with a single DFS
Calling isRegionReachable for every region the traversal popped made
hasLoop quadratic in the number of region successor edges. Use one
depth-first search from the entry regions instead. Reaching a region
that is still on the DFS stack is a loop, reaching a finished one is
not. Each region is queried at most once and the search stops at the
first loop.
Both traversals now get a region's successors from
RegionBranchOpInterface::getSuccessorRegions(Region &) instead of
asking each terminator with null operand attributes. The in-tree
terminators that override getSuccessorRegions (scf.condition and
cir.condition) return the same regions as their parent op when no
operand is constant.
Restore the dropped debug output. Rename the multi-branch test and
drive its mock op from attributes. Add tests for a diamond, a loop
through the entry region, a loop in an unreachable region and
[3 lines not shown]