[Flang][OpenMP] PoC module support for allocate directives
This patch implements partial support for `allocate` on Fortran
module variables, based on adding global constructor functions for each
impacted variable.
Shared as a proof of concept, because I have a few concerns about it:
1. It appears that Clang ignores `allocate` directives on global
variables instead. Is that the expected behavior?
2. The existing implementation for `allocate` in Flang doesn't
actually impact where the memory used for a variable resides. It
allocates/deallocates extra memory for it using OpenMP internal
compiler calls but then that storage is never used. The original
alloca is still used. This addition suffers from the same issue:
global constructors allocate extra memory that is never used to
update in any way the associated global variable or its users.
3. No `omp.allocate_free` (should be `omp.allocate.free`) can be added
by this approach.
4. The representation of `omp.allocate_dir` (should be `omp.allocate`)
[10 lines not shown]
[VPlan] Remove the unused CalculateTripCountMinusVF opcode (NFC) (#216675)
bcc272b3220f ("[LV] Remove DataAndControlFlowWithoutRuntimeCheck. NFC",
#183762) removed the only createNaryOp building this opcode, leaving
behind the enum entry and its cases for type inference, operand count,
scalar generation, lowering and printing. Nothing constructs it, so no
plan can contain it and no test prints it.
PowerPC: Fix MI peephole crash on an undef forwarding operand
Found by AI while working on something else.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
Support [[clang::lifetime_capture_by(X)]] in Plain Containers (#204361)
This PR implements support for `[[clang::lifetime_capture_by(X)]]` to
enable tracking lifetimes for plain structs and containers like
`std::vector` without requiring manual `[[gsl::Pointer]]` or
`[[gsl::Owner]]` annotations. The implementation extends the
`LifetimeAnnotatedOriginTypeCollector` to register types in capture_by
contracts for origin tracking.
This PR also enables the intra-procedural analysis in existing tests
using -Wlifetime-safety and updated expectations to handle the more
detailed flow-sensitive diagnostics.
```cpp
struct MyContainer {
const char* stored_ptr;
};
void captureInto(std::string_view v [[clang::lifetime_capture_by(c)]], MyContainer& c);
[22 lines not shown]
GlobalISel: Use MIPatternMatch in GIMatchTableExecutor (#216601)
Replace the getVRegDef + opcode-check idiom in isBaseWithConstantOffset
with mi_match using m_GPtrAdd and m_GConstant.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
RuntimeLibcalls: Provide fp128 long double libcalls on X86 (#216622)
16a8d8d038a3 removed the l-suffixed long double math functions
from the default set and re-added them per-target gated on
isLongDoubleF128, but X86 was not given the re-add. On targets
whose long double is fp128 (e.g. x86_64 Android/OHOS) this dropped
the fp128 l-suffixed libcalls.
Fixes the regression reported on #214944.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[AMDGPU] Fix isKnownNeverNaN for FMIN_LEGACY/FMAX_LEGACY (#216338)
These compare-selects return one of the operands bit-for-bit, so a
signaling NaN operand passes through unquieted
Recurse into both operands instead of assuming never-sNaN
[AArch64][BOLT] Fold local-exec TLS relocations into loads and stores (#215531)
Emit the low part of the 12- and 24-bit local-exec sequences as an
ADDlow so that it folds into the addressing mode of a following load or
store, saving one instruction.
This re-lands the local-exec part of r327316 (7bc64bd889ad), whose ELF
changes r327503 (bde677289acc) reverted because neither LLD nor GNU
binutils implemented the relevant
R_AARCH64_TLSLE_LDST*_TPREL_LO12 relocations at the time.
LLD and GNU bfd now handle the non-checking 8- to 64-bit variants used
by the default 24-bit sequence. GNU bfd also handles the checked
variants used by the 12-bit sequence; LLD does not support those, but it
did not support the predecessor checked ADD relocation either. GNU bfd
still has no LDST128 support, so 128-bit accesses stay unfolded.
Teach BOLT to classify the folded TLS load/store relocations so it can
process binaries linked with --emit-relocs.
[ARM] Emit an error when the hard-float ABI is enabled but can't be used (#111334)
Prior to this, compiling for an eabihf target with a CPU lacking
floating-point registers would silently use the soft-float ABI instead,
even though the Arm attributes section would still have
"Tag_ABI_VFP_args: VFP registers", which leads to silent ABI mismatches
at link time.
Update various tests that were using inconsistent ABI/PCS and features.
Change ARMTargetLowering::getEffectiveCallingConv from private to public
and modify it to pass through unrecognized calling conventions. Now that
ARMBaseTargetMachine::createMachineFunctionInfo calls it, leaving a
fatal error would change the behavior of IR passes that do not need to
lower calling conventions. Unrecognized calling conventions are still
treated as errors in lowering.
Fixes #110383.
[libc] Fix {asc,c,gm,mk}time(_r)? tests and spurios snprintf call (#216423)
time_test_utils was depending on a non-existent library, which caused
these tests to be auto-skipped. Fixing that exposed the fact that some
of the tests don't build (in hermetic mode) due to a snprintf
dependency concealed behind a __builtin_snprintf in asctime.
This patch addresses the existing TODO by moving
asctime to asctime_utils.h (avoiding a dependency loop)
and implementing it via strftime_main.
Assisted by Gemini.
clang/AMDGPU: Don't emit target-features on AMDGCN-flavored SPIR-V
The spirv64-amd-amdhsa target unions every GPU's features in its feature
map so it can report builtins as available. The CodeGen doesn't have
any use of the target-features. Putting it into the IR just results
in an annoying to update test every time a new feature is added. The
ultimate SPIRV codegen doesn't do anything with it, and if it did
survive to AMDGPU codegen, it would be actively harmful.
This isn't an ideal solution. The target-features spam is also
noisy and useless in the AMDGPU case, but solving that is more
intricate because we do currently rely on this for some features,
most notably the wavesize.
Co-authored-by: Claude (Claude-Opus-4.8)
clang/AMDGPU: Use feature bitset instead of ArchAttr
Convert from the legacy getArchAttrAMDGCN manual bitmask checks to using
the new generated bitset. These are the easy cases. sramecc and xnack
require more supporting work so will be done later.
Co-authored-by: Claude (Claude-Opus-4.8)
[clang][CIR][AArch64] Add lowering for conversion intrinsics (#211609)
This PR adds lowering for intrinsic from the following groups:
* https://arm-software.github.io/acle/neon_intrinsics/advsimd.html#conversions
It continues the work started in #190961, #193273, #199990 and #209252.
This PR implements the remaining conversions truncating to zero:
* vcvts_s32_f32
* vcvts_s64_f32
* vcvts_u32_f32
* vcvts_u64_f32
The corresponding tests are moved from:
* clang/test/CodeGen/AArch64/
to:
* clang/test/CodeGen/AArch64/neon/
The lowering follows the existing implementation in
CodeGen/TargetBuiltins/ARM.cpp
GlobalISel: Match loads by pointer operand in CombinerHelper
Add a load matcher that binds the pointer operand (like IR's m_Load), with
optional outputs for the load instruction and its MachineMemOperand via m_MMO.
Use it to replace the getVRegDef + dyn_cast idiom in the load combines.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
GlobalISel: Migrate misc. CombinerHelper def checks to MIPatternMatch
Replace getVRegDef + cast/opcode-check idioms across CombinerHelper
with mi_match, adding named instruction binders and operand-form matchers
as needed.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[mlir][affine] Require a vector size in affine-super-vectorize (#171110)
Diagnose invocations that omit the `virtual-vector-size` option. A
vector rank is required to construct a vectorization pattern, so
accepting an empty size list would silently leave the input unchanged.
Check that vector sizes are present and positive before applying
rank-dependent constraints.
Fixes #114528
GlobalISel: Use MIPatternMatch in GIMatchTableExecutor
Replace the getVRegDef + opcode-check idiom in isBaseWithConstantOffset with
mi_match using m_GPtrAdd and m_GConstant.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[lldb] Fix GetIndexOfChildWithName and GetChildMemberWithName on register sets (#212727)
And GetChildMemberWithName which had the same issue.
Fixes #211787.
Both of these methods were doing a lookup on the register info array as
a whole, rather than the subset of indexes into that array. That subset
of indexes is the "register set".
This lead to problems like this where index and name getters disagreed:
```
>>> lldb.frame.GetRegisters()[1].GetChildAtIndex(0)
(unsigned char __attribute__((ext_vector_type(16)))) v0 = (0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f,
0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f)
>>> lldb.frame.GetRegisters()[1].GetIndexOfChildWithName("v0")
63
```
GetChildAtIndex told us that v0 was at index 0, but looking up v0 by
[18 lines not shown]
GlobalISel: Introduce m_GPtrAdd flags matcher in CombinerHelper (#216600)
Add an optional MIFlags output operand to the binary-op matcher and a
m_GPtrAdd(L, R, m_MIFlags(F)) overload, and use it to replace getVRegDef
+ opcode checks.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[lldb-dap] Preserve watchpoints from console (#215228)
We should not delete watchpoints created via LLDB console when
processing DAP `setDataBreakpoints` request.
[Flang][OpenMP] PoC module support for allocate directives
This patch implements partial support for `allocate` on Fortran
module variables, based on adding global constructor functions for each
impacted variable.
Shared as a proof of concept, because I have a few concerns about it:
1. It appears that Clang ignores `allocate` directives on global
variables instead. Is that the expected behavior?
2. The existing implementation for `allocate` in Flang doesn't
actually impact where the memory used for a variable resides. It
allocates/deallocates extra memory for it using OpenMP internal
compiler calls but then that storage is never used. The original
alloca is still used. This addition suffers from the same issue:
global constructors allocate extra memory that is never used to
update in any way the associated global variable or its users.
3. No `omp.allocate_free` (should be `omp.allocate.free`) can be added
by this approach.
4. The representation of `omp.allocate_dir` (should be `omp.allocate`)
[10 lines not shown]
[Flang][OpenMP] Prevent allocate directive ICE on module variables (#216021)
The current lowering implementation for `allocate` directives assumes
the MLIR function in which it is creating operations will still be there
by finalization time, so that it can add a deallocation call.
When lowering Fortran modules, this is not the case (lowering happens in
a temporary dummy function) and it results in a compiler crash while
running cleanup callbacks. This patch adds a TODO for this case.
[mlir] Filter out failing tests when expensive checks are ON (#216323)
Adds logic to conditionally disable tests that fail when expensive
checks are enabled,
* -DMLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON.
When the expensive API checks are disabled, the newly marked tests
are run as usual.
This is a temporary measure to enable the introduction of a buildbot
that will run with expensive API checks enabled. No new tests disabled with
expensive checks should be added, i.e. tests with
* `XFAIL: mlir-expensive-checks`.
The existing failures marked in this PR should be fixed.
GitHub issue that reported these failures prior to this PR:
* https://github.com/llvm/llvm-project/issues/163599
[libc] Fix FreeBSD build for 53-bit-rounded fp80s (#216332)
Fix build issues on FreeBSD, which reports `LDBL_MANT_DIG == 53` for
`long double` on some targets despite using fp80 as the underlying type.
This is because it stores the value as an fp80, but configures the FPU
to round the mantissa to 53-bits. However, this causes some parts of
libc to misidentify the fp80 as an fp64 since both use a 53-bit
mantissa. This led to build issues on FreeBSD when trying to bitcast the
12-byte `FPBits<long double>` to an 8-byte fp64 value.
This is fixed by checking both the mantissa size and the exponent range
when determining the correct format for `long double`. Also, move the
check for this to a single place in `types.h`, rather than re-checking
the `LDBL_MANT_DIG` and `LDBL_MAX_EXP` values in `FPBits.h`.
[APFloat] Report the sign and the zero a conversion cannot represent (#216056)
`APFloat::convert` reports through `losesInfo` what rounding lost, but
not what
the target format has no encoding for at all. Two properties of a format
are not
rounding:
| property | formats today | what happens |
|---|---|---|
| `hasSignedRepr == false` | `f8E8M0FNU`, `f8E5M3FNU` | the sign bit is
carried into a format with no room for it |
| `hasZero == false` | `f8E8M0FNU` | zero is replaced by the smallest
normalized value, 2^-127 |
Both were reported as `opOK` with `losesInfo == false`. Callers gate on
`losesInfo` -- that is how `arith.truncf`'s folder decides whether a
constant
fold is legal -- so they kept a value the format cannot hold.
[84 lines not shown]
[MLIR][NVVM] Spell strict assembly properties directly
Bind every NVVM inherent property in its operation assembly format and
re-enable strict property parsing for the dialect. Use direct named clauses
for declarative formats and custom MMA parsers while retaining dictionaries
for discardable attributes.
Assisted-by: Codex