Skip to content

Commit

Permalink
[AutoBump] Merge with 5136521 (Aug 25)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgehre-amd committed Sep 20, 2024
2 parents 80da664 + 5136521 commit f0747cd
Show file tree
Hide file tree
Showing 1,882 changed files with 77,297 additions and 26,149 deletions.
1 change: 1 addition & 0 deletions .github/workflows/libcxx-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ jobs:
'generic-no-experimental',
'generic-no-filesystem',
'generic-no-localization',
'generic-no-terminal',
'generic-no-random_device',
'generic-no-threads',
'generic-no-tzdb',
Expand Down
2 changes: 1 addition & 1 deletion .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<i@maskray.me> <maskray@google.com>
<JCTremoulet@gmail.com> <jotrem@microsoft.com>
<min@myhsu.dev> <minyihh@uci.edu>
<qiucofan@cn.ibm.com> <qiucf@cn.ibm.com>
<qcf@ecnelises.com> <qiucofan@cn.ibm.com> <qiucf@cn.ibm.com>
<rnk@google.com> <reid@kleckner.net>
<thakis@chromium.org> <nicolasweber@gmx.de>
Jianjian GUAN <jacquesguan@me.com>
Expand Down
3 changes: 2 additions & 1 deletion bolt/lib/Core/BinaryFunctionProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ void BinaryFunction::inferFallThroughCounts() {
if (SuccBI.Count == 0) {
SuccBI.Count = Inferred;
SuccBI.MispredictedCount = BinaryBasicBlock::COUNT_INFERRED;
Succ->ExecutionCount += Inferred;
Succ->ExecutionCount =
std::max(Succ->getKnownExecutionCount(), Inferred);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions bolt/test/X86/end-symbol.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# RUN: yaml2obj %p/Inputs/plt-sec.yaml &> %t.exe
# RUN: llvm-bolt %t.exe -o %t.out
# RUN: (llvm-readelf --program-headers %t.out | grep LOAD | tail -n 1 ; llvm-nm %t.out) \
# RUN: | FileCheck %s

# RUN: llvm-readelf --program-headers %t.out | grep LOAD | tail -n 1 > %t.load
# RUN: llvm-nm %t.out >> %t.load
# RUN: FileCheck %s < %t.load

## Check that llvm-bolt correctly updates _end symbol to match the end of the
## last loadable segment.
Expand Down
45 changes: 45 additions & 0 deletions bolt/test/X86/infer-fall-throughs.s
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
5 changes: 3 additions & 2 deletions bolt/test/X86/instrumentation-eh_frame_hdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
// RUN: %clangxx %cxxflags -static -Wl,-q %s -o %t.exe -Wl,--entry=_start
// RUN: llvm-bolt %t.exe -o %t.instr -instrument \
// RUN: --instrumentation-file=%t.fdata -instrumentation-sleep-time=1
// RUN: (llvm-readelf -SW %t.instr | grep -v bolt; llvm-readelf -lW %t.instr | \
// RUN: grep LOAD | tail -n 1) | FileCheck %s
// RUN: llvm-readelf -SW %t.instr | grep -v bolt > %t.sections
// RUN: llvm-readelf -lW %t.instr | grep LOAD | tail -n 1 >> %t.sections
// RUN: FileCheck %s < %t.sections

// CHECK: {{.*}} .eh_frame_hdr PROGBITS [[#%x, EH_ADDR:]]
// CHECK: LOAD 0x[[#%x, LD_OFFSET:]] 0x[[#%x, LD_VADDR:]] 0x[[#%x, LD_FSIZE:]]
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/TUScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@ DebouncePolicy::compute(llvm::ArrayRef<clock::duration> History) const {
// Base the result on the median rebuild.
// nth_element needs a mutable array, take the chance to bound the data size.
History = History.take_back(15);
llvm::SmallVector<clock::duration, 15> Recent(History.begin(), History.end());
llvm::SmallVector<clock::duration, 15> Recent(History);
auto *Median = Recent.begin() + Recent.size() / 2;
std::nth_element(Recent.begin(), Median, Recent.end());

Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/include-cleaner/lib/WalkAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,11 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
}

bool VisitCXXNewExpr(CXXNewExpr *E) {
report(E->getExprLoc(), E->getOperatorNew());
report(E->getExprLoc(), E->getOperatorNew(), RefType::Ambiguous);
return true;
}
bool VisitCXXDeleteExpr(CXXDeleteExpr *E) {
report(E->getExprLoc(), E->getOperatorDelete());
report(E->getExprLoc(), E->getOperatorDelete(), RefType::Ambiguous);
return true;
}
};
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,9 @@ TEST(WalkAST, FriendDecl) {
}

TEST(WalkAST, OperatorNewDelete) {
testWalk("void* $explicit^operator new(decltype(sizeof(int)), void*);",
testWalk("void* $ambiguous^operator new(decltype(sizeof(int)), void*);",
"struct Bar { void foo() { Bar b; ^new (&b) Bar; } };");
testWalk("struct A { static void $explicit^operator delete(void*); };",
testWalk("struct A { static void $ambiguous^operator delete(void*); };",
"void foo() { A a; ^delete &a; }");
}
} // namespace
Expand Down
6 changes: 4 additions & 2 deletions clang/cmake/caches/CrossWinToARMLinux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ endif()

message(STATUS "Toolchain target to build: ${LLVM_TARGETS_TO_BUILD}")

# Allow to override libc++ ABI version. Use 2 by default.
# Allow to override libc++ ABI version (1 is default).
if (NOT DEFINED LIBCXX_ABI_VERSION)
set(LIBCXX_ABI_VERSION 2)
set(LIBCXX_ABI_VERSION 1)
endif()

message(STATUS "Toolchain's Libc++ ABI version: ${LIBCXX_ABI_VERSION}")
Expand Down Expand Up @@ -217,6 +217,8 @@ set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_SHARED
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ABI_VERSION ${LIBCXX_ABI_VERSION} CACHE STRING "")
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_CXX_ABI "libcxxabi" CACHE STRING "") #!!!
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
# Merge libc++ and libc++abi libraries into the single libc++ library file.
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")

# Avoid searching for the python3 interpreter during the runtimes configuration for the cross builds.
# It starts searching the python3 package using the target's sysroot path, that usually is not compatible with the build host.
Expand Down
51 changes: 36 additions & 15 deletions clang/docs/ClangFormatStyleOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ the configuration (without a prefix: ``Auto``).
**AllowAllParametersOfDeclarationOnNextLine** (``Boolean``) :versionbadge:`clang-format 3.3` :ref:`<AllowAllParametersOfDeclarationOnNextLine>`
If the function declaration doesn't fit on a line,
allow putting all parameters of a function declaration onto
the next line even if ``BinPackParameters`` is ``false``.
the next line even if ``BinPackParameters`` is ``OnePerLine``.

.. code-block:: c++

Expand Down Expand Up @@ -2067,20 +2067,41 @@ the configuration (without a prefix: ``Auto``).

.. _BinPackParameters:

**BinPackParameters** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`<BinPackParameters>`
If ``false``, a function declaration's or function definition's
parameters will either all be on the same line or will have one line each.
**BinPackParameters** (``BinPackParametersStyle``) :versionbadge:`clang-format 3.7` :ref:`<BinPackParameters>`
The bin pack parameters style to use.

.. code-block:: c++
Possible values:

* ``BPPS_BinPack`` (in configuration: ``BinPack``)
Bin-pack parameters.

.. code-block:: c++

void f(int a, int bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
int ccccccccccccccccccccccccccccccccccccccccccc);

* ``BPPS_OnePerLine`` (in configuration: ``OnePerLine``)
Put all parameters on the current line if they fit.
Otherwise, put each one on its own line.

.. code-block:: c++

void f(int a, int b, int c);

void f(int a,
int b,
int ccccccccccccccccccccccccccccccccccccc);

* ``BPPS_AlwaysOnePerLine`` (in configuration: ``AlwaysOnePerLine``)
Always put each parameter on its own line.

.. code-block:: c++

void f(int a,
int b,
int c);

true:
void f(int aaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}

false:
void f(int aaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}

.. _BitFieldColonSpacing:

Expand Down Expand Up @@ -4817,7 +4838,7 @@ the configuration (without a prefix: ``Auto``).
items into as few lines as possible when they go over ``ColumnLimit``.

If ``Auto`` (the default), delegates to the value in
``BinPackParameters``. If that is ``true``, bin-packs Objective-C
``BinPackParameters``. If that is ``BinPack``, bin-packs Objective-C
protocol conformance list items into as few lines as possible
whenever they go over ``ColumnLimit``.

Expand All @@ -4831,13 +4852,13 @@ the configuration (without a prefix: ``Auto``).

.. code-block:: objc
Always (or Auto, if BinPackParameters=true):
Always (or Auto, if BinPackParameters==BinPack):
@interface ccccccccccccc () <
ccccccccccccc, ccccccccccccc,
ccccccccccccc, ccccccccccccc> {
}
Never (or Auto, if BinPackParameters=false):
Never (or Auto, if BinPackParameters!=BinPack):
@interface ddddddddddddd () <
ddddddddddddd,
ddddddddddddd,
Expand Down
85 changes: 85 additions & 0 deletions clang/docs/RealtimeSanitizer.rst
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>)
Loading

0 comments on commit f0747cd

Please sign in to comment.