[libc][__support] Ensure index_to_min_size monotonicity on MSVC Windows in TLSFFreeStoreImpl
On Windows MSVC where alignof(max_align_t) == 8, UNIT_SIZE is 8 while MIN_INNER_SIZE is 24 (3 * UNIT_SIZE).
In index_to_min_size, computing MIN_INNER_SIZE + (index - 1) * UNIT_SIZE + 1 for linear bins caused
index 31 (EXP_BASE - 1) to reach 265 bytes, exceeding the start of the exponential table at index EXP_BASE (32 * 8 = 256 bytes).
This caused IndexToMinSize unit test to fail EXPECT_GT(min_size, prev_size) at index 32.
This change caps min_size for linear bins at (EXP_BASE << UNIT_SIZE_LOG2) - (EXP_BASE - index),
ensuring index_to_min_size is strictly increasing across all indices on all targets.
TAG=agy
CONV=cff84e8c-ee22-4f39-af3c-344d1e6f417b
[SSAF] Serialize virtual method summaries and families
Per-TU summaries and whole-program results cross process boundaries, and the
JSON layer refuses to write a summary kind it has no format for. Register both
sides so --ssaf-extract-summaries=VirtualMethod becomes usable and the family
result survives a round trip.
Deserialization tolerates a missing override list, since a root virtual method
legitimately has none.
§3 of rdar://179151603
[SSAF] Extract the virtual method override relation per TU
A virtual call may dispatch to any override of its callee, so a whole-program
analysis cannot reason about a method's parameters and return value in
isolation. It needs to know which method overrides which, and which slots
that relates. Collect this per TU, so a later pass can join the related
slots into families.
JSON serialization lands separately, so the summary is not writable via
--ssaf-extract-summaries yet.
§1 of rdar://179151603
[SSAF] Close unsafe-buffer reachability over override families
An unsafe pointer reaching one override's parameter is equally unsafe in every
sibling and base override of that method, because the call site picks the
target dynamically. Without closing over the families, reachability depended
on which override the extractor happened to see the flow through, so a fix
suggested for the base could be contradicted by a derived override.
Mirroring is level-preserving: families relate slot entities, so a reachable
EPL propagates only to the same pointer level on its family members.
The closure runs after the pointer-flow DFS has converged and does not feed
its own output back in, so a flow edge out of a newly discovered EPL is still
missed. FamilyClosureDoesNotRerunDFS pins that gap.
§4 of rdar://179151603
[SSAF] Group virtual method slots into override families
A virtual call site can dispatch to any override, so the parameter and return
slots that occupy the same vtable slot across an override chain are
indistinguishable to a caller. Whole-program consumers therefore have to treat
them as one unit or they will reason about a slot that a call never actually
reaches.
Compute those units up front, keyed per slot, so consumers only need a map
lookup rather than their own traversal of the override relation. Overloads
occupy distinct vtable slots and stay in distinct families.
The family representative is the smallest EntityId in the class, which keeps
the result stable across runs.
§2 of rdar://179151603
[libc++] Remove unused headers from <cmath> (#213114)
I believe these headers were relevant when we actually implemented
functions in `<cmath>`, but they are not anymore. Note that ::hypot in
particular is obtained from <math.h> like all the other math functions.
Co-authored-by: A. Jiang <de34 at live.cn>
[SSAF] Close unsafe-buffer reachability over override families
An unsafe pointer reaching one override's parameter is equally unsafe in every
sibling and base override of that method, because the call site picks the
target dynamically. Without closing over the families, reachability depended
on which override the extractor happened to see the flow through, so a fix
suggested for the base could be contradicted by a derived override.
Mirroring is level-preserving: families relate slot entities, so a reachable
EPL propagates only to the same pointer level on its family members.
The closure runs after the pointer-flow DFS has converged and does not feed
its own output back in, so a flow edge out of a newly discovered EPL is still
missed. FamilyClosureDoesNotRerunDFS pins that gap.
§4 of rdar://179151603
[SSAF] Extract the virtual method override relation per TU
A virtual call may dispatch to any override of its callee, so a whole-program
analysis cannot reason about a method's parameters and return value in
isolation. It needs to know which method overrides which, and which slots
that relates. Collect this per TU, so a later pass can join the related
slots into families.
JSON serialization lands separately, so the summary is not writable via
--ssaf-extract-summaries yet.
§1 of rdar://179151603
[SSAF] Group virtual method slots into override families
A virtual call site can dispatch to any override, so the parameter and return
slots that occupy the same vtable slot across an override chain are
indistinguishable to a caller. Whole-program consumers therefore have to treat
them as one unit or they will reason about a slot that a call never actually
reaches.
Compute those units up front, keyed per slot, so consumers only need a map
lookup rather than their own traversal of the override relation. Overloads
occupy distinct vtable slots and stay in distinct families.
The family representative is the smallest EntityId in the class, which keeps
the result stable across runs.
§2 of rdar://179151603
[SSAF] Serialize virtual method summaries and families
Per-TU summaries and whole-program results cross process boundaries, and the
JSON layer refuses to write a summary kind it has no format for. Register both
sides so --ssaf-extract-summaries=VirtualMethod becomes usable and the family
result survives a round trip.
Deserialization tolerates a missing override list, since a root virtual method
legitimately has none.
§3 of rdar://179151603
[libc][__support] Fix linear fast path for first exponential bin in TLSFFreeStoreImpl
Linear bins occupy indices 0 to EXP_BASE - 1. Index EXP_BASE (32) is the first exponential bin.
Previously, index_to_min_size and the linear fast path in find_and_remove_fit used <= EXP_BASE,
which treated index EXP_BASE as a linear bin. This caused find_and_remove_fit to return the
first block in bin EXP_BASE without checking if its size was sufficient for the request.
This change replaces <= with < when comparing against EXP_BASE in index_to_min_size and
find_and_remove_fit, and adds a unit test (NegativeTestForFullHeap).
TAG=agy
CONV=cff84e8c-ee22-4f39-af3c-344d1e6f417b
[libc++] Add an assertion for monotonic_buffer_resource's initial_size (#213136)
[mem.res.monotonic.buffer.ctor] requires initial_size to be greater than
zero for the two constructors that take one, but we silently accepted
zero. Add a hardening assertion for that precondition.
Fixes #213059
[llvm] Include ArrayRef.h in GenericCycleInfo.h (#213267)
Try to fix the llvm-x86_64-debian-dylib builder, which has been broken
for a while with:
```
CCACHE_CPP2=yes CCACHE_HASHDIR=yes CCACHE_SLOPPINESS=pch_defines,time_macros /usr/bin/ccache /usr/bin/clang++ -DLLVM_EXPORTS -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/1/llvm-x86_64-debian-dylib/build/lib/CodeGen -I/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/lib/CodeGen -I/b/1/llvm-x86_64-debian-dylib/build/include -I/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -UNDEBUG -fno-exceptions -funwind-tables -fno-rtti -std=c++17 -MD -MT lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/CodeGenPrepare.cpp.o -MF lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/CodeGenPrepare.cpp.o.d -o lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/CodeGenPrepare.cpp.o -c /b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/lib/CodeGen/CodeGenPrepare.cpp
In file included from /b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/lib/CodeGen/CodeGenPrepare.cpp:53:
In file included from /b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/include/llvm/IR/CycleInfo.h:18:
/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/include/llvm/ADT/GenericCycleInfo.h:231:33: error: member reference base type 'ArrayRef' is not a structure or union
return ArrayRef(BlockLayout).slice(Cyc.EntryBegin, Cyc.EntrySize);
~~~~~~~~~~~~~~~~~~~~~^~~~~~
```
see e.g.
https://lab.llvm.org/buildbot/#/builders/60/builds/5422/steps/5/logs/stdio
I'm not sure if this will help or not, I can't reproduce this locally
and nobody else seems to have the same problem(?).
[libc++] Fix dangling reference in the associative container benchmarks (#213139)
Two insert benchmarks were registered with lambdas capturing insert_iter_iter_bench
by reference, unlike every other registration in this file, which captures by value.
RegisterBenchmark() stores the lambda by value and only invokes it from
RunSpecifiedBenchmarks(), which happens long after associative_container_benchmarks()
has returned, creating a dangling reference.
[libc++] Actually partially populate the container in a benchmark (#213146)
The "partially populated" variant of assignment was a copy-paste of the
"into cleared container" assignment.
[flang] Do not convert load and store FIR ops to memref if volatile (#212884)
Memref dialect has no way to express volatility currently. Let such FIR
operations to stay as FIR to be handled by CodeGen in path to LLVM.
clang: Emit "float-abi" module flag (#212985)
Emit the new module flag if it differs from the triple's
default.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[SSAF] Close unsafe-buffer reachability over override families
An unsafe pointer reaching one override's parameter is equally unsafe in every
sibling and base override of that method, because the call site picks the
target dynamically. Without closing over the families, reachability depended
on which override the extractor happened to see the flow through, so a fix
suggested for the base could be contradicted by a derived override.
Mirroring is level-preserving: families relate slot entities, so a reachable
EPL propagates only to the same pointer level on its family members.
The closure runs after the pointer-flow DFS has converged and does not feed
its own output back in, so a flow edge out of a newly discovered EPL is still
missed. FamilyClosureDoesNotRerunDFS pins that gap.
§4 of rdar://179151603
[SSAF] Serialize virtual method summaries and families
Per-TU summaries and whole-program results cross process boundaries, and the
JSON layer refuses to write a summary kind it has no format for. Register both
sides so --ssaf-extract-summaries=VirtualMethod becomes usable and the family
result survives a round trip.
Deserialization tolerates a missing override list, since a root virtual method
legitimately has none.
§3 of rdar://179151603
[SSAF] Group virtual method slots into override families
A virtual call site can dispatch to any override, so the parameter and return
slots that occupy the same vtable slot across an override chain are
indistinguishable to a caller. Whole-program consumers therefore have to treat
them as one unit or they will reason about a slot that a call never actually
reaches.
Compute those units up front, keyed per slot, so consumers only need a map
lookup rather than their own traversal of the override relation. Overloads
occupy distinct vtable slots and stay in distinct families.
The family representative is the smallest EntityId in the class, which keeps
the result stable across runs.
§2 of rdar://179151603
[SSAF] Extract the virtual method override relation per TU
A virtual call may dispatch to any override of its callee, so a whole-program
analysis cannot reason about a method's parameters and return value in
isolation. It needs to know which method overrides which, and which slots
that relates. Collect this per TU, so a later pass can join the related
slots into families.
JSON serialization lands separately, so the summary is not writable via
--ssaf-extract-summaries yet.
§1 of rdar://179151603
[VPlan] Use subpattern-m_VPValue in simplifyRecipe (NFC) (#213268)
Use the subpattern variant of m_VPValue introduced in 8db13de ([VPlan]
Remove redundant x && (y && x) -> x && y combine, #213219) to improve
code in simplifyRecipe.
[RISCV] Fix incorrect lowering of VECTOR_INTERLEAVE on fixed vectors (#212642)
This is the sibling patch of #207254, as it turns out VECTOR_INTERLEAVE
has the same problem on fixed vectors as well.
Instead of converting individual operands into scalable vectors, this
patch puts each of the operands directly onto stack using the fixed
vector version of segmented store intrinsics, before loading them back.
---------
Co-authored-by: Luke Lau <luke at igalia.com>
[libc] Fix math failures for fmod on NVPTX (#213168)
Summary:
Fixes some failing tests. Fmod's builtin has improper handling in the
NVPTX instruction so we should just use the generic version for now. The
Float128 implementation seems to have had some undefined behavior for
out of range behavior that only showed up now. Hopefully someone can
tell me if this is fixed correctly.