Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Automatic merge of https://github.com/llvm/llvm-project main into cla…
Browse files Browse the repository at this point in the history
…ngd-powerpc (2023-11-22 05-04)
  • Loading branch information
BenjaminGrayNp1 committed Nov 22, 2023
2 parents a57f122 + 2c87571 commit 2a22d2a
Show file tree
Hide file tree
Showing 402 changed files with 29,215 additions and 14,573 deletions.
48 changes: 46 additions & 2 deletions .github/workflows/release-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,52 @@ jobs:
fi
bash .github/workflows/set-release-binary-outputs.sh "${{ github.actor }}" "$tag" "$upload"
# Try to get around the 6 hour timeout by first running a job to fill
# the build cache.
fill-cache:
name: "Fill Cache ${{ matrix.os }}"
needs: prepare
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-22.04
steps:
- name: Checkout LLVM
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref_name }}

- name: Install Ninja
uses: llvm/actions/install-ninja@main

- name: Setup sccache
uses: hendrikmuhs/ccache-action@v1
with:
max-size: 250M
key: sccache-${{ matrix.os }}-release
variant: sccache

- name: Build Clang
run: |
cmake -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_BUILD_TYPE=Release -DCMAKE_ENABLE_ASSERTIONS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLLVM_ENABLE_PROJECTS=clang -S llvm -B build
ninja -v -C build
build-binaries:
name: ${{ matrix.target.triple }}
permissions:
contents: write # To upload assets to release.
needs: prepare
needs:
- prepare
- fill-cache
runs-on: ${{ matrix.target.runs-on }}
strategy:
fail-fast: false
matrix:
target:
- triple: x86_64-linux-gnu-ubuntu-22.04
os: ubuntu-22.04
runs-on: ubuntu-22.04-16x64
debian-build-deps: >
chrpath
Expand All @@ -81,6 +116,14 @@ jobs:
ref: ${{ needs.prepare.outputs.ref }}
path: ${{ needs.prepare.outputs.build-dir }}/llvm-project

- name: Setup sccache
uses: hendrikmuhs/ccache-action@v1
with:
max-size: 250M
key: sccache-${{ matrix.target.os }}-release
save: false
variant: sccache

- name: Install Brew build dependencies
if: matrix.target.brew-build-deps != ''
run: brew install ${{ matrix.target.brew-build-deps }}
Expand All @@ -102,7 +145,8 @@ jobs:
-triple ${{ matrix.target.triple }} \
-use-ninja \
-no-checkout \
-no-test-suite
-no-test-suite \
-configure-flags "-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
- name: Upload binaries
if: ${{ always() && needs.prepare.outputs.upload == 'true' }}
Expand Down
3 changes: 3 additions & 0 deletions bolt/include/bolt/Core/BinaryContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,9 @@ class BinaryContext {
/// Return true if the function should be emitted to the output file.
bool shouldEmit(const BinaryFunction &Function) const;

/// Dump the assembly representation of MCInst to debug output.
void dump(const MCInst &Inst) const;

/// Print the string name for a CFI operation.
static void printCFI(raw_ostream &OS, const MCCFIInstruction &Inst);

Expand Down
9 changes: 9 additions & 0 deletions bolt/lib/Core/BinaryContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1738,6 +1738,15 @@ bool BinaryContext::shouldEmit(const BinaryFunction &Function) const {
return HasRelocations || Function.isSimple();
}

void BinaryContext::dump(const MCInst &Inst) const {
if (LLVM_UNLIKELY(!InstPrinter)) {
dbgs() << "Cannot dump for InstPrinter is not initialized.\n";
return;
}
InstPrinter->printInst(&Inst, 0, "", *STI, dbgs());
dbgs() << "\n";
}

void BinaryContext::printCFI(raw_ostream &OS, const MCCFIInstruction &Inst) {
uint32_t Operation = Inst.getOperation();
switch (Operation) {
Expand Down
10 changes: 4 additions & 6 deletions bolt/lib/Passes/ValidateInternalCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,18 +281,16 @@ bool ValidateInternalCalls::analyzeFunction(BinaryFunction &Function) const {
LLVM_DEBUG({
dbgs() << "Detected out-of-range PIC reference in " << Function
<< "\nReturn address load: ";
BC.InstPrinter->printInst(TargetInst, 0, "", *BC.STI, dbgs());
dbgs() << "\nUse: ";
BC.InstPrinter->printInst(&Use, 0, "", *BC.STI, dbgs());
dbgs() << "\n";
BC.dump(*TargetInst);
dbgs() << "Use: ";
BC.dump(Use);
Function.dump();
});
return false;
}
LLVM_DEBUG({
dbgs() << "Validated access: ";
BC.InstPrinter->printInst(&Use, 0, "", *BC.STI, dbgs());
dbgs() << "\n";
BC.dump(Use);
});
}
if (!UseDetected) {
Expand Down
4 changes: 2 additions & 2 deletions bolt/lib/Profile/YAMLProfileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static llvm::cl::opt<bool>
llvm::cl::opt<bool> ProfileUseDFS("profile-use-dfs",
cl::desc("use DFS order for YAML profile"),
cl::Hidden, cl::cat(BoltOptCategory));
}
} // namespace opts

namespace llvm {
namespace bolt {
Expand Down Expand Up @@ -354,7 +354,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
matchProfileToFunction(YamlBF, Function);
}

for (auto &[CommonName, LTOProfiles]: LTOCommonNameMap) {
for (const auto &[CommonName, LTOProfiles] : LTOCommonNameMap) {
if (!LTOCommonNameFunctionMap.contains(CommonName))
continue;
std::unordered_set<BinaryFunction *> &Functions =
Expand Down
4 changes: 4 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,10 @@ Static Analyzer
- Added a new checker ``core.BitwiseShift`` which reports situations where
bitwise shift operators produce undefined behavior (because some operand is
negative or too large).

- Move checker ``alpha.unix.Errno`` out of the ``alpha`` package
to ``unix.Errno``.

- Move checker ``alpha.unix.StdCLibraryFunctions`` out of the ``alpha`` package
to ``unix.StdCLibraryFunctions``.

Expand Down
142 changes: 71 additions & 71 deletions clang/docs/analyzer/checkers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,76 @@ Check calls to various UNIX/Posix functions: ``open, pthread_once, calloc, mallo
.. literalinclude:: checkers/unix_api_example.c
:language: c
.. _unix-Errno:
unix.Errno (C)
""""""""""""""
Check for improper use of ``errno``.
This checker implements partially CERT rule
`ERR30-C. Set errno to zero before calling a library function known to set errno,
and check errno only after the function returns a value indicating failure
<https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152351>`_.
The checker can find the first read of ``errno`` after successful standard
function calls.
The C and POSIX standards often do not define if a standard library function
may change value of ``errno`` if the call does not fail.
Therefore, ``errno`` should only be used if it is known from the return value
of a function that the call has failed.
There are exceptions to this rule (for example ``strtol``) but the affected
functions are not yet supported by the checker.
The return values for the failure cases are documented in the standard Linux man
pages of the functions and in the `POSIX standard <https://pubs.opengroup.org/onlinepubs/9699919799/>`_.
.. code-block:: c
int unsafe_errno_read(int sock, void *data, int data_size) {
if (send(sock, data, data_size, 0) != data_size) {
// 'send' can be successful even if not all data was sent
if (errno == 1) { // An undefined value may be read from 'errno'
return 0;
}
}
return 1;
}
The checker :ref:`unix-StdCLibraryFunctions` must be turned on to get the
warnings from this checker. The supported functions are the same as by
:ref:`unix-StdCLibraryFunctions`. The ``ModelPOSIX`` option of that
checker affects the set of checked functions.
**Parameters**
The ``AllowErrnoReadOutsideConditionExpressions`` option allows read of the
errno value if the value is not used in a condition (in ``if`` statements,
loops, conditional expressions, ``switch`` statements). For example ``errno``
can be stored into a variable without getting a warning by the checker.
.. code-block:: c
int unsafe_errno_read(int sock, void *data, int data_size) {
if (send(sock, data, data_size, 0) != data_size) {
int err = errno;
// warning if 'AllowErrnoReadOutsideConditionExpressions' is false
// no warning if 'AllowErrnoReadOutsideConditionExpressions' is true
}
return 1;
}
Default value of this option is ``true``. This allows save of the errno value
for possible later error handling.
**Limitations**
- Only the very first usage of ``errno`` is checked after an affected function
call. Value of ``errno`` is not followed when it is stored into a variable
or returned from a function.
- Documentation of function ``lseek`` is not clear about what happens if the
function returns different value than the expected file position but not -1.
To avoid possible false-positives ``errno`` is allowed to be used in this
case.
.. _unix-Malloc:
unix.Malloc (C)
Expand Down Expand Up @@ -1098,7 +1168,7 @@ state of the value ``errno`` if applicable to the analysis. Many system
functions set the ``errno`` value only if an error occurs (together with a
specific return value of the function), otherwise it becomes undefined. This
checker changes the analysis state to contain such information. This data is
used by other checkers, for example :ref:`alpha-unix-Errno`.
used by other checkers, for example :ref:`unix-Errno`.
**Limitations**
Expand Down Expand Up @@ -2826,76 +2896,6 @@ Check improper use of chroot.
f(); // warn: no call of chdir("/") immediately after chroot
}
.. _alpha-unix-Errno:
alpha.unix.Errno (C)
""""""""""""""""""""
Check for improper use of ``errno``.
This checker implements partially CERT rule
`ERR30-C. Set errno to zero before calling a library function known to set errno,
and check errno only after the function returns a value indicating failure
<https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152351>`_.
The checker can find the first read of ``errno`` after successful standard
function calls.
The C and POSIX standards often do not define if a standard library function
may change value of ``errno`` if the call does not fail.
Therefore, ``errno`` should only be used if it is known from the return value
of a function that the call has failed.
There are exceptions to this rule (for example ``strtol``) but the affected
functions are not yet supported by the checker.
The return values for the failure cases are documented in the standard Linux man
pages of the functions and in the `POSIX standard <https://pubs.opengroup.org/onlinepubs/9699919799/>`_.
.. code-block:: c
int unsafe_errno_read(int sock, void *data, int data_size) {
if (send(sock, data, data_size, 0) != data_size) {
// 'send' can be successful even if not all data was sent
if (errno == 1) { // An undefined value may be read from 'errno'
return 0;
}
}
return 1;
}
The checker :ref:`unix-StdCLibraryFunctions` must be turned on to get the
warnings from this checker. The supported functions are the same as by
:ref:`unix-StdCLibraryFunctions`. The ``ModelPOSIX`` option of that
checker affects the set of checked functions.
**Parameters**
The ``AllowErrnoReadOutsideConditionExpressions`` option allows read of the
errno value if the value is not used in a condition (in ``if`` statements,
loops, conditional expressions, ``switch`` statements). For example ``errno``
can be stored into a variable without getting a warning by the checker.
.. code-block:: c
int unsafe_errno_read(int sock, void *data, int data_size) {
if (send(sock, data, data_size, 0) != data_size) {
int err = errno;
// warning if 'AllowErrnoReadOutsideConditionExpressions' is false
// no warning if 'AllowErrnoReadOutsideConditionExpressions' is true
}
return 1;
}
Default value of this option is ``true``. This allows save of the errno value
for possible later error handling.
**Limitations**
- Only the very first usage of ``errno`` is checked after an affected function
call. Value of ``errno`` is not followed when it is stored into a variable
or returned from a function.
- Documentation of function ``lseek`` is not clear about what happens if the
function returns different value than the expected file position but not -1.
To avoid possible false-positives ``errno`` is allowed to be used in this
case.
.. _alpha-unix-PthreadLock:
alpha.unix.PthreadLock (C)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,6 @@ class Environment {
/// Record a fact that must be true if this point in the program is reached.
void assume(const Formula &);

/// Deprecated synonym for `assume()`.
void addToFlowCondition(const Formula &F) { assume(F); }

/// Returns true if the formula is always true when this point is reached.
/// Returns false if the formula may be false (or the flow condition isn't
/// sufficiently precise to prove that it is true) or if the solver times out.
Expand All @@ -563,9 +560,6 @@ class Environment {
/// (or the flow condition is overly constraining) or if the solver times out.
bool allows(const Formula &) const;

/// Deprecated synonym for `proves()`.
bool flowConditionImplies(const Formula &F) const { return proves(F); }

/// Returns the `DeclContext` of the block being analysed, if any. Otherwise,
/// returns null.
const DeclContext *getDeclCtx() const { return CallStack.back(); }
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -6701,7 +6701,7 @@ def ArmSmeStreamingCompatibleDocs : Documentation {
let Category = DocCatArmSmeAttributes;
let Content = [{
The ``__arm_streaming_compatible`` keyword applies to prototyped function types and
specifies that the function has a streaming compatible interface. This
specifies that the function has a "streaming compatible interface". This
means that:

* the function may be entered in either non-streaming mode (PSTATE.SM=0) or
Expand Down Expand Up @@ -7495,7 +7495,7 @@ a **coroutine return type (CRT)**.

A function ``R func(P1, .., PN)`` has a coroutine return type (CRT) ``R`` if ``R``
is marked by ``[[clang::coro_return_type]]`` and ``R`` has a promise type associated to it
(i.e., std​::​coroutine_traits<R, P1, .., PN>​::​promise_type is a valid promise type).
(i.e., std::coroutine_traits<R, P1, .., PN>::promise_type is a valid promise type).

If the return type of a function is a ``CRT`` then the function must be a coroutine.
Otherwise the program is invalid. It is allowed for a non-coroutine to return a ``CRT``
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/DiagnosticParseKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ def warn_pragma_acc_unimplemented_clause_parsing
: Warning<"OpenACC clause parsing not yet implemented">,
InGroup<SourceUsesOpenACC>;
def err_acc_invalid_directive
: Error<"invalid OpenACC directive '%0'">;
: Error<"invalid OpenACC directive '%select{%1|%1 %2}0'">;
def err_acc_missing_directive : Error<"expected OpenACC directive">;

// OpenMP support.
Expand Down
Loading

0 comments on commit 2a22d2a

Please sign in to comment.