SecondLevelPageOffset should be incremented by SecondLevelPageSize bytes, not
one byte.
Failure to calculate the offset correctly leads to corrupted unwind-info (and
consequently broken exceptions / unwinding) when more than one second level
page is needed. Since JITLink's unwind support only produces
UNWIND_SECOND_LEVEL_REGULAR-style pages this would trigger for any file
containing more than 511 functions with unwind info. The included test-case
contains 1022 functions (sufficient for both the current format and any
future implementation that supports UNWIND_SECOND_LEVEL_COMPRESSED pages).
Thanks to @edoardo on discord for spotting this bug!
(cherry picked from commit 88f55d16c4c247a9eef326961a1445dee3f2e30c)
Re-enables compact-unwind support in JITLink, which was reverted in b04847b427d
due to buildbot failures.
The underlying cause for the failures on the buildbots was the lack of
compact-unwind registration support on older Darwin OSes. Since the
CompactUnwindManager pass now removes eh-frames by default we were left with
unwind-info that could not be registered. On x86-64, where eh-frame info is
produced by default the solution is to fall back to using eh-frames. On arm64
we simply can't support exceptions on older OSes.
This patch updates the EHFrameRegistrationPlugin to remove the compact-unwind
section (__LD,__compact_unwind) when installed, forcing use of eh-frames when
the EHFrameRegistrationPlugin is used. In LLJIT, the EHFrameRegistrationPlugin
continues to be used for all non-Darwin platform, and will be added on Darwin
platforms when the a CompactUnwindRegistrationPlugin instance can't be created
(e.g. due to missing support for compact-unwind info registration).
The lit.cfg.py script is updated to check whether the host OSes default unwind
info supports JIT registration, allowing tests to be disabled for older Darwin
OSes on arm64.
(cherry picked from commit eae6d6d18bd4d9e7dfe5fc1206d23d8ef663c8c7)
The suppressions mechanism doesn't work reliably in optimized builds,
which turns out to be a known issue (see b87543c704724 / svn r308908).
Disable this test, as it is also testing a feature (alloc/dealloc
mismatch) that is disabled by default on Darwin anyway.
rdar://143830493
(cherry picked from commit 4985804c0608a83f6ab017137c3d3d4f02827774)
Add %env_asan_opts=alloc_dealloc_mismatch=1 since it is disabled by
default.
rdar://143830493
(cherry picked from commit f0d05b099dafda89df4c971b64b2051c33db5da1)
In certain cases, the SDK headers declare
`OSSpinLock*` APIs as macros (instead of
functions), so users can be transparently
forwarded to non-deprecated APIs.
When enabled, building of TSan interceptors failed
because these macros interfere with the
interceptor machinery, i.e., they prevent proper
forward declaration of intercepted APIs.
In a previous change [1], we misattributed this to
the deprecation of `OSSpinLock*` APIs.
[1] ae484c21c05668f84b13304c28bc39f753e493de
rdar://143193907
When targeting ABIO32 (mips32), _ABIN32 is undefined and the
preprocessor directives cause compile errors. Guard references to
_ABIN32 with defined(_ABIN32), just like the references to _ABIO32.
Signed-off-by: Jens Reidel <adrian@travitia.xyz>
These cannot be detected by reading the ID_AA64ISAR1_EL1 register since
their corresponding bitfields are hidden. Additionally the instructions
that these features enable are unusable from EL0.
ACLE: https://github.com/ARM-software/acle/pull/382
TySan supports some preprocessor checks and ignorelists, but they are
currently untested. This PR adds some tests to make sure they all work.
@fhahn @AaronBallman, this is based off the discussion in the
documentation PR [#123595]
This reverts 4f0325873faccfbe171bae4babceb65975ca892e and follow-up patches
(see below) while I investigate some ongoing failures on the buildbots.
---
Revert "[clang-repl] Try to XFAIL testcase on arm32 without affecting arm64
darwin."
This reverts commit fd174f0ff3e793fe96a6663b1488ed159cfe042f.
Revert "[clang-repl] The simple-exception test now passes on arm64-darwin."
This reverts commit c9bc242e387f4a4a3dfcd86561f3ec0ca8a72d62.
Revert "[ORC] Destroy defunct MaterializationUnits outside the session lock."
This reverts commit a001cc0e6cdcfa672b8aff9ce6d14782bb96356a.
Revert "[ORC] Add explicit narrowing casts to fix build errors."
This reverts commit 26fc07d5d88760ad659599184fd10181287d2d9e.
Revert "[ORC] Enable JIT support for the compact-unwind frame info format on
Darwin."
This reverts commit 4f0325873faccfbe171bae4babceb65975ca892e.
For Darwin/arm64 (including Apple Silicon Macs) this will enable exception
handling and stack unwinding in JIT'd code.
Darwin supports two unwind-info formats: DWARF eh-frames and compact-unwind. On
Darwin/x86-64 compilers usually produce both by default, and ORC supported
exceptions and unwinding via eh-frames (same as on Linux), discarding the
redundant compact-unwind info. On Darwin/arm64 compilers typically default to
producing compact-unwind only, with DWARF eh-frames as a fallback for functions
that can't be described in compact-unwind. Since ORC did not previously support
the compact-unwind format and eh-frames were not present ORC was unable to
handle exceptions or unwinding by default in Darwin/arm64 JIT'd code.
This patch enables support for the compact-unwind-info format, and contains
three major moving parts:
(1) The JITLink CompactUnwindManager class is responsible for transforming the
__compact_unwind records produced by the linker into the __unwind_info
tables that libunwind parses during unwinding. To enable this the
CompactUnwindManager class provides three JITLink passes: The
prepareForPrune pass that splits the __compact_unwind section into
single-record blocks, allowing unused records to be dead-stripped; the
processAndReserveUnwindInfo pass that reserves space for the final
__unwind_info section, and the writeUnwindInfo pass that writes the
__unwind_info section.
(2) The OrcTargetProcess UnwindInfoManager class maintains a table of
registered JIT'd __unwind_info and __eh_frame sections, and handles
requests from libunwind for unwind info sections (by registering a callback
with libunwind's __unw_add_find_dynamic_unwind_sections function).
(3) The Orc UnwindInfoRegistrationPlugin, which scans LinkGraphs for
__unwind_info and __eh_frame sections to register with the
UnwindInfoManager.
This commit adds the CompactUnwindManager passes to the default JITLink
pipelines for Darwin/arm64 and Darwin/x86-64, and UnwindInfoManager intances to
the SelfExecutorProcessControl class (when built for apple platforms) and the
llvm-jitlink-executor tool.
The LLJIT class will now create an UnwindInfoRegistrationPlugin when targeting
a process running on Darwin if it detects that an UnwindInfoManager is
available to handle the registrations.
The ORC runtime macho_platform class already supported libunwind callbacks, so
out-of-process execution and unwinding support will work when loading the ORC
runtime.
The llvm-jitlink tool will only support compact-unwind when the orc-runtime is
loaded, as the UnwindInfoRegistrationPlugin requires access to an IR compiler
to load a helper module and llvm-jitlink does not provide an IR compiler.
An initializer for the Crash Reporter Annotatoins struct was added in
version 5. For the simplicity of not needing to always update the struct
in subsequent versions, this patchs checks for the initializer before
attempting to redefine the struct on its own.
Note -- we have an existing test for this that is disabled by default,
it is inherently flakey due to the nature of crash reporter. But we can
run that when making crash reporter related changes.
rdar://136156203
This patch makes Arm builtins aware of endianness in VMOVs.
Before this patch, the functions' definitions assumed little endian,
which made any program compiled for big endian incorrect.
The attr typically located on the stack is of an opaque pthread_attr_t
type, which may be a pointer that gets initialized by
pthread_attr_init(). Explicitly clean up the attr with
pthread_attr_destroy() to avoid a leak on such platforms to avoid
unexpected test failures with lsan enabled.
This primarily affects FreeBSD; NetBSD, musl, and glibc will seemingly
all use a full-sized pthread_attr_t.
Enable ELFNixPlatform support for loongarch64. These are few simple
changes, but it allows us to use the orc runtime in ELF/LoongArch64
backend.
This change adds test cases targeting the LoongArch64 Linux platform to
the ORC runtime integration test suite. Since jitlink for loongarch64 is
ready for general use, and ELF-based platforms support defining multiple
static initializer table sections with differing priorities, some
relevant test cases in compiler-rt for ELFNixPlatform support can be
enabled.
This ensures that the directory layout of the libc++/libc++abi matches
exactly what we would get on a real installation. Currently the build
directory happens to match the install directory layout, but this will
no longer be true in the future.
In PGO continuous mode, we mmap the profile file into shared memory, which
allows multiple processes to be updating the same memory.
The -fprofile-update=atomic option forces the counter increments to be atomic,
but the counter size is always 64-bit (in -m32 and -m64), so in 32-bit mode the
atomic operations are function calls to libatomic.a and these function calls use
locks.
The lock based libatomic.a functions are per-process, so two processes will race
on the same shared memory because each will acquire their own lock.
In LTO builds, some test checks can be optimized away, since the
compiler can
see through the memory accesses after inlining across TUs. This causes
the existing death tests to fail, since the functions are completely
optimized out and things like copying a lambda will no longer occur and
trigger the sanitizer.
To prevent that, we can use an empty inline assembly block to tell the
compiler that memory is modified, and prevent it from doing that.