forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AutoBump] Merge with 5136521 (Aug 25)
- Loading branch information
Showing
1,882 changed files
with
77,297 additions
and
26,149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
## Test that infer-fall-throughs would correctly infer the wrong fall-through | ||
## edge count in the example | ||
|
||
# RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %s -o %t.o | ||
# RUN: link_fdata %s %t.o %t.fdata | ||
# RUN: llvm-strip --strip-unneeded %t.o | ||
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q | ||
# RUN: llvm-bolt %t.exe -o %t.bolt \ | ||
# RUN: --print-estimate-edge-counts --data=%t.fdata \ | ||
# RUN: 2>&1 | FileCheck --check-prefix=WITHOUTINFERENCE %s | ||
# RUN: llvm-bolt %t.exe -o %t.bolt --infer-fall-throughs \ | ||
# RUN: --print-estimate-edge-counts --data=%t.fdata \ | ||
# RUN: 2>&1 | FileCheck --check-prefix=CORRECTINFERENCE %s | ||
|
||
|
||
# WITHOUTINFERENCE: Binary Function "main" after estimate-edge-counts | ||
# WITHOUTINFERENCE: {{^\.Ltmp0}} | ||
# WITHOUTINFERENCE: Successors: .Ltmp1 (mispreds: 0, count: 10), .LFT0 (mispreds: 0, count: 0) | ||
# WITHOUTINFERENCE: {{^\.LFT0}} | ||
# WITHOUTINFERENCE: Exec Count : 490 | ||
|
||
# CORRECTINFERENCE: Binary Function "main" after estimate-edge-counts | ||
# CORRECTINFERENCE: {{^\.Ltmp0}} | ||
# CORRECTINFERENCE: Successors: .Ltmp1 (mispreds: 0, count: 10), .LFT0 (inferred count: 490) | ||
# CORRECTINFERENCE: {{^\.LFT0}} | ||
# CORRECTINFERENCE: Exec Count : 490 | ||
|
||
|
||
.globl main | ||
.type main, @function | ||
main: | ||
LLmain_LLstart: | ||
jmp LLstart | ||
# FDATA: 1 main #LLmain_LLstart# 1 main #LLstart# 0 500 | ||
LLstart: | ||
jge LLexit | ||
# FDATA: 1 main #LLstart# 1 main #LLexit# 0 10 | ||
# FDATA: 1 main #LLstart# 1 main #LLmore# 0 0 | ||
LLmore: | ||
movl $5, %eax | ||
# FDATA: 1 main #LLmore# 1 main #LLexit# 0 490 | ||
LLexit: | ||
ret | ||
.LLmain_end: | ||
.size main, .LLmain_end-main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
================= | ||
RealtimeSanitizer | ||
================= | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Introduction | ||
============ | ||
RealtimeSanitizer (a.k.a. RTSan) is a real-time safety testing tool for C and C++ | ||
projects. RTSan can be used to detect real-time violations, i.e. calls to methods | ||
that are not safe for use in functions with deterministic runtime requirements. | ||
RTSan considers any function marked with the ``[[clang::nonblocking]]`` attribute | ||
to be a real-time function. If RTSan detects a call to ``malloc``, ``free``, | ||
``pthread_mutex_lock``, or anything else that could have a non-deterministic | ||
execution time in a function marked ``[[clang::nonblocking]]`` | ||
RTSan raises an error. | ||
|
||
The runtime slowdown introduced by RealtimeSanitizer is negligible. | ||
|
||
How to build | ||
============ | ||
|
||
Build LLVM/Clang with `CMake <https://llvm.org/docs/CMake.html>` and enable the | ||
``compiler-rt`` runtime. An example CMake configuration that will allow for the | ||
use/testing of RealtimeSanitizer: | ||
|
||
.. code-block:: console | ||
$ cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_RUNTIMES="compiler-rt" <path to source>/llvm | ||
Usage | ||
===== | ||
|
||
There are two requirements: | ||
|
||
1. The code must be compiled with the ``-fsanitize=realtime`` flag. | ||
2. Functions that are subject to real-time constraints must be marked | ||
with the ``[[clang::nonblocking]]`` attribute. | ||
|
||
Typically, these attributes should be added onto the functions that are entry | ||
points for threads with real-time priority. These threads are subject to a fixed | ||
callback time, such as audio callback threads or rendering loops in video game | ||
code. | ||
|
||
.. code-block:: console | ||
% cat example_realtime_violation.cpp | ||
#include <vector> | ||
void violation() [[clang::nonblocking]]{ | ||
std::vector<float> v; | ||
v.resize(100); | ||
} | ||
int main() { | ||
violation(); | ||
return 0; | ||
} | ||
# Compile and link | ||
% clang++ -fsanitize=realtime -g example_realtime_violation.cpp | ||
If a real-time safety violation is detected in a ``[[clang::nonblocking]]`` | ||
context, or any function invoked by that function, the program will exit with a | ||
non-zero exit code. | ||
|
||
.. code-block:: console | ||
% clang++ -fsanitize=realtime -g example_realtime_violation.cpp | ||
% ./a.out | ||
Real-time violation: intercepted call to real-time unsafe function `malloc` in real-time context! Stack trace: | ||
#0 0x000102893034 in __rtsan::PrintStackTrace() rtsan_stack.cpp:45 | ||
#1 0x000102892e64 in __rtsan::Context::ExpectNotRealtime(char const*) rtsan_context.cpp:78 | ||
#2 0x00010289397c in malloc rtsan_interceptors.cpp:286 | ||
#3 0x000195bd7bd0 in operator new(unsigned long)+0x1c (libc++abi.dylib:arm64+0x16bd0) | ||
#4 0x5c7f00010230f07c (<unknown module>) | ||
#5 0x00010230f058 in std::__1::__libcpp_allocate[abi:ue170006](unsigned long, unsigned long) new:324 | ||
#6 0x00010230effc in std::__1::allocator<float>::allocate[abi:ue170006](unsigned long) allocator.h:114 | ||
... snip ... | ||
#10 0x00010230e4bc in std::__1::vector<float, std::__1::allocator<float>>::__append(unsigned long) vector:1162 | ||
#11 0x00010230dcdc in std::__1::vector<float, std::__1::allocator<float>>::resize(unsigned long) vector:1981 | ||
#12 0x00010230dc28 in violation() main.cpp:5 | ||
#13 0x00010230dd64 in main main.cpp:9 | ||
#14 0x0001958960dc (<unknown module>) | ||
#15 0x2f557ffffffffffc (<unknown module>) |
Oops, something went wrong.