ValueTracking: Generalize known frexp exponent range to any constant
Extend computeKnownExponentRangeFromContext beyond the special case of a
dominating fabs(V) compare against exactly 1.0 to any finite limit.
Generalizing below 1.0 exposes a soundness issue: frexp(0) has exponent
0, so a bound derived assuming a nonzero value could wrongly exclude it
when the limit implies a negative maximum exponent. Query fcZero and clamp
the maximum exponent to at least 0 when the source may be zero.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[arm64e] Add a builtin + intrinsic for arm64e PAuth_LR: __builtin_ptr_auth_auth_with_pc_and_resign (#202742)
The new builtin behaves like __builtin_ptrauth_auth_and_resign, but
incorporates the address of the signing instruction (i.e. the
`pacibsppc`/`paciasppc`) when performing the auth side, and subsequently
re-signs using a different scheme. Authenticating the re-signed value
will fail if and only if authenticating the original value with the
incorporated pc would have failed.
[clang] implement CWG2064: ignore value dependence for decltype
The 'decltype' for a value-dependent (but non-type-dependent) should be known,
so this patch makes them non-opaque instead.
This patch also implements what's neceessary to allow overloading
on pure differences in instantiation dependence, making `std::void_t`
usable for SFINAE purposes.
This also readds a few test cases from da98651, which was a previous attempt
at resolving CWG2064.
Fixes #8740
Fixes #61818
Fixes #190388
[docs] Rewrite LangRef.md as Markdown (#201975)
Tracking issue: #201242
Migration guide docs:
https://llvm.org/docs/SphinxQuickstartTemplate.html#markdown-migration-guidelines
RFC:
https://discourse.llvm.org/t/rfc-make-myst-markdown-the-llvm-docs-format-rip-rest/90840
This change migrates LangRef by itself, since it is quite a large
document with many idiosyncracies.
LangRef makes extensive use of definition lists, which apparently
require enabling the deflist MyST extension in Sphinx conf.py. In part
because definition list boundaries are controlled by indentation,
several of them required manual fixups to get the nesting right. Some of
the issues were pre-existing broken indentation, but this should now be
much better.
I have a verification script that tracks all anchors and ensures that
all previous anchors are carried over to the new document, so no
mid-document links are broken.
[clang] Reland: fix getTemplateInstantiationArgs (#208285)
Relands https://github.com/llvm/llvm-project/pull/199528
Previous: https://github.com/llvm/llvm-project/pull/207825
This implements a new strategy for collecting the template arguments, by
relying on the qualifiers and template parameter lists to navigate the
template
context of out-of-line definitions.
This greatly simplifies the signature of that function, by removing a
bunch
of workarounds, and simpliffying a couple that weren't removed yet.
Since this now relies on qualifiers and template parameter lists,
this patch expends most of its effort making sure these are placed,
transformed and propagated to template instantiations.
Also makes the explicit specialization AST nodes stop abusing the
[14 lines not shown]
[ADT][NFC] UniqueFunction MSVC fix (#208293)
Fixup of #208251 for MSVC, which erroneously treats uses of non-static
constexpr variables as odr-use and requires them to be captured.
[SimplifyCFG] Improve reduceSwitchRange to avoid unnecessary subtractions (#198374)
Dense switch cases can sometimes be achieved with only a shift, avoiding
a subtract. Change reduceSwitchRange to check for such cases before
falling back to using a subtract.
The changes to test9 demonstrates that for the purpose of lookup-table
lowering (triggered by the switch-to-lookup flag), the switch range
still ends up normalized to start at 0, the subtraction just happens
after the fshl.
test10 demonstrates where this change is useful, resulting in a dense
switch case with one less subtract.
test11 demonstrates cases where the subtract is still needed in order to
form a dense switch case.
[BOLT] Fix DW_FORM_implicit_const values lost during DWARF5 rewriting (#192166)
Summary:
Fix two bugs in DIEBuilder that caused DW_FORM_implicit_const values to
be zeroed out when rewriting DWARF5 debug sections
(--update-debug-sections).
1. In constructDIEFast(), DWARFFormValue was constructed with just the
form code, leaving the value at 0. For DW_FORM_implicit_const,
extractValue() is a no-op since the value is expected to be pre-set.
Fix: use AttrSpec.getFormValue() which initializes the value from the
abbreviation table.
2. In assignAbbrev(), AddAttribute(Attr.getAttribute(), Attr.getForm())
used the two-argument overload which discards the implicit_const value.
Fix: use AddAttribute(Attr) to copy the full DIEAbbrevData.
Fixes https://github.com/llvm/llvm-project/issues/192084
[AArch64][PAC] Reset `killed` operand flag in custom inserter of PAC pseudo (#158699)
If custom inserter changes the `AddrDisc` operand of `AArch64::PAC`
pseudo instruction, conservatively reset its `killed` flag. Keeping this
flag without checking if it is still legal may result in code of the
form
%disc = MOVKXi %addr(tied-def 0), 1234, 48
%signed = PAC %ptr(tied-def 0), 2, 0, killed %disc
# %addr is used past this point and %disc is not
being turned into
%signed = PAC %ptr(tied-def 0), 2, 1234, killed %addr
# %addr is used past this point, but the operand of
# the above instruction has killed flag
[MachineCopyPropagation] Fix debug info referring to subregisters. (#207861)
When copy propagation removes a copy, it fixes debug info that refers to
the old register to instead refer to the new register. This logic didn't
really deal with subregisters; it took any DBG_VALUE that pointed to a
subregister of the old register, and replaced it with the full new
register.
This patch adds logic for subregisters: if a DBG_VALUE refers to a
subregister of the source register, find the corresponding subregister
of the destination register.
Fixes #207682
[ids-check] Add support for ignoring symbols (#208241)
`llvmGetPassPluginInfo()` is not exported from the LLVM dylib. It is
meant to be the entry point for a pass plugin in another dylib. As it
is, the ids-check workflow would automatically add the `LLVM_ABI`
annotation to it, which is incorrect.
This fixes the issue by explicitly marking the symbol as ignored.
The effort to build LLVM as a DLL is tracked in #109483.
[X86] combineArithReduction - truncate from v4iXX to v4i16 for PSADBW add reduction patterns (#208286)
Noticed while trying to make ISD::VECREDUCE_ADD legal - if we're using
PSADBW, we don't need to truncate down to v4i8 and then zero-padd the
lowest v8i8/64-bits, we can just use v4i16 and bitcast to v8i8 since we
know the upper 8-bits are zero.
ValueTracking: Fix off by one in known frexp exponent range
Also restrict the optimization to the exactly 1 case for now.
There was an additional bug for values less than 1 to be fixed
separately.
Fixes #208192
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[docs] Rename LangRef.{rst|md}
Tracking issue: #201242
This commit does not use valid markdown, so the docs will not build, but they will be fixed in an immediate follow-up commit that does the migration.
[RISCV] Use DCI.CombineTo instead of DAG.ReplaceAllUsesWith in performReverseEVLCombine. (#208275)
This makes sure the replaced node is deleted without relying on it still
being in the worklist, schedules its users for revisiting, and prints
the debug message for the replacement.
[SSAF][Extractor] Extract operator new/delete overload entities that shall retain their types (#206600)
This commit creates an extractor for operator new/delete overloads.
Overloads of operator new shall retain their void* return type,
regardless of whether they are propagated by unsafe buffers. The same
applies to the parameters of operator delete overloads.
Therefore, clang-reforge eventually need this information.
rdar://179151541
---------
Co-authored-by: Balázs Benics <benicsbalazs at gmail.com>