Skip to content

Commit 785cd8c

Browse files
authored
Merge branch 'llvm:main' into telemetry_flag
2 parents e6fa138 + eacbcbe commit 785cd8c

File tree

146 files changed

+3490
-1266
lines changed

Some content is hidden

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

146 files changed

+3490
-1266
lines changed

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/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
//===----------------------------------------------------------------------===//

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,20 @@ def CIR_PointerType : CIR_Type<"Pointer", "ptr",
266266
}];
267267
}
268268

269+
//===----------------------------------------------------------------------===//
270+
// BoolType
271+
//===----------------------------------------------------------------------===//
272+
273+
def CIR_BoolType :
274+
CIR_Type<"Bool", "bool",
275+
[DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
276+
277+
let summary = "CIR bool type";
278+
let description = [{
279+
`cir.bool` represents C++ bool type.
280+
}];
281+
}
282+
269283
//===----------------------------------------------------------------------===//
270284
// FuncType
271285
//===----------------------------------------------------------------------===//
@@ -355,7 +369,8 @@ def VoidPtr : Type<
355369
//===----------------------------------------------------------------------===//
356370

357371
def CIR_AnyType : AnyTypeOf<[
358-
CIR_VoidType, CIR_IntType, CIR_AnyFloat, CIR_PointerType, CIR_FuncType
372+
CIR_VoidType, CIR_BoolType, CIR_IntType, CIR_AnyFloat, CIR_PointerType,
373+
CIR_FuncType
359374
]>;
360375

361376
#endif // MLIR_CIR_DIALECT_CIR_TYPES

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/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
5858
cgf.getLoc(e->getExprLoc()), type,
5959
builder.getAttr<cir::IntAttr>(type, e->getValue()));
6060
}
61+
62+
mlir::Value VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *e) {
63+
mlir::Type type = cgf.convertType(e->getType());
64+
return builder.create<cir::ConstantOp>(
65+
cgf.getLoc(e->getExprLoc()), type,
66+
builder.getCIRBoolAttr(e->getValue()));
67+
}
6168
};
6269
} // namespace
6370

0 commit comments

Comments
 (0)