Skip to content

Commit 03a80db

Browse files
committed
Merge branch 'pr/xqccmp-assembly' into pr/riscv-xqccmp-codegen
2 parents 9e24cf9 + 009a1cb commit 03a80db

File tree

427 files changed

+15975
-8514
lines changed

Some content is hidden

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

427 files changed

+15975
-8514
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/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: 17 additions & 4 deletions
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,16 +125,22 @@ 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

131-
if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
132-
set_final_stage_var(LLVM_USE_STATIC_ZSTD "ON" BOOL)
133-
endif()
146+
set_final_stage_var(LLVM_USE_STATIC_ZSTD "ON" BOOL)

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/AST/Decl.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5045,15 +5045,26 @@ class HLSLBufferDecl final : public NamedDecl, public DeclContext {
50455045
// LayoutStruct - Layout struct for the buffer
50465046
CXXRecordDecl *LayoutStruct;
50475047

5048+
// For default (implicit) constant buffer, an array of references of global
5049+
// decls that belong to the buffer. The decls are already parented by the
5050+
// translation unit context. The array is allocated by the ASTContext
5051+
// allocator in HLSLBufferDecl::CreateDefaultCBuffer.
5052+
ArrayRef<Decl *> DefaultBufferDecls;
5053+
50485054
HLSLBufferDecl(DeclContext *DC, bool CBuffer, SourceLocation KwLoc,
50495055
IdentifierInfo *ID, SourceLocation IDLoc,
50505056
SourceLocation LBrace);
50515057

5058+
void setDefaultBufferDecls(ArrayRef<Decl *> Decls);
5059+
50525060
public:
50535061
static HLSLBufferDecl *Create(ASTContext &C, DeclContext *LexicalParent,
50545062
bool CBuffer, SourceLocation KwLoc,
50555063
IdentifierInfo *ID, SourceLocation IDLoc,
50565064
SourceLocation LBrace);
5065+
static HLSLBufferDecl *
5066+
CreateDefaultCBuffer(ASTContext &C, DeclContext *LexicalParent,
5067+
ArrayRef<Decl *> DefaultCBufferDecls);
50575068
static HLSLBufferDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
50585069

50595070
SourceRange getSourceRange() const override LLVM_READONLY {
@@ -5079,6 +5090,28 @@ class HLSLBufferDecl final : public NamedDecl, public DeclContext {
50795090
return static_cast<HLSLBufferDecl *>(const_cast<DeclContext *>(DC));
50805091
}
50815092

5093+
// Iterator for the buffer decls. For constant buffers explicitly declared
5094+
// with `cbuffer` keyword this will the list of decls parented by this
5095+
// HLSLBufferDecl (equal to `decls()`).
5096+
// For implicit $Globals buffer this will be the list of default buffer
5097+
// declarations stored in DefaultBufferDecls plus the implicit layout
5098+
// struct (the only child of HLSLBufferDecl in this case).
5099+
//
5100+
// The iterator uses llvm::concat_iterator to concatenate the lists
5101+
// `decls()` and `DefaultBufferDecls`. For non-default buffers
5102+
// `DefaultBufferDecls` is always empty.
5103+
using buffer_decl_iterator =
5104+
llvm::concat_iterator<Decl *const, SmallVector<Decl *>::const_iterator,
5105+
decl_iterator>;
5106+
using buffer_decl_range = llvm::iterator_range<buffer_decl_iterator>;
5107+
5108+
buffer_decl_range buffer_decls() const {
5109+
return buffer_decl_range(buffer_decls_begin(), buffer_decls_end());
5110+
}
5111+
buffer_decl_iterator buffer_decls_begin() const;
5112+
buffer_decl_iterator buffer_decls_end() const;
5113+
bool buffer_decls_empty();
5114+
50825115
friend class ASTDeclReader;
50835116
friend class ASTDeclWriter;
50845117
};

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);

0 commit comments

Comments
 (0)