Skip to content

Commit a52579f

Browse files
author
z1.cciauto
committed
merge main into amd-staging
2 parents f876d2b + eacbcbe commit a52579f

File tree

216 files changed

+6884
-4892
lines changed

Some content is hidden

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

216 files changed

+6884
-4892
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

bolt/test/X86/entry-point-fallthru.s

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/Maintainers.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ Clang static analyzer
136136
137137
| Balázs Benics
138138
| benicsbalazs\@gmail.com (email), steakhal (Phabricator), steakhal (GitHub)
139+
| balazs.benics\@sonarsource.com (email), balazs-benics-sonarsource (GitHub)
139140
140141
Compiler options
141142
~~~~~~~~~~~~~~~~

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/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#define LLVM_CLANG_CIR_DIALECT_BUILDER_CIRBASEBUILDER_H
1111

1212
#include "clang/CIR/Dialect/IR/CIRAttrs.h"
13+
#include "clang/CIR/Dialect/IR/CIRDialect.h"
14+
#include "clang/CIR/Dialect/IR/CIRTypes.h"
1315

1416
#include "mlir/IR/Builders.h"
1517
#include "mlir/IR/BuiltinTypes.h"
@@ -23,6 +25,14 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
2325
CIRBaseBuilderTy(mlir::MLIRContext &mlirContext)
2426
: mlir::OpBuilder(&mlirContext) {}
2527

28+
cir::ConstantOp getBool(bool state, mlir::Location loc) {
29+
return create<cir::ConstantOp>(loc, getBoolTy(), getCIRBoolAttr(state));
30+
}
31+
cir::ConstantOp getFalse(mlir::Location loc) { return getBool(false, loc); }
32+
cir::ConstantOp getTrue(mlir::Location loc) { return getBool(true, loc); }
33+
34+
cir::BoolType getBoolTy() { return cir::BoolType::get(getContext()); }
35+
2636
cir::PointerType getPointerTo(mlir::Type ty) {
2737
return cir::PointerType::get(getContext(), ty);
2838
}
@@ -31,6 +41,10 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
3141
return getPointerTo(cir::VoidType::get(getContext()));
3242
}
3343

44+
cir::BoolAttr getCIRBoolAttr(bool state) {
45+
return cir::BoolAttr::get(getContext(), getBoolTy(), state);
46+
}
47+
3448
mlir::TypedAttr getConstPtrAttr(mlir::Type type, int64_t value) {
3549
auto valueAttr = mlir::IntegerAttr::get(
3650
mlir::IntegerType::get(type.getContext(), 64), value);

clang/include/clang/CIR/Dialect/IR/CIRAttrs.td

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,25 @@ class CIRUnitAttr<string name, string attrMnemonic, list<Trait> traits = []>
3535
let isOptional = 1;
3636
}
3737

38+
//===----------------------------------------------------------------------===//
39+
// BoolAttr
40+
//===----------------------------------------------------------------------===//
41+
42+
def CIR_BoolAttr : CIR_Attr<"Bool", "bool", [TypedAttrInterface]> {
43+
let summary = "Represent true/false for !cir.bool types";
44+
let description = [{
45+
The BoolAttr represents a 'true' or 'false' value.
46+
}];
47+
48+
let parameters = (ins AttributeSelfTypeParameter<
49+
"", "cir::BoolType">:$type,
50+
"bool":$value);
51+
52+
let assemblyFormat = [{
53+
`<` $value `>`
54+
}];
55+
}
56+
3857
//===----------------------------------------------------------------------===//
3958
// IntegerAttr
4059
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)