Skip to content

Commit

Permalink
merge main into amd-staging
Browse files Browse the repository at this point in the history
reverts: Depend upon older [ctx_prof] reverts
73c3b73 [ctx_prof] Add support for ICP (llvm#105469)
1022323 [ctx_prof] Move the "from json" logic more centrally to reuse it from test. (llvm#106129)

Change-Id: I7579b15b8df14981afa399ca966aab0741e8637e
  • Loading branch information
mhalk committed Aug 28, 2024
2 parents 5dbcd5b + 2f0661c commit 3cd4eb1
Show file tree
Hide file tree
Showing 646 changed files with 23,777 additions and 7,807 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/libcxx-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,42 @@ jobs:
**/CMakeError.log
**/CMakeOutput.log
**/crash_diagnostics/*
macos:
runs-on: macos-14
needs: [ stage1 ]
strategy:
fail-fast: true
matrix:
config: [
generic-cxx03,
generic-cxx23,
generic-modules,
apple-configuration
]
steps:
- uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 'latest-stable'
- uses: seanmiddleditch/gha-setup-ninja@master
- name: Build and test
run: |
python3 -m venv .venv
source .venv/bin/activate
python -m pip install psutil
bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
if: always() # Upload artifacts even if the build or test suite fails
with:
name: macos-${{ matrix.config }}-results
path: |
**/test-results.xml
**/*.abilist
**/CMakeError.log
**/CMakeOutput.log
**/crash_diagnostics/*
windows:
runs-on: windows-2022
needs: [ stage1 ]
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/release-asset-audit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
import github
import sys

_SPECIAL_CASE_BINARIES = {
"keith": {"clang+llvm-18.1.8-arm64-apple-macos11.tar.xz"},
}


def _is_valid(uploader_name, valid_uploaders, asset_name):
if uploader_name in valid_uploaders:
return True

if uploader_name in _SPECIAL_CASE_BINARIES:
return asset_name in _SPECIAL_CASE_BINARIES[uploader_name]

return False


def main():
token = sys.argv[1]

Expand Down Expand Up @@ -41,7 +56,7 @@ def main():
print(
f"{asset.name} : {asset.uploader.login} [{created_at} {updated_at}] ( {asset.download_count} )"
)
if asset.uploader.login not in uploaders:
if not _is_valid(asset.uploader.login, uploaders, asset.name):
with open('comment', 'w') as file:
file.write(f'@{asset.uploader.login} is not a valid uploader.')
sys.exit(1)
Expand Down
2 changes: 2 additions & 0 deletions bolt/include/bolt/Core/BinaryFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,8 @@ class BinaryFunction {

void setPseudo(bool Pseudo) { IsPseudo = Pseudo; }

void setPreserveNops(bool Value) { PreserveNops = Value; }

BinaryFunction &setUsesGnuArgsSize(bool Uses = true) {
UsesGnuArgsSize = Uses;
return *this;
Expand Down
20 changes: 4 additions & 16 deletions bolt/lib/Core/BinaryFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1339,22 +1339,10 @@ Error BinaryFunction::disassemble() {
BC.getBinaryFunctionContainingAddress(TargetAddress))
TargetFunc->setIgnored();

if (IsCall && containsAddress(TargetAddress)) {
if (TargetAddress == getAddress()) {
// Recursive call.
TargetSymbol = getSymbol();
} else {
if (BC.isX86()) {
// Dangerous old-style x86 PIC code. We may need to freeze this
// function, so preserve the function as is for now.
PreserveNops = true;
} else {
BC.errs() << "BOLT-WARNING: internal call detected at 0x"
<< Twine::utohexstr(AbsoluteInstrAddr)
<< " in function " << *this << ". Skipping.\n";
IsSimple = false;
}
}
if (IsCall && TargetAddress == getAddress()) {
// A recursive call. Calls to internal blocks are handled by
// ValidateInternalCalls pass.
TargetSymbol = getSymbol();
}

if (!TargetSymbol) {
Expand Down
9 changes: 6 additions & 3 deletions bolt/lib/Passes/ValidateInternalCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,24 +302,27 @@ bool ValidateInternalCalls::analyzeFunction(BinaryFunction &Function) const {
}

Error ValidateInternalCalls::runOnFunctions(BinaryContext &BC) {
if (!BC.isX86())
return Error::success();

// Look for functions that need validation. This should be pretty rare.
std::set<BinaryFunction *> NeedsValidation;
for (auto &BFI : BC.getBinaryFunctions()) {
BinaryFunction &Function = BFI.second;
for (BinaryBasicBlock &BB : Function) {
for (MCInst &Inst : BB) {
if (getInternalCallTarget(Function, Inst)) {
BC.errs() << "BOLT-WARNING: internal call detected in function "
<< Function << '\n';
NeedsValidation.insert(&Function);
Function.setSimple(false);
Function.setPreserveNops(true);
break;
}
}
}
}

if (!BC.isX86())
return Error::success();

// Skip validation for non-relocation mode
if (!BC.HasRelocations)
return Error::success();
Expand Down
65 changes: 65 additions & 0 deletions bolt/test/AArch64/internal-call.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
## Test that llvm-bolt detects internal calls and marks the containing function
## as non-simple.

# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -static
# RUN: llvm-bolt %t.exe -o %t.null --print-all 2>&1 | FileCheck %s

# CHECK: Binary Function "_start" after building cfg
# CHECK: internal call detected in function _start
# CHECK-NOT: Binary Function "_start" after validate-internal-calls

.text
.globl _start
.type _start, %function
_start:
.cfi_startproc
.LBB00:
mov x11, #0x1fff
cmp x1, x11
b.hi .Ltmp1

.entry1:
movi v4.16b, #0x0
movi v5.16b, #0x0
subs x1, x1, #0x8
b.lo .Ltmp2

.entry2:
ld1 { v2.2d, v3.2d }, [x0], #32
ld1 { v0.2d, v1.2d }, [x0], #32

.Ltmp2:
uaddlp v4.4s, v4.8h
uaddlp v4.2d, v4.4s
mov x0, v4.d[0]
mov x1, v4.d[1]
add x0, x0, x1
ret x30

.Ltmp1:
mov x8, x30

.Lloop:
add x5, x0, x9
mov x1, #0xface
movi v4.16b, #0x0
movi v5.16b, #0x0
bl .entry2
add x4, x4, x0
mov x0, x5
sub x7, x7, x10
cmp x7, x11
b.hi .Lloop

mov x1, x7
bl .entry1
add x0, x4, x0
mov x30, x8
ret x30

.cfi_endproc
.size _start, .-_start

## Force relocation mode.
.reloc 0, R_AARCH64_NONE
6 changes: 6 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ Attribute Changes in Clang
- ``[[clang::lifetimebound]]`` is now explicitly disallowed on explicit object member functions
where they were previously silently ignored.

- Clang now automatically adds ``[[clang::lifetimebound]]`` to the parameters of
``std::span, std::string_view`` constructors, this enables Clang to capture
more cases where the returned reference outlives the object.
(#GH100567)

Improvements to Clang's diagnostics
-----------------------------------

Expand Down Expand Up @@ -323,6 +328,7 @@ Bug Fixes to C++ Support
of the current instantiation in all cases.
- Fix evaluation of the index of dependent pack indexing expressions/types specifiers (#GH105900)
- Correctly handle subexpressions of an immediate invocation in the presence of implicit casts. (#GH105558)
- Clang now correctly handles direct-list-initialization of a structured bindings from an array. (#GH31813)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
22 changes: 19 additions & 3 deletions clang/docs/analyzer/checkers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ if ((y = make_int())) {
nullability
^^^^^^^^^^^

Objective C checkers that warn for null pointer passing and dereferencing errors.
Checkers (mostly Objective C) that warn for null pointer passing and dereferencing errors.

.. _nullability-NullPassedToNonnull:

Expand All @@ -588,8 +588,8 @@ Warns when a null pointer is passed to a pointer which has a _Nonnull type.

.. _nullability-NullReturnedFromNonnull:

nullability.NullReturnedFromNonnull (ObjC)
""""""""""""""""""""""""""""""""""""""""""
nullability.NullReturnedFromNonnull (C, C++, ObjC)
""""""""""""""""""""""""""""""""""""""""""""""""""
Warns when a null pointer is returned from a function that has _Nonnull return type.

.. code-block:: objc
Expand All @@ -604,6 +604,22 @@ Warns when a null pointer is returned from a function that has _Nonnull return t
return result;
}

Warns when a null pointer is returned from a function annotated with ``__attribute__((returns_nonnull))``

.. code-block:: cpp

int global;
__attribute__((returns_nonnull)) void* getPtr(void* p);

void* getPtr(void* p) {
if (p) { // forgot to negate the condition
return &global;
}
// Warning: nullptr returned from a function that is expected
// to return a non-null value
return p;
}

.. _nullability-NullableDereferenced:

nullability.NullableDereferenced (ObjC)
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/ExtractAPI/DeclarationFragments.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,9 @@ class DeclarationFragmentsBuilder {
/// Build DeclarationFragments for a macro.
///
/// \param Name name of the macro.
/// \param MD the associated MacroDirective.
/// \param MI the associated MacroInfo.
static DeclarationFragments getFragmentsForMacro(StringRef Name,
const MacroDirective *MD);
const MacroInfo *MI);

/// Build DeclarationFragments for a typedef \p TypedefNameDecl.
static DeclarationFragments
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class ExtractAPIVisitorBase : public RecursiveASTVisitor<Derived> {

StringRef getOwningModuleName(const Decl &D) {
if (auto *OwningModule = D.getImportedOwningModule())
return OwningModule->Name;
return OwningModule->getTopLevelModule()->Name;

return {};
}
Expand Down
5 changes: 5 additions & 0 deletions clang/include/clang/Sema/Initialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,11 @@ class InitializationSequence {

void AddParenthesizedListInitStep(QualType T);

/// Only used when initializing structured bindings from an array with
/// direct-list-initialization. Unwrap the initializer list to get the array
/// for array copy.
void AddUnwrapInitListInitStep(InitListExpr *Syntactic);

/// Add steps to unwrap a initializer list for a reference around a
/// single element and rewrap it at the end.
void RewrapReferenceInitList(QualType T, InitListExpr *Syntactic);
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -1806,6 +1806,9 @@ class Sema final : public SemaBase {
/// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record);

/// Add [[clang:::lifetimebound]] attr for std:: functions and methods.
void inferLifetimeBoundAttribute(FunctionDecl *FD);

/// Add [[gsl::Pointer]] attributes for std:: types.
void inferGslPointerAttribute(TypedefNameDecl *TD);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
//
// This file defines CheckerVisitor.
// This file defines various utilities used by checkers.
//
//===----------------------------------------------------------------------===//

Expand Down Expand Up @@ -114,6 +114,10 @@ OperatorKind operationKindFromOverloadedOperator(OverloadedOperatorKind OOK,

std::optional<SVal> getPointeeVal(SVal PtrSVal, ProgramStateRef State);

/// Returns true if declaration \p D is in std namespace or any nested namespace
/// or class scope.
bool isWithinStdNamespace(const Decl *D);

} // namespace ento

} // namespace clang
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ class ExprEngine {
const Stmt *DiagnosticStmt = nullptr,
ProgramPoint::Kind K = ProgramPoint::PreStmtPurgeDeadSymbolsKind);

/// A tag to track convenience transitions, which can be removed at cleanup.
/// This tag applies to a node created after removeDead.
static const ProgramPointTag *cleanupNodeTag();

/// processCFGElement - Called by CoreEngine. Used to generate new successor
/// nodes by processing the 'effects' of a CFG element.
void processCFGElement(const CFGElement E, ExplodedNode *Pred,
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ComputeDependence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ ExprDependence clang::computeDependence(BinaryOperator *E) {
ExprDependence clang::computeDependence(ConditionalOperator *E) {
// The type of the conditional operator depends on the type of the conditional
// to support the GCC vector conditional extension. Additionally,
// [temp.dep.expr] does specify state that this should be dependent on ALL sub
// [temp.dep.expr] does specify that this should be dependent on ALL sub
// expressions.
return E->getCond()->getDependence() | E->getLHS()->getDependence() |
E->getRHS()->getDependence();
Expand Down
4 changes: 1 addition & 3 deletions clang/lib/ExtractAPI/DeclarationFragments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1327,14 +1327,12 @@ DeclarationFragmentsBuilder::getFragmentsForFunctionTemplateSpecialization(

DeclarationFragments
DeclarationFragmentsBuilder::getFragmentsForMacro(StringRef Name,
const MacroDirective *MD) {
const MacroInfo *MI) {
DeclarationFragments Fragments;
Fragments.append("#define", DeclarationFragments::FragmentKind::Keyword)
.appendSpace();
Fragments.append(Name, DeclarationFragments::FragmentKind::Identifier);

auto *MI = MD->getMacroInfo();

if (MI->isFunctionLike()) {
Fragments.append("(", DeclarationFragments::FragmentKind::Text);
unsigned numParameters = MI->getNumParams();
Expand Down
Loading

0 comments on commit 3cd4eb1

Please sign in to comment.