Commit Graph

5226 Commits

Author SHA1 Message Date
Lang Hames 47e9e58808 [ORC][ORC-RT][MachO] Reset __data and __common sections on library close.
If we want to be able to close and then re-open a library then we need to reset
the data section states when the library is closed. This commit updates
MachOPlatform and the ORC runtime to track __data and __common sections, and
reset the state in MachOPlatformRuntimeState::dlcloseDeinitialize.

This is only a first step to full support -- there are other data sections that
we're not capturing, and we'll probably want a more efficient representation
for the sections (rather than passing their string name over IPC), but this is
a reasonable first step.

This commit also contains a fix to MapperJITLinkMemoryManager that prevents it
from calling OnDeallocated twice in the case of an error.
2022-09-16 13:40:19 -07:00
Matheus Izvekov 67e2298311
[clang] use getCommonSugar in an assortment of places
For this patch, a simple search was performed for patterns where there are
two types (usually an LHS and an RHS) which are structurally the same, and there
is some result type which is resolved as either one of them (typically LHS for
consistency).

We change those cases to resolve as the common sugared type between those two,
utilizing the new infrastructure created for this purpose.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Differential Revision: https://reviews.llvm.org/D111509
2022-09-16 16:36:00 +02:00
Matheus Izvekov 1d1a98e9a0
Revert "[clang] use getCommonSugar in an assortment of places"
This reverts commit aff1f6310e.
2022-09-16 12:03:34 +02:00
Matheus Izvekov aff1f6310e
[clang] use getCommonSugar in an assortment of places
For this patch, a simple search was performed for patterns where there are
two types (usually an LHS and an RHS) which are structurally the same, and there
is some result type which is resolved as either one of them (typically LHS for
consistency).

We change those cases to resolve as the common sugared type between those two,
utilizing the new infrastructure created for this purpose.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Differential Revision: https://reviews.llvm.org/D111509
2022-09-16 11:55:40 +02:00
Lang Hames 83a0ac12f5 [ORC-RT] Invert the layout of the trivial-jit-re-dlopen testcase.
Compiles and moves the original C code for main to Inputs/dlopen-dlclose-x2.S,
where it can be shared with other testcases that want a
dlopen-dlclose-dlopen-dlclose sequence. The assembly containging the
initializers to be tested is moved into the test file.
2022-09-15 19:11:51 -07:00
Navid Emamdoost 3e52c0926c Add -fsanitizer-coverage=control-flow
Reviewed By: kcc, vitalybuka, MaskRay

Differential Revision: https://reviews.llvm.org/D133157
2022-09-15 15:56:04 -07:00
Roy Sundahl 9a82412f82 [test][fuzzer] XFAIL tvOS tests pending investigation. (rdar://99981102)
These four tests are failing on tvOS devices (not simulators) so  XFAIL
them for now for CI and investigate further.

rdar://99981102

Differential Revision: https://reviews.llvm.org/D133963
2022-09-15 13:40:28 -07:00
Leonard Grey ed2c3f46f5 [lsan][Darwin] Scan libdispatch and Foundation memory regions
libdispatch uses its own heap (_dispatch_main_heap) for some allocations, including the dispatch_continuation_t that holds a dispatch source's event handler.
Objective-C block trampolines (creating methods at runtime with a block as the implementations) use the VM_MEMORY_FOUNDATION region (see 8701d5672d/runtime/objc-block-trampolines.mm (L371)).

This change scans both regions to fix false positives. See tests for details; unfortunately I was unable to reduce the trampoline example with imp_implementationWithBlock on a new class, so I'm resorting to something close to the bug as seen in the wild.

Differential Revision: https://reviews.llvm.org/D129385
2022-09-14 16:46:40 -04:00
Roy Sundahl 17dde371e7 [test] [fuzzer] Enable tests for iossim, disable for ios (update2)
The fuzzer tests cross_over.test and merge-control-file.test are not handled
correctly on ios device testing. On-device testing requires the macros %t, %s,
etc. to be expanded for a different default directory than when testing on host.

rdar://99889376

Differential Revision: https://reviews.llvm.org/D133811
2022-09-13 16:19:08 -07:00
Lang Hames a85e4aa37d [ORC-RT] Drop the 'clang_rt.' prefix from the ORC runtime.
The ORC runtime isn't used by clang -- the prefix was just cargo-culted with
the rest of the XRay config when the ORC runtime was introduced. We now want to
make parts of it available for clients to link directly, so this seems like a
good time to fix the name.
2022-09-12 16:48:20 -07:00
sunho 73c4033987 [ORC][ORC_RT][COFF] Support dynamic VC runtime.
Supports dynamic VC runtime. It implements atexits handling which is required to load msvcrt.lib successfully. (the object file containing atexit symbol somehow resolves to static vc runtim symbols) It also default to dynamic vc runtime which tends to be more robust.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D132525
2022-09-10 15:25:49 +09:00
Blue Gaston d1fe5cf522 [ASAN][DARWIN] Remove getpwnam(NULL) test for undefined behavior
Reverting a patch that was added to test for getpwnam(NULL) -- it was noted at the time the behavior might have been a bug, however the patch was added for binary compatibility. Because of the change in the expected behavior, we are reverting this commit, as the test added is no longer passing.

Update: Rather than reverting the original commit, updating this to only remove the unnecessary test.

Original Patch: https://reviews.llvm.org/D40052

rdar://98592334
2022-09-09 08:54:13 -07:00
Fangrui Song d8c09b7bbc Revert D111509 "[clang] use getCommonSugar in an assortment of places"
This reverts commit d42122cd5d.

`clang++ gcc/libstdc++-v3/src/c++98/complex_io.cc` (all language modes) crashes.
Also see https://reviews.llvm.org/D111509#3777980
2022-09-08 17:09:18 -07:00
Matheus Izvekov d42122cd5d
[clang] use getCommonSugar in an assortment of places
For this patch, a simple search was performed for patterns where there are
two types (usually an LHS and an RHS) which are structurally the same, and there
is some result type which is resolved as either one of them (typically LHS for
consistency).

We change those cases to resolve as the common sugared type between those two,
utilizing the new infrastructure created for this purpose.

Depends on D111283

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Differential Revision: https://reviews.llvm.org/D111509
2022-09-08 19:17:53 +02:00
Michał Górny ea953b9d9a [compiler-rt] [test] Handle missing ld.gold gracefully
Fix the is_binutils_lto_supported() function to handle missing
executables gracefully.  Currently, the function does not catch
exceptions from subprocess.Popen() and therefore causes lit to crash
if config.gold_executable does not specify a valid executable:

```
lit: /usr/lib/python3.11/site-packages/lit/TestingConfig.py:136: fatal: unable to parse config file '/tmp/portage/sys-libs/compiler-rt-
15.0.0/work/compiler-rt/test/lit.common.cfg.py', traceback: Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/lit/TestingConfig.py", line 125, in load_from_path
    exec(compile(data, path, 'exec'), cfg_globals, None)
  File "/tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py", line 561, in <module>
    if is_binutils_lto_supported():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py", line 543, in is_binutils_lto_supported
    ld_cmd = subprocess.Popen([exe, '--help'], stdout=subprocess.PIPE, env={'LANG': 'C'})
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1022, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1899, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'GOLD_EXECUTABLE-NOTFOUND'
```

Differential Revision: https://reviews.llvm.org/D133358
2022-09-07 07:14:31 +02:00
Vitaly Buka 2eda7c5b38 [test][hwasan] Update test for D132622 2022-09-06 15:54:04 -07:00
Florian Mayer 9006b082a5 [HWASan] rename left/right to before/after.
left/right is a weird way to refer to address ordering.

Reviewed By: eugenis, vitalybuka

Differential Revision: https://reviews.llvm.org/D132622
2022-09-06 13:52:28 -07:00
Florian Mayer a51d19636c [ASan] Fix libfuzzer test 2022-09-06 13:37:35 -07:00
Florian Mayer be366041fa [ASan] rename left/right to before/after.
left/right is a weird way to refer to address ordering.

Reviewed By: eugenis, MaskRay

Differential Revision: https://reviews.llvm.org/D132611
2022-09-06 13:25:15 -07:00
Vitaly Buka b4257d3bf5 [tsan] Replace mem intrinsics with calls to interceptors
After https://reviews.llvm.org/rG463aa814182a23 tsan replaces llvm
intrinsics with calls to glibc functions. However this approach is
fragile, as slight changes in pipeline can return llvm intrinsics back.
In particular InstCombine can do that.

Msan/Asan already declare own version of these memory
functions for the similar purpose.

KCSAN, or anything that uses something else than compiler-rt, needs to
implement this callbacks.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D133268
2022-09-06 13:09:31 -07:00
Igor Kudrin 84c4efbc6d [ubsan-minimal] Report the address of an error
This implements a FIXME in the runtime library and adds printing the
address at the end of the message as "by 0x123abc". The buffer for the
message is allocated on the stack in a handler, so the stack memory
consumption is slightly increased. No additional external dependencies
are added.

Differential revision: https://reviews.llvm.org/D131914
2022-09-05 14:18:25 +04:00
Lang Hames 1169586dcd [ORC-RT] Refactor ORC runtime CMake for future test tool(s).
We want to move functionality from the LLVM ORCTargetProcess library into the
ORC runtime, and this will mean implementing remote-executor testing tools
(like llvm-jitlink-executor and lli-child-target) in the ORC runtime.

This patch refactors the ORC runtime build system to introduce an
add_orc_tool function that can be used to add new test tools. The code is
modeled on existing functions for adding unit tests.

A placeholder orc-rt-executor tool and test are added to verify that the
config changes behave as expected.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D133084
2022-09-02 20:59:57 -07:00
Andrew Browne 64529eb291 [DFSan] Increase size of buffer to fix possibly-flakey test.
Observed a test failure where "Returned length: 3054".

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D133227
2022-09-02 17:52:12 -07:00
Lang Hames acce424111 [ORC-RT] Fix typo.
Removes the stray '$' that slipped in to c1c585a065.
2022-09-01 23:16:45 -07:00
Lang Hames c1c585a065 [ORC-RT] Don't unconditionally add dependence on llvm-jitlink.
Commit 4adc5bead4 moved a dependence on llvm-jitlink from
SANITIZER_COMMON_LIT_TEST_DEPS to ORC_TEST_DEPS, but in doing so it moved it
out from under a 'NOT COMPILER_RT_STANDALONE_BUILD ...' conditional. This led
to failures on standalone builds.

This commit adds the conditional to the ORC_TEST_DEPS assignment to work
around the issue while we look a longer term fix.

rdar://99453446
2022-09-01 22:53:30 -07:00
Kevin Athey 0b509f2d1a [MSAN] removing redundant tests and parameters (NFC)
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D117622
2022-09-01 14:03:55 -07:00
Vitaly Buka 960e7a5513 [msan] Use Debug Info to point to affected fields
Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D132909
2022-08-31 13:12:17 -07:00
Vitaly Buka c059ede28e [msan] Add more specific messages for use-after-destroy
Reviewed By: kda, kstoimenov

Differential Revision: https://reviews.llvm.org/D132907
2022-08-30 19:52:32 -07:00
Lang Hames 4adc5bead4 [ORC-RT] Make llvm-jitlink an ORC-RT specific dependence.
The llvm-jitlink tool is not needed by other sanitizer tests.
2022-08-30 17:19:54 -07:00
Gulfem Savrun Yeniceri 999886325e [profile] Create only prof header when no counters
When we use selective instrumentation and instrument a file
that is not in the selected files list provided via -fprofile-list,
we generate an empty raw profile. This leads to empty_raw_profile
error when we try to read that profile. This patch fixes the issue by
generating a raw profile that contains only a profile header when
there are no counters and profile data.

A small reproducer for the above issue:
echo "src:other.cc" > code.list
clang++ -O2 -fprofile-instr-generate -fcoverage-mapping
-fprofile-list=code.list code.cc -o code
./code
llvm-profdata show default.profraw

Differential Revision: https://reviews.llvm.org/D132094
2022-08-30 19:50:41 +00:00
Hans Wennborg 54e17931a6 Mark compiler-rt/test/profile/instrprof-merging.cpp unsupported on Windows
It is not reliable. See #57430.
2022-08-29 21:36:22 +02:00
Vitaly Buka 64dbcca6cf [test][msan] Add debug info use-after-dtor tests 2022-08-28 23:05:23 -07:00
Rainer Orth a31426dc87 [asan][test] Fix typo in Unit/lit.site.cfg.py.in
I noticed that `test/asan/Unit/lit.site.cfg.py.in` contains two typos,
using the FreeBSD forms of the `LD_*LIBRARY_PATH*` variables on Solaris.

Tested on `amd64-pc-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D132736
2022-08-27 07:50:18 +02:00
Julian Lettner 3d928e1d28 [TSan] Fix pointer/type-mismatch bug in test that has turned into a compile error
Fixes this test compile error:
```
<path>/compiler-rt/test/tsan/debug_alloc_stack.cpp:54:7: error: no matching function for call to '__tsan_get_alloc_stack'
      __tsan_get_alloc_stack(mem, trace, num_frames, &thread_id, &thread_os_id);
      ^~~~~~~~~~~~~~~~~~~~~~
<path>/compiler-rt/test/tsan/debug_alloc_stack.cpp:17:16: note: candidate function not viable: no known conversion from 'uint64_t **' (aka 'unsigned long long **') to 'uint64_t *' (aka 'unsigned long long *') for 5th argument; remove &
extern "C" int __tsan_get_alloc_stack(void *addr, void **trace, size_t size,
               ^
<path>/compiler-rt/test/tsan/debug_alloc_stack.cpp:61:46: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t *' (aka 'unsigned long long *') [-Wformat]
  fprintf(stderr, "thread os id = 0x%llx\n", thread_os_id);
                                    ~~~~     ^~~~~~~~~~~~
1 warning and 1 error generated.
```
2022-08-26 16:29:30 -07:00
Julian Lettner af64a9248f [Tests][TSan] Remove bash-ism `|&`, which is unsupported on other shells 2022-08-26 14:38:06 -07:00
Teresa Johnson d10c1b88f0 [memprof] Correct max size and access count computations
The existing code resulted in the max size and access counts being equal
to the min. Compute the max instead (max lifetime was already correct).

Differential Revision: https://reviews.llvm.org/D132515
2022-08-23 16:53:46 -07:00
Yuanfang Chen e78208f082 [compiler-rt][lit] initialize LIT LLVMConfig instance
to handle lit tools searching. Otherwise
compiler-rt depends on system environment variable PATH for lit tools
which diverge from the other LLVM projects. This reverts D83486 which
really should be implemented in LIT itself when the PATH is constructed.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D122837
2022-08-22 16:36:39 -07:00
Andrew Browne 065d2e1d8b [DFSan] Fix handling of libAtomic external functions.
Implementation based on MSan.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D132070
2022-08-22 16:04:29 -07:00
Vitaly Buka d848186a3b [tsan] Keep thread/stack for closed FD
Fixes b/242869837

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D132068
2022-08-22 12:00:52 -07:00
David Blaikie 89d7db9d81 Revert "[tsan] Keep thread/stack for closed FD"
Test is flaky.

This reverts commit e9c5bde88e.
2022-08-19 04:01:42 +00:00
Vitaly Buka e9c5bde88e [tsan] Keep thread/stack for closed FD
Fixes b/242869837

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D132068
2022-08-18 01:29:29 -07:00
Vitaly Buka 3f5f2905c4 [test] Propagate HWASAN_OPTIONS 2022-08-17 18:59:49 -07:00
Vitaly Buka 57d0e9bf96 [test][sanitizer] Disable netdb tests on Android 2022-08-13 01:07:12 -07:00
Vitaly Buka c34b0720ca [test][sanitizer] Fix REQUIRES in the test 2022-08-13 00:04:55 -07:00
Vitaly Buka cd269daf25 [test][asan] Remove -fsanitize-address-use-after-scope
It's enabled by default in D31479.
2022-08-13 00:04:55 -07:00
Sunho Kim 9189a26664 [ORC_RT][COFF] Initial platform support for COFF/x86_64.
Initial platform support for COFF/x86_64.

Completed features:
* Statically linked orc runtime.
* Full linking/initialization of static/dynamic vc runtimes and microsoft stl libraries.
* SEH exception handling.
* Full static initializers support
* dlfns
* JIT side symbol lookup/dispatch

Things to note:
* It uses vc runtime libraries found in vc toolchain installations.
* Bootstrapping state is separated because when statically linking orc runtime it needs microsoft stl functions to initialize the orc runtime, but static initializers need to be ran in order to fully initialize stl libraries.
* Process symbols can't be used blidnly on msvc platform; otherwise duplicate definition error gets generated. If process symbols are used, it's destined to get out-of-reach error at some point.
* Atexit currently not handled -- will be handled in the follow-up patches.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D130479
2022-08-13 13:48:40 +09:00
Vitaly Buka 4b33ea052a [sanitizer] Add dn_comp interceptor
Reviewed By: kda

Differential Revision: https://reviews.llvm.org/D129247
2022-08-12 16:57:49 -07:00
Kevin Athey 532564de17 [MSAN] add flag to suppress storage of stack variable names with -sanitize-memory-track-origins
Allows for even more savings in the binary image while simultaneously removing the name of the offending stack variable.

Depends on D131631

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D131728
2022-08-12 11:59:53 -07:00
Vitaly Buka c615411d82 [test][asan] Disable symbolization
Reduces runtime of the test.
Unrelated pre-merge checks often timeouts here.
2022-08-11 00:02:02 -07:00
Vitaly Buka ad5f7895ef [test][sanitizer] Fix REQUIRES of the test
getnetent is availible from API 28
2022-08-10 16:59:40 -07:00