Skip to content

Commit 62f73a7

Browse files
authored
Merge branch 'main' into main
2 parents a924776 + f22291c commit 62f73a7

File tree

191 files changed

+6588
-4788
lines changed

Some content is hidden

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

191 files changed

+6588
-4788
lines changed

.github/workflows/release-binaries.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ jobs:
142142
# 2-3 hours to build on macOS, much slower than on Linux.
143143
# The long build time causes the release build to time out on x86_64,
144144
# so we need to disable flang there.
145-
target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_PROJECTS='clang;lld;lldb;clang-tools-extra;bolt;polly;mlir'"
145+
target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_PROJECTS='clang;lld;lldb;clang-tools-extra;polly;mlir'"
146146
fi
147147
target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_ARCHS=$arches -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_BUILTIN_ARCHS=$arches"
148148
fi

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "bolt/Core/DynoStats.h"
1616
#include "bolt/Core/HashUtilities.h"
1717
#include "bolt/Core/MCPlusBuilder.h"
18+
#include "bolt/Utils/CommandLineOpts.h"
1819
#include "bolt/Utils/NameResolver.h"
1920
#include "bolt/Utils/NameShortener.h"
2021
#include "bolt/Utils/Utils.h"
@@ -1753,8 +1754,8 @@ void BinaryFunction::postProcessEntryPoints() {
17531754
// In non-relocation mode there's potentially an external undetectable
17541755
// reference to the entry point and hence we cannot move this entry
17551756
// point. Optimizing without moving could be difficult.
1756-
// In BAT mode, register any known entry points for CFG construction.
1757-
if (!BC.HasRelocations && !BC.HasBATSection)
1757+
// In aggregation, register any known entry points for CFG construction.
1758+
if (!BC.HasRelocations && !opts::AggregateOnly)
17581759
setSimple(false);
17591760

17601761
const uint32_t Offset = KV.first;

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,9 +831,10 @@ bool DataAggregator::doTrace(const LBREntry &First, const LBREntry &Second,
831831
ParentFunc = FromFunc;
832832
ParentFunc->SampleCountInBytes += Count * (Second.From - First.To);
833833

834+
const uint64_t FuncAddress = FromFunc->getAddress();
834835
std::optional<BoltAddressTranslation::FallthroughListTy> FTs =
835-
BAT ? BAT->getFallthroughsInTrace(FromFunc->getAddress(), First.To,
836-
Second.From)
836+
BAT && BAT->isBATFunction(FuncAddress)
837+
? BAT->getFallthroughsInTrace(FuncAddress, First.To, Second.From)
837838
: getFallthroughsInTrace(*FromFunc, First, Second, Count);
838839
if (!FTs) {
839840
LLVM_DEBUG(

bolt/test/X86/bolt-address-translation-yaml.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ YAML-BAT-CHECK-NEXT: - bid: 0
6161
YAML-BAT-CHECK-NEXT: insns: 26
6262
YAML-BAT-CHECK-NEXT: hash: 0xA900AE79CFD40000
6363
YAML-BAT-CHECK-NEXT: succ: [ { bid: 3, cnt: 0 }, { bid: 1, cnt: 0 } ]
64+
# Check fallthroughs in non-BAT function
65+
YAML-BAT-CHECK-NEXT: - bid: 27
66+
YAML-BAT-CHECK-NEXT: insns: 3
67+
YAML-BAT-CHECK-NEXT: hash: 0x30A1EBA77A903F0
68+
YAML-BAT-CHECK-NEXT: succ: [ { bid: 28, cnt: 1 } ]
6469
# Calls from no-BAT to BAT function
6570
YAML-BAT-CHECK: - bid: 28
6671
YAML-BAT-CHECK-NEXT: insns: 13
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Checks that fallthroughs spanning entry points are accepted in aggregation
2+
## mode.
3+
4+
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
5+
# RUN: ld.lld %t.o -o %t
6+
# RUN: link_fdata %s %t %t.preagg PREAGG
7+
# RUN: perf2bolt %t -p %t.preagg --pa -o %t.fdata | FileCheck %s
8+
# CHECK: traces mismatching disassembled function contents: 0
9+
10+
.globl main
11+
main:
12+
.cfi_startproc
13+
vmovaps %zmm31,%zmm3
14+
15+
next:
16+
add $0x4,%r9
17+
add $0x40,%r10
18+
dec %r14
19+
Ljmp:
20+
jne main
21+
# PREAGG: T #Ljmp# #main# #Ljmp# 1
22+
ret
23+
.cfi_endproc
24+
.size main,.-main

clang/cmake/caches/Release.cmake

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,21 @@ endfunction()
2929
# cache file to CMake via -C. e.g.
3030
#
3131
# cmake -D LLVM_RELEASE_ENABLE_PGO=ON -C Release.cmake
32+
33+
set (DEFAULT_PROJECTS "clang;lld;lldb;clang-tools-extra;polly;mlir;flang")
34+
# bolt only supports ELF, so only enable it for Linux.
35+
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
36+
list(APPEND DEFAULT_PROJECTS "bolt")
37+
endif()
38+
3239
set (DEFAULT_RUNTIMES "compiler-rt;libcxx")
3340
if (NOT WIN32)
3441
list(APPEND DEFAULT_RUNTIMES "libcxxabi" "libunwind")
3542
endif()
3643
set(LLVM_RELEASE_ENABLE_LTO THIN CACHE STRING "")
3744
set(LLVM_RELEASE_ENABLE_PGO ON CACHE BOOL "")
3845
set(LLVM_RELEASE_ENABLE_RUNTIMES ${DEFAULT_RUNTIMES} CACHE STRING "")
39-
set(LLVM_RELEASE_ENABLE_PROJECTS "clang;lld;lldb;clang-tools-extra;bolt;polly;mlir;flang" CACHE STRING "")
46+
set(LLVM_RELEASE_ENABLE_PROJECTS ${DEFAULT_PROJECTS} CACHE STRING "")
4047
# Note we don't need to add install here, since it is one of the pre-defined
4148
# steps.
4249
set(LLVM_RELEASE_FINAL_STAGE_TARGETS "clang;package;check-all;check-llvm;check-clang" CACHE STRING "")
@@ -118,13 +125,21 @@ if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
118125
set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -static-libgcc")
119126
endif()
120127

128+
# Set flags for bolt
129+
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
130+
set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -Wl,--emit-relocs,-znow")
131+
endif()
132+
121133
set_instrument_and_final_stage_var(CMAKE_EXE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
122134
set_instrument_and_final_stage_var(CMAKE_SHARED_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
123135
set_instrument_and_final_stage_var(CMAKE_MODULE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
124136

125137
# Final Stage Config (stage2)
126138
set_final_stage_var(LLVM_ENABLE_RUNTIMES "${LLVM_RELEASE_ENABLE_RUNTIMES}" STRING)
127139
set_final_stage_var(LLVM_ENABLE_PROJECTS "${LLVM_RELEASE_ENABLE_PROJECTS}" STRING)
140+
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
141+
set_final_stage_var(CLANG_BOLT "INSTRUMENT" STRING)
142+
endif()
128143
set_final_stage_var(CPACK_GENERATOR "TXZ" STRING)
129144
set_final_stage_var(CPACK_ARCHIVE_THREADS "0" STRING)
130145

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ Removed Compiler Flags
124124

125125
Attribute Changes in Clang
126126
--------------------------
127+
Adding [[clang::unsafe_buffer_usage]] attribute to a method definition now turns off all -Wunsafe-buffer-usage
128+
related warnings within the method body.
127129

128130
- The ``no_sanitize`` attribute now accepts both ``gnu`` and ``clang`` names.
129131
- Clang now diagnoses use of declaration attributes on void parameters. (#GH108819)

clang/lib/Basic/Targets/SPIR.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ class LLVM_LIBRARY_VISIBILITY SPIRV64AMDGCNTargetInfo final
399399
HasLegalHalfType = true;
400400
HasFloat16 = true;
401401
HalfArgsAndReturns = true;
402+
403+
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
402404
}
403405

404406
bool hasBFloat16Type() const override { return true; }

clang/lib/Sema/AnalysisBasedWarnings.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,6 +2566,9 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings(
25662566

25672567
// The Callback function that performs analyses:
25682568
auto CallAnalyzers = [&](const Decl *Node) -> void {
2569+
if (Node->hasAttr<UnsafeBufferUsageAttr>())
2570+
return;
2571+
25692572
// Perform unsafe buffer usage analysis:
25702573
if (!Diags.isIgnored(diag::warn_unsafe_buffer_operation,
25712574
Node->getBeginLoc()) ||

clang/lib/Sema/SemaChecking.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7390,10 +7390,11 @@ bool DecomposePrintfHandler::GetSpecifiers(
73907390
const char *Str = Data.data();
73917391
llvm::SmallBitVector BV;
73927392
UncoveredArgHandler UA;
7393+
const Expr *PrintfArgs[] = {FSL->getFormatString()};
73937394
DecomposePrintfHandler H(S, FSL, FSL->getFormatString(), Type, 0, 0, IsObjC,
7394-
Str, Sema::FAPK_Elsewhere, {FSL->getFormatString()},
7395-
0, InFunctionCall, Sema::VariadicDoesNotApply, BV,
7396-
UA, Args);
7395+
Str, Sema::FAPK_Elsewhere, PrintfArgs, 0,
7396+
InFunctionCall, Sema::VariadicDoesNotApply, BV, UA,
7397+
Args);
73977398

73987399
if (!analyze_format_string::ParsePrintfString(
73997400
H, Str, Str + Data.size(), S.getLangOpts(), S.Context.getTargetInfo(),
@@ -7402,7 +7403,7 @@ bool DecomposePrintfHandler::GetSpecifiers(
74027403
if (H.HadError)
74037404
return false;
74047405

7405-
std::sort(
7406+
std::stable_sort(
74067407
Args.begin(), Args.end(),
74077408
[](const EquatableFormatArgument &A, const EquatableFormatArgument &B) {
74087409
return A.getPosition() < B.getPosition();

0 commit comments

Comments
 (0)