[ORC] Replace JIT-dispatch handlers with call-controller handlers (#228628)
This is the executor-to-controller counterpart to Proxy: where Proxy
provides a uniform way to call functions in the executor,
call-controller handlers provide a uniform way for the executor to call
handlers in the controller.
Handlers are now registered as CallControllerHandlerBindings, which
decouples ExecutionSession's handler registration from
SimplePackedSerialization. The new bindCallControllerHandlerSPS utility
makes it easy to introduce a new SPS handler with a one-liner, using
either a lambda:
ES.registerCallControllerHandlers(
JD, bindCallControllerHandlerSPS<int32_t(int32_t, int32_t)>(
SymbolNameSpec::c("add_tag"),
[](unique_function<void(int32_t)> Return,
int32_t X, int32_t Y) {
Return(X + Y);
[39 lines not shown]
[Clang][HIP] Skip internalization for non-LTO device links (#225859)
A non-LTO HIP device link can combine native relocatable objects with
bitcode libraries. This can happen with both RDC and non-RDC
compilation. LLD must resolve undefined symbols in the native objects
with definitions from the bitcode.
The LTO step processing the bitcode cannot see references from native
objects. Internalizing non-kernel functions can therefore hide
definitions that those objects need. Do not enable AMDGPU
internalization for these mixed non-LTO links.
LTO mode does not have this problem. It links the bitcode modules before
internalization, so the references are visible when symbols are
resolved. Keep internalization for LTO links and when compiling non-RDC
main modules.
[Clang][HIP] Skip internalization for non-LTO device links (#225859)
A non-LTO HIP device link can combine native relocatable objects with
bitcode libraries. This can happen with both RDC and non-RDC
compilation. LLD must resolve undefined symbols in the native objects
with definitions from the bitcode.
The LTO step processing the bitcode cannot see references from native
objects. Internalizing non-kernel functions can therefore hide
definitions that those objects need. Do not enable AMDGPU
internalization for these mixed non-LTO links.
LTO mode does not have this problem. It links the bitcode modules before
internalization, so the references are visible when symbols are
resolved. Keep internalization for LTO links and when compiling non-RDC
main modules.
[mlir][scf] Fix scf.for value bounds for empty and unsigned loops (#226761)
Value bounds assumes that an `scf.for` result is `init + ceildiv(ub -
lb, step) * (yield - iter_arg)`. This is only true if the loop runs at
least once. When the loop does not run, `ceildiv(ub - lb, step)` is
negative instead of 0. For unsigned loops, `ub - lb` is computed as if
the bounds were signed, which also gives a wrong trip count. The
induction variable bounds of unsigned loops have the same signed
problem.
Example:
```mlir
%r = scf.for %iv = %c5 to %c2 step %c1 iter_args(%arg = %c7) -> index {
%n = arith.addi %arg, %c1 : index
scf.yield %n : index
}
%m = affine.min affine_map<(d0) -> (d0, 5)>(%r)
```
The loop does not run, so `%r` is 7 and `%m` should be 5. Value bounds
[13 lines not shown]
The path generation must not contain '..' or '/' type patterns or it
can walk upwards and sideways. The privsep open() is now restricted by
a single unveil() inside the config directory, but files in relative config
directories can still be reached and create potentially confusing outcomes.
This is half of a repair from Franz Bettag before I restructured the privsep
to use unveil(), the other half of the repair is not needed because it applies
to code that no longer exists.
ok markus hshoexer bluhm, testing sthen mvs
Franz Bettag sent a report & diff repairing the privsep monitor's
dangerous file behavior in /var/run, and I was shocked at what it
does. isakmpd never had a proper diagnosis and control program like
other daemons do, and instead accepts weird commands on a fifo and
splats files dangerously. Some path names can be manipulated. This
2600 line diff removes all of this session debugging mechanism which
is the main cause of that unsafe design. There are no reuseable parts
in that code (it cannot be reconstructed into a proper control program
interface). As a result, the privsep monitor now has unveil to the
config directory, and the network speaking process is "stdio sendfd
route recvfd inet". There is some loss of functionality, since some
users had gotten used to the decrepit debugging / logging interface to
repair sessions which would not negotiate.
This is almost completely unmaintained code from early OpenBSD days
with an incorrect privsep design, and many users have migrated to
using iked(8) which does IKEv2 protocol. RFC9395 also provides valuable
guidance here. Everyone is urged to avoid using this program. If IKEv1
protocol is still a part of your life roll up sleeves and try to write a
high-quality control interface using lessons from the IKEv2 iked(8) code.
[2 lines not shown]
[orc-rt] Use the Error matchers in NativeDylibManagerSPSCITest (#228629)
Use the Error matchers introduced in 4c8a437d0487 to clean up error
checks in NativeDylibManagerSPSCITest.
[CodeGen] Avoid sinking EH pad blocks (#224812)
EH pad blocks should not be sinkable since the control flow comes from
the unwinder instead of the predecessor.
This exclusion also matches the behavior of other sinkers.
Fixes #224802.
[lldb] Don't run code for CanJIT() while creating the ObjC runtime (#227555)
When libobjc lacks class_getMethodImplementation, the ObjC trampoline
handler calls CanJIT() to decide whether to warn. Without the _M
packet, CanJIT() allocated memory by calling mmap in the inferior.
Setting up that call unwinds the stack, which asks for the ObjC
runtime. The runtime isn't registered yet, so LLDB creates another one
and recurses until the stack overflows.
Ask the process plugin whether it can allocate memory instead of
trying it. ProcessGDBRemote probes the _M packet and otherwise checks
for an mmap symbol, neither of which runs code in the inferior.
rdar://188335027
[lldb][FreeBSDKernel] Find .debug files using pseudo sysroot (#224845)
Unlike userspace processes, it is common to obtain kernel dump from a
machine (e.g. QEMU) which different from the machine debugging the dump.
In this case users need to run `target symbols add foo.debug` for the
kernel and each kernel object, which becomes quite inconvenient when the
machine had dozens of kernel modules loaded during the dump.
This patch adds functionality to the dynamic loader so that it loads
symbol files automatically when kernel or kenrel modules are loaded. It
assumes a pseudo sysroot. When kernel is located at
`/foo/boot/kernel/kernel`, it will look for
`foo/usr/lib/debug/boot/kernel/kernel.debug` and same for kernel
modules. In this case, the only thing users need to do is copying the
dumped machine's `/usr/lib/debug/boot` relative to `/boot` that is being
debugged.
Assisted-by: GPT
[CASPlugin] Move CASPluginTest next to the CAS unit tests (#227546)
Set up the CAS test plugin like CGTestPlugin: move it from
llvm/tools/libCASPluginTest to llvm/unittests/CAS/CASPluginTest and
build it as CASPluginTest${LLVM_PLUGIN_EXT}, without the lib prefix or
a version, so its name is the same on all platforms. The lit tests now
find it via %llvmshlibdir/CASPluginTest%pluginext instead of a
configured LLVM_CAS_PLUGIN_TEST_PATH, and CASTests gets its path from
the build system through the CAS_PLUGIN_PATH definition.
[llvm-objcopy][MachO] Fix use-after-free when stripping (#228607)
We must preserve symbols referenced by the indirect symbol table even
with strip all, and we must preserve symbols referenced by relocations
without strip all.
Fixes: https://github.com/llvm/llvm-project/issues/228595
Assisted-by: codex
[lldb] Search both visionOS and XROS DeviceSupport directories (#228573)
Xcode now downloads visionOS shared cache symbols into
~/Library/Developer/Xcode/visionOS DeviceSupport, but
PlatformRemoteAppleXR only looked in "XROS DeviceSupport". As a result,
LLDB never found the expanded shared cache for visionOS devices and
failed to resolve symbols like `memcpy`, which breaks expression
evaluation and loading images into the inferior.
This makes `GetDeviceSupportDirectoryName` return a list of directory
names (renamed to `GetDeviceSupportDirectoryNames`) and have
`PlatformDarwinDevice` search each of them. visionOS returns both the
current and the legacy name; all other platforms keep their single name
for now.
rdar://189049149
Signed-off-by: Med Ismail Bennani <ismail at bennani.ma>
[OpenMP] Do not GEP 'inbounds' for multi-dimensional OpenMP device maps (#218436)
The C standard treats array subscripts as inbounds of the object, but
OpenMP section maps intentionally index from a host-relative base that
is not the mapped allocation. Drop inbounds on those GEPs so later
passes do not assume the slice lives inside the object.
---------
Co-authored-by: Alexey Bataev <a.bataev at gmx.com>
ntp(9): Avoid more left shift of negative UB.
This logic is, presumably, intended to compute integer arithmetic, so
just write it as *16 instead of <<4. If there's an advantage to
using a machine shift instruction to get the same semantics, the
compiler can do that for us.
Also avoid arithmetic overflow. If set a few lines above,
time_monitor can lie anywhere in the interval [-MAXPHASE,MAXPHASE] =
[-500e6,500e6]. Multiplying by sixteen can therefore overflow the
bounds [-2.2e9,2.2e9] of long on LP32 platforms by a factor of four.
But mtemp >= 256 here, so even if time_monitor*16 overflows the
signed 32-bit range, the result (time_monitor*16)/mtemp will not.
Hence: cast to int64_t for the intermediate computation of
time_monitor*16.
This isn't the end of the analysis: time_monitor can also be set in
hardpps(9) to something else whose bounds aren't as clear to me, but
that only applies under `options PPS_SYNC' which is usually not set.
[4 lines not shown]
[VPlan] Remove NDEBUG and LLVM_ENABLE_DUMP guards around VPBlockBase::printOperand (#228326)
DominatorTreeBase::print calls the printOperand function of its NodeT
type unconditionally and the VPDominatorTree class is derrived from
DominatorTreeBase<VPBlockBase, false>.
This fixes the link with MSVC and LLVM_BUILD_LLVM_DYLIB_VIS=ON.