[Darwin][TSan] Only track lock state for locks taken by instrumented code (#234732)
Some libraries take and release os_unfair_locks in a manner that is
opaque to TSan; this can result in the deadlock detector failing to free
slots (that it believes are currently held locks) and running out of
space in `all_locks_with_contexts_`, failing a CHECK condition, and
dying. Additionally it can lead to false positive reports of 'unlock of
an unlocked mutex'.
This patch conservatively prevents locking operations in noninstrumented
code from being tracked by the deadlock detector by default. It also
ignores any unlock of an os_unfair_lock without a corresponding lock
(this will assert anyway).
rdar://190667681
[SPIR-V] Lower llvm.debugtrap to NonSemantic.DebugBreak (#231354)
[SPIRV] Lower llvm.debugtrap to NonSemantic.DebugBreak
Lowers the generic `llvm.debugtrap` intrinsic to the extended
instruction `OpExtInst %void <set> DebugBreak` in the
SPIR-V backend per HLSL proposal 0039. Instead of adding
a target-specific intrinsic, this reuses the existing
`llvm.debugtrap` pipeline (`G_DEBUGTRAP` -> `selectDebugTrap`),
requiring no clang changes.
- Emits `OpExtension "SPV_KHR_non_semantic_info"` when targeting SPIR-V
< 1.6
- Falls back to `OpNop` when the extended set is unavailable, ensuring
lowering
never fails.
- Adds necessary TableGen definitions, opcode enums, and string
mappings.
[3 lines not shown]
[lldb] Remove ConstString from ObjCLanguage formatters (#239834)
These are easily replaced with llvm::StringMap and llvm::StringRef.
There are a handful of remaining uses but they are to fulfill API
requirements.
[HLSL] Add QuadAll builtin (#236932)
This PR adds the QuadAll builtin to clang, with both DXIL and SPIRV
lowering.
Fixes https://github.com/llvm/llvm-project/issues/99215
Assisted by: Github Copilot
---------
Co-authored-by: Copilot <223556219+Copilot at users.noreply.github.com>
Copilot-Session: 365638e8-2291-4925-8f1e-1b5c23220818
[ConstraintElim] Split signed min/max across their operands when checking a compare
The existing constraint systems only record the bounds that hold for both
operands of a min/max (smax(a, b) >= a and >= b, smin(a, b) <= a and <= b). The
other direction is a disjunction, which cannot be recorded as a fact. When a
compare of signed decompositions involves a min/max result, split it into its
operands: the decomposition is monotonic in that result, so it is the max or min
of its values on each side, and the relation holds for all or for either side
respectively.
https://alive2.llvm.org/ce/z/zsGkJ-
[ConstraintElim] Prove sadd/ssub.with.overflow cannot overflow from the exact sum
Decompose the operands and show that the sum lies in the range of the type. This
handles patterns like A + (B - A), as well as sums involving signed min/max
results, which are split across their respective operands using monotonicity
(for example start + smax(end - start - 1, 0) <= end).
https://alive2.llvm.org/ce/z/ze8LCk
[ConstraintElim] A signed sum of operands with opposite signs cannot wrap
If one operand is known non-negative and the other non-positive, the signed
sum is between them, so it cannot overflow.
https://alive2.llvm.org/ce/z/ZF5Yqr
[mlir][IndexToLLVM] Link MLIRAnalysisBase instead of the MLIRAnalysis umbrella (#240466)
#238966 added the \`MLIRAnalysis\` umbrella to \`MLIRIndexToLLVM\`'s
link libraries, but the conversion only needs \`DataLayoutAnalysis\`,
which lives in \`MLIRAnalysisBase\`. Same issue as #238915: the umbrella
archive (#232793) reuses the component object libraries, so depending on
it puts both \`libMLIRAnalysis.a\` and e.g. \`libMLIRAnalysisBase.a\` on
the link line of anything that links all of MLIR's libraries. Linkers
that extract every archive member (e.g. \`--whole-archive\`) then fail
with duplicate symbols.
Assisted by: Claude
[ValueTracking] call nnan/ninf noundef cannot return poison (#239912)
While working on #239458, I noticed that ValueTracking had inconsistent
semantics for call instructions with both nnan/ninf and noundef.
canCreateUndefOrPoison would return true, but
isGuaranteedNotToBeUndefOrPoison would also return true.
This effectively decides on one of the two semantics, saying that `call
{nnan,ninf} noundef` cannot return poison (effectively nnan/ninf getting
evaluted before noundef). This keeps `nnan noundef` consistent with
`nofpclass(nan) noundef` and makes `noundef` actually useful with FMF.
[GVNHoist] Replace getDefiningAccess with getClobberingMemoryAccess (#240217)
getDefiningAccess in safeToHoistLdSt returns the nearest stores if we
don't query AA result by using getClobberingMemoryAccess. This reduce
the opportunity for optimization as isLiveOnEntryDef returns false
without updating in safeToHoistLdSt.
In the example (See Closes item): after hoisting left.a and left.b,
getDefiningAccess returns `store q` before.
As a result, we replace getDefiningAccess with getClobberingMemoryAccess
and then we can safely remove ensureOptimizedUses now.
Assisted-by: Claude # Test
Closes: #221578
[Hlsl][Spirv] Don't emit global variables for structs containing just resources (#234797)
For global, non-static instances of a struct containing resources, we
end up splitting these recursively into separate global variables for
each resource, and for numeric members these go into the default
$globals cbuffer.
For this change, when there's a instance of a struct (or array of)
containing only resources, skip emitting a global variable for the
struct. Before, it would emit external linkage globals of these which
would not get removed.
based on
https://github.com/llvm/wg-hlsl/blob/main/proposals/0038-resources-in-structs.md
improves #194435
assisted by: codex
[bazel][llvm] Add SelectionDAGOptionsTableGen to CodeGen deps (#240498)
Fixes build failure introduced by commit 3e3ca055b0bb ("[SelectionDAG]
Declare command line options in TableGen (Part 1) (#240033)"), which
generated SelectionDAGOptions.inc from SelectionDAGOptions.td.
Add gentbl_cc_library target SelectionDAGOptionsTableGen and add it to
CodeGen deps.
LLM-aided
[lldb][test] Lazily generate ValueCheck error messages (#240484)
We spend a large amount of time in the test suite preparing the error
messages for failed asserts. All of this time is spent on formatting
SBValue objects that we are checking, so we can print their textual
representation in the assert error.
This patch uses the typical Python lazy string class trick to make this
evaluation lazy. This speeds up several tests by a small amount, and
some tests like `TestDataFormatterGenericDeque.py` get their runtime cut
from 30s to 7s.
[lldb] Remove unused MIPS register descriptions (#239081)
Remove the unused MIPS and MIPS64 register-info tables and Linux
register-buffer structures. Keep the numbering definitions used by the
instruction emulators.
[libc][cmake] Collapse extra blank lines in cmake_format (#240295)
Updated cmake_format.py to collapse consecutive blank lines to a single
blank line and strip leading blank lines at the start of files. Applied
the updated formatter across libc CMake files.
Assisted-by: Automated tooling, human reviewed.
[ConstraintElim] Split signed min/max across their operands when checking a compare
The existing constraint systems only record the bounds that hold for both
operands of a min/max (smax(a, b) >= a and >= b, smin(a, b) <= a and <= b). The
other direction is a disjunction, which cannot be recorded as a fact. When a
compare of signed decompositions involves a min/max result, split it into its
operands: the decomposition is monotonic in that result, so it is the max or min
of its values on each side, and the relation holds for all or for either side
respectively.
https://alive2.llvm.org/ce/z/zsGkJ-
[ConstraintElim] Prove sadd/ssub.with.overflow cannot overflow from the exact sum
Decompose the operands and show that the sum lies in the range of the type. This
handles patterns like A + (B - A), as well as sums involving signed min/max
results, which are split across their respective operands using monotonicity
(for example start + smax(end - start - 1, 0) <= end).
https://alive2.llvm.org/ce/z/ze8LCk
[ConstraintElim] A signed sum of operands with opposite signs cannot wrap
If one operand is known non-negative and the other non-positive, the signed
sum is between them, so it cannot overflow.
https://alive2.llvm.org/ce/z/ZF5Yqr
Reapply `WaveMultiPrefixCountBits` with test fix (#239503)
Reapply #238132 after revert #239439. Add `WaveMultiPrefixCountBits`
with DirectX lowering. SPIR-V calls report that the builtin is not
supported on that target.
Keep the Clang IR checks in
`clang/test/CodeGenHLSL/builtins/WaveMultiPrefixCountBits.hlsl`. Put the
DXIL checks in `llvm/test/CodeGen/DirectX/WaveMultiPrefixCountBits.ll`,
where the existing directory configuration skips them when DirectX is
not built. Cover dynamic, true, and false inputs.
The first commit restores the original change. The second commit adds
the test fix. This avoids the unconditional DirectX-only command that
was present in the Clang test.
Fixes #99211.
Assisted by: GitHub Copilot
[4 lines not shown]
[lldb][test] Remove dead Continue calls from TestTargetAPI.py (#239030)
This test launches a program that has no breakpoint, which causes the
launch to stall until the process exists. Then, we call Continue several
times with a dead process. The Continue with a exited process does
nothing right now aside from stalling for 5 seconds.
This removes the dead Continue calls that were just copy-pasted from the
other tests. This removes the 20s of waiting, and cuts the test time
from 27s to 7s.
[lldb][test] Split up LibcxxStringSimulator test [NFC] (#239017)
TestDataFormatterLibcxxStringSimulator.py is by far the slowest test in
LLDB and runs for about 90s on the bot, which more than twice as long as
the second slowest test (TestTargetAPI with 38s). There isn't anything
wrong with the test itself, and I don't see anything we can easily
optimize.
Instead, this patch splits up TestDataFormatterLibcxxStringSimulator.py
into several tests that each test just one libcxx revision. This way we
can run the different subtests in parallel, which is beneficial on
machines with many cores.
Keep the condition key when a match_any WHEN clause omits its directive
The unguarded candidate of a match_any WHEN clause keeps its condition
key when the clause has a directive, but not when it omits one. A
selector with a key is then never a strict subset of one without, so
with
```
!$omp metadirective &
!$omp& when(user={condition(a)}, &
!$omp& implementation={vendor(score(4): llvm), extension(match_any)}: &
!$omp& taskwait) &
!$omp& when(user={condition(a)}, device={kind(host)}, &
!$omp& implementation={vendor(score(3): llvm), extension(match_any)}:)
```
TASKWAIT was also selected when `a` is false. Give both unguarded
candidates the key, so the first is again a strict subset of the second
and nothing is selected when `a` is false.
[9 lines not shown]
[OpenMP] Fix non-contiguous and empty target updates
Only merge consecutive innermost contiguous dimensions so a gap in an
inner dimension cannot be hidden by contiguous outer dimensions. Skip
empty updates before presence checks and data transfers, and use 64-bit
counts while visiting an already contiguous final dimension only once.
Exercise C/C++ array sections through target update pragmas, including
both transfer directions, multidimensional gaps, and empty present
updates. Retain direct ABI coverage for zero physical strides and
synthetic oversized descriptors that cannot be expressed in valid C/C++.
Co-authored-by: Codex <codex at openai.com>