Skip to content

Commit 3cd4eb1

Browse files
committed
merge main into amd-staging
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
2 parents 5dbcd5b + 2f0661c commit 3cd4eb1

File tree

646 files changed

+23777
-7807
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

646 files changed

+23777
-7807
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,42 @@ jobs:
191191
**/CMakeError.log
192192
**/CMakeOutput.log
193193
**/crash_diagnostics/*
194+
195+
macos:
196+
runs-on: macos-14
197+
needs: [ stage1 ]
198+
strategy:
199+
fail-fast: true
200+
matrix:
201+
config: [
202+
generic-cxx03,
203+
generic-cxx23,
204+
generic-modules,
205+
apple-configuration
206+
]
207+
steps:
208+
- uses: actions/checkout@v4
209+
- uses: maxim-lobanov/setup-xcode@v1
210+
with:
211+
xcode-version: 'latest-stable'
212+
- uses: seanmiddleditch/gha-setup-ninja@master
213+
- name: Build and test
214+
run: |
215+
python3 -m venv .venv
216+
source .venv/bin/activate
217+
python -m pip install psutil
218+
bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
219+
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
220+
if: always() # Upload artifacts even if the build or test suite fails
221+
with:
222+
name: macos-${{ matrix.config }}-results
223+
path: |
224+
**/test-results.xml
225+
**/*.abilist
226+
**/CMakeError.log
227+
**/CMakeOutput.log
228+
**/crash_diagnostics/*
229+
194230
windows:
195231
runs-on: windows-2022
196232
needs: [ stage1 ]

.github/workflows/release-asset-audit.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
import github
22
import sys
33

4+
_SPECIAL_CASE_BINARIES = {
5+
"keith": {"clang+llvm-18.1.8-arm64-apple-macos11.tar.xz"},
6+
}
7+
8+
9+
def _is_valid(uploader_name, valid_uploaders, asset_name):
10+
if uploader_name in valid_uploaders:
11+
return True
12+
13+
if uploader_name in _SPECIAL_CASE_BINARIES:
14+
return asset_name in _SPECIAL_CASE_BINARIES[uploader_name]
15+
16+
return False
17+
18+
419
def main():
520
token = sys.argv[1]
621

@@ -41,7 +56,7 @@ def main():
4156
print(
4257
f"{asset.name} : {asset.uploader.login} [{created_at} {updated_at}] ( {asset.download_count} )"
4358
)
44-
if asset.uploader.login not in uploaders:
59+
if not _is_valid(asset.uploader.login, uploaders, asset.name):
4560
with open('comment', 'w') as file:
4661
file.write(f'@{asset.uploader.login} is not a valid uploader.')
4762
sys.exit(1)

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,8 @@ class BinaryFunction {
16921692

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

1695+
void setPreserveNops(bool Value) { PreserveNops = Value; }
1696+
16951697
BinaryFunction &setUsesGnuArgsSize(bool Uses = true) {
16961698
UsesGnuArgsSize = Uses;
16971699
return *this;

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,22 +1339,10 @@ Error BinaryFunction::disassemble() {
13391339
BC.getBinaryFunctionContainingAddress(TargetAddress))
13401340
TargetFunc->setIgnored();
13411341

1342-
if (IsCall && containsAddress(TargetAddress)) {
1343-
if (TargetAddress == getAddress()) {
1344-
// Recursive call.
1345-
TargetSymbol = getSymbol();
1346-
} else {
1347-
if (BC.isX86()) {
1348-
// Dangerous old-style x86 PIC code. We may need to freeze this
1349-
// function, so preserve the function as is for now.
1350-
PreserveNops = true;
1351-
} else {
1352-
BC.errs() << "BOLT-WARNING: internal call detected at 0x"
1353-
<< Twine::utohexstr(AbsoluteInstrAddr)
1354-
<< " in function " << *this << ". Skipping.\n";
1355-
IsSimple = false;
1356-
}
1357-
}
1342+
if (IsCall && TargetAddress == getAddress()) {
1343+
// A recursive call. Calls to internal blocks are handled by
1344+
// ValidateInternalCalls pass.
1345+
TargetSymbol = getSymbol();
13581346
}
13591347

13601348
if (!TargetSymbol) {

bolt/lib/Passes/ValidateInternalCalls.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,24 +302,27 @@ bool ValidateInternalCalls::analyzeFunction(BinaryFunction &Function) const {
302302
}
303303

304304
Error ValidateInternalCalls::runOnFunctions(BinaryContext &BC) {
305-
if (!BC.isX86())
306-
return Error::success();
307-
308305
// Look for functions that need validation. This should be pretty rare.
309306
std::set<BinaryFunction *> NeedsValidation;
310307
for (auto &BFI : BC.getBinaryFunctions()) {
311308
BinaryFunction &Function = BFI.second;
312309
for (BinaryBasicBlock &BB : Function) {
313310
for (MCInst &Inst : BB) {
314311
if (getInternalCallTarget(Function, Inst)) {
312+
BC.errs() << "BOLT-WARNING: internal call detected in function "
313+
<< Function << '\n';
315314
NeedsValidation.insert(&Function);
316315
Function.setSimple(false);
316+
Function.setPreserveNops(true);
317317
break;
318318
}
319319
}
320320
}
321321
}
322322

323+
if (!BC.isX86())
324+
return Error::success();
325+
323326
// Skip validation for non-relocation mode
324327
if (!BC.HasRelocations)
325328
return Error::success();

bolt/test/AArch64/internal-call.s

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
## Test that llvm-bolt detects internal calls and marks the containing function
2+
## as non-simple.
3+
4+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
5+
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -static
6+
# RUN: llvm-bolt %t.exe -o %t.null --print-all 2>&1 | FileCheck %s
7+
8+
# CHECK: Binary Function "_start" after building cfg
9+
# CHECK: internal call detected in function _start
10+
# CHECK-NOT: Binary Function "_start" after validate-internal-calls
11+
12+
.text
13+
.globl _start
14+
.type _start, %function
15+
_start:
16+
.cfi_startproc
17+
.LBB00:
18+
mov x11, #0x1fff
19+
cmp x1, x11
20+
b.hi .Ltmp1
21+
22+
.entry1:
23+
movi v4.16b, #0x0
24+
movi v5.16b, #0x0
25+
subs x1, x1, #0x8
26+
b.lo .Ltmp2
27+
28+
.entry2:
29+
ld1 { v2.2d, v3.2d }, [x0], #32
30+
ld1 { v0.2d, v1.2d }, [x0], #32
31+
32+
.Ltmp2:
33+
uaddlp v4.4s, v4.8h
34+
uaddlp v4.2d, v4.4s
35+
mov x0, v4.d[0]
36+
mov x1, v4.d[1]
37+
add x0, x0, x1
38+
ret x30
39+
40+
.Ltmp1:
41+
mov x8, x30
42+
43+
.Lloop:
44+
add x5, x0, x9
45+
mov x1, #0xface
46+
movi v4.16b, #0x0
47+
movi v5.16b, #0x0
48+
bl .entry2
49+
add x4, x4, x0
50+
mov x0, x5
51+
sub x7, x7, x10
52+
cmp x7, x11
53+
b.hi .Lloop
54+
55+
mov x1, x7
56+
bl .entry1
57+
add x0, x4, x0
58+
mov x30, x8
59+
ret x30
60+
61+
.cfi_endproc
62+
.size _start, .-_start
63+
64+
## Force relocation mode.
65+
.reloc 0, R_AARCH64_NONE

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ Attribute Changes in Clang
225225
- ``[[clang::lifetimebound]]`` is now explicitly disallowed on explicit object member functions
226226
where they were previously silently ignored.
227227

228+
- Clang now automatically adds ``[[clang::lifetimebound]]`` to the parameters of
229+
``std::span, std::string_view`` constructors, this enables Clang to capture
230+
more cases where the returned reference outlives the object.
231+
(#GH100567)
232+
228233
Improvements to Clang's diagnostics
229234
-----------------------------------
230235

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

327333
Bug Fixes to AST Handling
328334
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/analyzer/checkers.rst

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ if ((y = make_int())) {
571571
nullability
572572
^^^^^^^^^^^
573573
574-
Objective C checkers that warn for null pointer passing and dereferencing errors.
574+
Checkers (mostly Objective C) that warn for null pointer passing and dereferencing errors.
575575
576576
.. _nullability-NullPassedToNonnull:
577577
@@ -588,8 +588,8 @@ Warns when a null pointer is passed to a pointer which has a _Nonnull type.
588588
589589
.. _nullability-NullReturnedFromNonnull:
590590
591-
nullability.NullReturnedFromNonnull (ObjC)
592-
""""""""""""""""""""""""""""""""""""""""""
591+
nullability.NullReturnedFromNonnull (C, C++, ObjC)
592+
""""""""""""""""""""""""""""""""""""""""""""""""""
593593
Warns when a null pointer is returned from a function that has _Nonnull return type.
594594
595595
.. code-block:: objc
@@ -604,6 +604,22 @@ Warns when a null pointer is returned from a function that has _Nonnull return t
604604
return result;
605605
}
606606
607+
Warns when a null pointer is returned from a function annotated with ``__attribute__((returns_nonnull))``
608+
609+
.. code-block:: cpp
610+
611+
int global;
612+
__attribute__((returns_nonnull)) void* getPtr(void* p);
613+
614+
void* getPtr(void* p) {
615+
if (p) { // forgot to negate the condition
616+
return &global;
617+
}
618+
// Warning: nullptr returned from a function that is expected
619+
// to return a non-null value
620+
return p;
621+
}
622+
607623
.. _nullability-NullableDereferenced:
608624
609625
nullability.NullableDereferenced (ObjC)

clang/include/clang/ExtractAPI/DeclarationFragments.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,9 @@ class DeclarationFragmentsBuilder {
411411
/// Build DeclarationFragments for a macro.
412412
///
413413
/// \param Name name of the macro.
414-
/// \param MD the associated MacroDirective.
414+
/// \param MI the associated MacroInfo.
415415
static DeclarationFragments getFragmentsForMacro(StringRef Name,
416-
const MacroDirective *MD);
416+
const MacroInfo *MI);
417417

418418
/// Build DeclarationFragments for a typedef \p TypedefNameDecl.
419419
static DeclarationFragments

clang/include/clang/ExtractAPI/ExtractAPIVisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class ExtractAPIVisitorBase : public RecursiveASTVisitor<Derived> {
213213

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

218218
return {};
219219
}

clang/include/clang/Sema/Initialization.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,11 @@ class InitializationSequence {
13841384

13851385
void AddParenthesizedListInitStep(QualType T);
13861386

1387+
/// Only used when initializing structured bindings from an array with
1388+
/// direct-list-initialization. Unwrap the initializer list to get the array
1389+
/// for array copy.
1390+
void AddUnwrapInitListInitStep(InitListExpr *Syntactic);
1391+
13871392
/// Add steps to unwrap a initializer list for a reference around a
13881393
/// single element and rewrap it at the end.
13891394
void RewrapReferenceInitList(QualType T, InitListExpr *Syntactic);

clang/include/clang/Sema/Sema.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,6 +1806,9 @@ class Sema final : public SemaBase {
18061806
/// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
18071807
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record);
18081808

1809+
/// Add [[clang:::lifetimebound]] attr for std:: functions and methods.
1810+
void inferLifetimeBoundAttribute(FunctionDecl *FD);
1811+
18091812
/// Add [[gsl::Pointer]] attributes for std:: types.
18101813
void inferGslPointerAttribute(TypedefNameDecl *TD);
18111814

clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file defines CheckerVisitor.
9+
// This file defines various utilities used by checkers.
1010
//
1111
//===----------------------------------------------------------------------===//
1212

@@ -114,6 +114,10 @@ OperatorKind operationKindFromOverloadedOperator(OverloadedOperatorKind OOK,
114114

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

117+
/// Returns true if declaration \p D is in std namespace or any nested namespace
118+
/// or class scope.
119+
bool isWithinStdNamespace(const Decl *D);
120+
117121
} // namespace ento
118122

119123
} // namespace clang

clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,10 @@ class ExprEngine {
286286
const Stmt *DiagnosticStmt = nullptr,
287287
ProgramPoint::Kind K = ProgramPoint::PreStmtPurgeDeadSymbolsKind);
288288

289+
/// A tag to track convenience transitions, which can be removed at cleanup.
290+
/// This tag applies to a node created after removeDead.
291+
static const ProgramPointTag *cleanupNodeTag();
292+
289293
/// processCFGElement - Called by CoreEngine. Used to generate new successor
290294
/// nodes by processing the 'effects' of a CFG element.
291295
void processCFGElement(const CFGElement E, ExplodedNode *Pred,

clang/lib/AST/ComputeDependence.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ ExprDependence clang::computeDependence(BinaryOperator *E) {
164164
ExprDependence clang::computeDependence(ConditionalOperator *E) {
165165
// The type of the conditional operator depends on the type of the conditional
166166
// to support the GCC vector conditional extension. Additionally,
167-
// [temp.dep.expr] does specify state that this should be dependent on ALL sub
167+
// [temp.dep.expr] does specify that this should be dependent on ALL sub
168168
// expressions.
169169
return E->getCond()->getDependence() | E->getLHS()->getDependence() |
170170
E->getRHS()->getDependence();

clang/lib/ExtractAPI/DeclarationFragments.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,14 +1327,12 @@ DeclarationFragmentsBuilder::getFragmentsForFunctionTemplateSpecialization(
13271327

13281328
DeclarationFragments
13291329
DeclarationFragmentsBuilder::getFragmentsForMacro(StringRef Name,
1330-
const MacroDirective *MD) {
1330+
const MacroInfo *MI) {
13311331
DeclarationFragments Fragments;
13321332
Fragments.append("#define", DeclarationFragments::FragmentKind::Keyword)
13331333
.appendSpace();
13341334
Fragments.append(Name, DeclarationFragments::FragmentKind::Identifier);
13351335

1336-
auto *MI = MD->getMacroInfo();
1337-
13381336
if (MI->isFunctionLike()) {
13391337
Fragments.append("(", DeclarationFragments::FragmentKind::Text);
13401338
unsigned numParameters = MI->getNumParams();

0 commit comments

Comments
 (0)