[clang][Driver] Ensure intermediate bitcode files are written according to `/Fo` (#189977)
With the following compilation process:
```
$ mkdir -p src/ tmp/
$ cat << 'EOF' > src/main.c
int main() { return 0; }
EOF
$ clang-cl /c /Fo:tmp/ /clang:-fembed-bitcode src/main.c
```
the object file `main.obj` is generated in the `tmp/` directory but the
intermediate `main.bc` is placed in the current working directory.
This PR ensures that intermediate `.bc` files are written to the same
directory specified by `/Fo`.
[libc] Fix 'finish()' being called by the client instead of the server (#191226)
Summary:
This function is supposed to manage the doorbell interrupts. The flow
that was intended was that the client notified work to wake the server
and the server finished the work so it didn't go back to sleep until
everything was done. This was reversed and we had the client finishing
work and then stalling on it.
[libc] Add a redirecting <syscall.h> header. (#191069)
The amount of legacy code including `<syscall.h>` header instead of
`<sys/syscall.h>` (which is the regular header location on Linux
systems) out there is large.
Add a simple one-liner redirecting header to fix this compatibility
issues. In this PR I omit the regular licensing blurb at the top, given
the transient nature of this file, but I'm happy to add this if needed.
Also, given that it's effectively a compatibility shim, YAML generation
is not used.
hwpmc: prevent IBS fetch from getting stuck
Both fetch and op IBS sampling have the same problem where we need to
rewrite the control MSR to ensure sampling continues at the correct
rate. I also like this because it resets the counter reducing the
chances that we collect a sample inside the NMI handler.
Reported by: Aalok Agarwal
Reviewed by: mhorne
Sponsored by: Netflix
Fixes: e51ef8ae490f ("hwpmc: Initial support for AMD IBS")
Pull Request: https://github.com/freebsd/freebsd-src/pull/2130
hwpmc: Fix bug when stopping ibs-op
In ibs_stop_pmc I accidently cleared the fetch max count value rather
than the op max count value, when stopping the op counter. This
mitigates a bug in early pre-zen processors, but breaks using both
counters simultaneously. I also found that the max op count mask needs
to be extended for recent zen processors.
Reported by: Andre Fernando da Silva
Reviewed by: mhorne
Sponsored by: Netflix
Fixes: e51ef8ae490f ("hwpmc: Initial support for AMD IBS")
Pull Request: https://github.com/freebsd/freebsd-src/pull/2120
[clang][modules] Close module file descriptors (#191227)
This was missed in the original PR and was causing "too many files open"
errors on real workloads.
[DA] Fix overflow of findBoundsALL in BanerjeeTest
Fix signed overflow handling in `findBoundsALL` for the Banerjee test.
The previous implementation computed bounds using `getMinusSCEV` and
`getMulExpr` without checking for signed overflow, which could produce
incorrect bounds when coefficients have extreme values.
- Add `mulSCEVNoSignedOverflow` helper function that checks for
multiplication overflow before computing the result
- Use `minusSCEVNoSignedOverflow` and `mulSCEVNoSignedOverflow` in
`findBoundsALL` to safely compute bounds, returning `nullptr`
when overflow would occur
[clang][ssaf] Fix CLANG_PLUGIN_SUPPORT=OFF SSAFExamplePlugin cmake errors (#191229)
Such builds would fail with:
```
...
CMake Error at cmake/modules/AddLLVM.cmake:2245 (add_dependencies):
The dependency target "SSAFExamplePlugin" of target
"check-clang-utils-update_cc_test_checks" does not exist.
...
```
This fixes it by using the same condition for the test dependency as is
used for deciding to build the plugin in
clang/lib/ScalableStaticAnalysisFramework/Plugins/CMakeLists.txt
Reland [MC] Fuse relaxation and layout into a single forward pass (#190318)
This relands debb2514ea7f, which was reverted by #189548 due to ARM
spurious `cbz` out of range error (Chromium, Android).
---
Replace the two-pass inner loop in relaxOnce (relaxFragment +
layoutSection) with a single forward pass that sets each fragment's
offset before processing it.
- Extract relaxAlign from layoutSection's FT_Align handling and call
it from relaxFragment. FT_Align padding is computed inline with the
tracked Offset, so alignment fragments always see fresh upstream
offsets. This structurally eliminates the O(N) convergence pitfall
where stale offsets caused each iteration to fix only one more
alignment fragment.
- The new MCAssembler::Stretch field tracks the cumulative upstream size
[55 lines not shown]
MVC: add support for pluggable dynamic menu items and move some existing parts out of the MenuSystem class
In most cases we use static menu registartions, but there are exceptions which depend on interfaces for example.
While looking at https://github.com/opnsense/core/pull/10033, a longer standing wish came up again, which is the reason to add this support right now. It also helps in removing some legacy components for good via plugins.
To register new menu items, the following pattern may be used:
* In your model, derive a Menu class from MenuContainer
* implement a method collect() which should add new menu items via the appendItem() {bound to appendItem in MenuSystem}
Always try to minimize the amount of code inside these plugins as this code will be executed on each page load.
[LLVM][AArch64] Remove addrspace(0) restriction from all SVE/SME memory intrinsics. (#189992)
This requirement was not intentional, just the result of convenience.
Fixes: https://github.com/llvm/llvm-project/issues/183265
---------
Co-authored-by: nikhil-m-k <nikhil_mk at yahoo.com>
[compiler-rt] [Darwin] Move macOS ASAN reservation above 512G (#191039)
On macOS, the first 512G may contain platform-specific reservations. To
ensure compatibility with these reservations, this changes ASAN to
always map shadow memory above 512G on macOS.
rdar://174252720
[InstCombine][ProfCheck] Mark unknown select profiles in sub xor fold (#191192)
Mark the weights as explicitly unknown given we cannot statically infer
the weights without value profiling due to the select being synthesized
from a binary operation.
[flang][OpenMP] Add optional SemanticsContext parameter to loop utilities
Some of the utilities may be used in symbol resolution which is before
the expression analysis is done. In such situations, the typedExpr's
normally stored in parser::Expr may not be available.
To be able to obtain numeric values of expressions, using the analyzer
directly may be necessary, which requires SemanticsContext to be provided.
[BasicAA] Fix assertion failure in alias() caused by non-pointer base in DecomposeGEPExpression (#191180)
When stripping a bitcast in DecomposeGEPExpression, the resulting
operand may have a non-scalar-pointer type (e.g. <1 x ptr>). Proceeding
with such a type as the decomposition base violates the AA assumption
that all pointers are scalar pointer types, triggering an assertion
failure on alias() call.
Add a type check in the bitcast/addrspacecast handling path to return
not stripped V as base when the stripped operand is not a scalar pointer
type.
Add a lit test verifying no crash on valid IR containing such a bitcast,
and checking that the alias query conservatively returns MayAlias.
Fixes #191157
[DA] Fix overflow of findBoundsALL in BanerjeeTest
Fix signed overflow handling in `findBoundsALL` for the Banerjee test.
The previous implementation computed bounds using `getMinusSCEV` and
`getMulExpr` without checking for signed overflow, which could produce
incorrect bounds when coefficients have extreme values.
- Add `mulSCEVNoSignedOverflow` helper function that checks for
multiplication overflow before computing the result
- Use `minusSCEVNoSignedOverflow` and `mulSCEVNoSignedOverflow` in
`findBoundsALL` to safely compute bounds, returning `nullptr`
when overflow would occur