Skip to content

Commit 50cb3b7

Browse files
authored
Merge branch 'main' into scmp
2 parents b994cdc + e9c9adc commit 50cb3b7

File tree

331 files changed

+7081
-3665
lines changed

Some content is hidden

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

331 files changed

+7081
-3665
lines changed

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include "llvm/CodeGen/DIE.h"
2121
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
2222
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
23-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
2423
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
24+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
2525
#include "llvm/Support/Allocator.h"
2626

2727
#include <list>

bolt/lib/Core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
set(LLVM_LINK_COMPONENTS
22
DebugInfoDWARF
3+
DebugInfoDWARFLowLevel
34
Demangle
45
MC
56
MCDisassembler

bolt/lib/Core/DIEBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
#include "llvm/CodeGen/DIE.h"
1515
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
1616
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
17-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
1817
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
1918
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
2019
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
2120
#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
21+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
2222
#include "llvm/Support/Casting.h"
2323
#include "llvm/Support/Debug.h"
2424
#include "llvm/Support/ErrorHandling.h"

bolt/lib/Core/DebugNames.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
#include "bolt/Core/DebugNames.h"
1010
#include "bolt/Core/BinaryContext.h"
11-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
1211
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
12+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
1313
#include "llvm/Support/EndianStream.h"
1414
#include "llvm/Support/LEB128.h"
1515
#include <cstdint>

bolt/lib/Rewrite/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
set(LLVM_LINK_COMPONENTS
22
Core
33
DebugInfoDWARF
4+
DebugInfoDWARFLowLevel
45
JITLink
56
MC
67
Object

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
2525
#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
2626
#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
27-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
2827
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
2928
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
3029
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
30+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
3131
#include "llvm/MC/MCAsmBackend.h"
3232
#include "llvm/MC/MCAssembler.h"
3333
#include "llvm/MC/MCObjectWriter.h"

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4190,6 +4190,11 @@ void RewriteInstance::patchELFPHDRTable() {
41904190
NewWritableSegmentSize = NextAvailableAddress - NewWritableSegmentAddress;
41914191
}
41924192

4193+
if (!NewTextSegmentSize && !NewWritableSegmentSize) {
4194+
BC->outs() << "BOLT-INFO: not adding new segments\n";
4195+
return;
4196+
}
4197+
41934198
const uint64_t SavedPos = OS.tell();
41944199
OS.seek(PHDRTableOffset);
41954200

bolt/test/program-header.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Check that llvm-bolt does not add new segments when writing code in-place.
2+
3+
REQUIRES: system-linux
4+
5+
RUN: %clang %cflags %p/Inputs/hello.c -o %t -no-pie -Wl,-q
6+
RUN: llvm-bolt %t -o %t.bolt --use-old-text --align-functions=1 \
7+
RUN: --no-huge-pages --align-text=1 --use-gnu-stack \
8+
RUN: | FileCheck %s --check-prefix=CHECK-BOLT
9+
RUN: llvm-readelf -WS %t.bolt | FileCheck %s
10+
11+
CHECK-BOLT: rewriting .eh_frame_hdr in-place
12+
CHECK-BOLT: not adding new segments
13+
14+
CHECK-NOT: .bolt.org.eh_frame_hdr

bolt/utils/llvm-bolt-wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def get_cfg(key):
7979

8080

8181
# perf2bolt mode
82-
PERF2BOLT_MODE = ["-aggregate-only", "-ignore-build-id"]
82+
PERF2BOLT_MODE = ["-aggregate-only", "-ignore-build-id", "-show-density"]
8383

8484
# boltdiff mode
8585
BOLTDIFF_MODE = ["-diff-only", "-o", "/dev/null"]

clang/docs/ReleaseNotes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,13 @@ Improvements to Clang's diagnostics
649649
#GH69470, #GH59391, #GH58172, #GH46215, #GH45915, #GH45891, #GH44490,
650650
#GH36703, #GH32903, #GH23312, #GH69874.
651651

652+
- Clang now avoids issuing `-Wreturn-type` warnings in some cases where
653+
the final statement of a non-void function is a `throw` expression, or
654+
a call to a function that is trivially known to always throw (i.e., its
655+
body consists solely of a `throw` statement). This avoids certain
656+
false positives in exception-heavy code, though only simple patterns
657+
are currently recognized.
658+
652659

653660
Improvements to Clang's time-trace
654661
----------------------------------

clang/include/clang/Basic/Attr.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,13 @@ def AnalyzerNoReturn : InheritableAttr {
965965
let Documentation = [Undocumented];
966966
}
967967

968+
def InferredNoReturn : InheritableAttr {
969+
let Spellings = [];
970+
let SemaHandler = 0;
971+
let Subjects = SubjectList<[Function], ErrorDiag>;
972+
let Documentation = [InternalOnly];
973+
}
974+
968975
def Annotate : InheritableParamOrStmtAttr {
969976
let Spellings = [Clang<"annotate">];
970977
let Args = [StringArgument<"Annotation">, VariadicExprArgument<"Args">];

clang/include/clang/Basic/Module.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ struct ASTFileSignature : std::array<uint8_t, 20> {
6464

6565
explicit operator bool() const { return *this != BaseT({{0}}); }
6666

67+
// Support implicit cast to ArrayRef. Note that ASTFileSignature::size
68+
// prevents implicit cast to ArrayRef because one of the implicit constructors
69+
// of ArrayRef requires access to BaseT::size.
70+
operator ArrayRef<uint8_t>() const { return ArrayRef<uint8_t>(data(), size); }
71+
6772
/// Returns the value truncated to the size of an uint64_t.
6873
uint64_t truncatedValue() const {
6974
uint64_t Value = 0;

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,17 @@ def FPAttr : CIR_Attr<"FP", "fp", [TypedAttrInterface]> {
160160
value of the specified floating-point type. Supporting only CIR FP types.
161161
}];
162162
let parameters = (ins
163-
AttributeSelfTypeParameter<"", "::cir::CIRFPTypeInterface">:$type,
163+
AttributeSelfTypeParameter<"", "::cir::FPTypeInterface">:$type,
164164
APFloatParameter<"">:$value
165165
);
166166
let builders = [
167167
AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
168168
"const llvm::APFloat &":$value), [{
169-
return $_get(type.getContext(), mlir::cast<CIRFPTypeInterface>(type),
170-
value);
169+
return $_get(type.getContext(), mlir::cast<FPTypeInterface>(type), value);
171170
}]>,
172171
AttrBuilder<(ins "mlir::Type":$type,
173172
"const llvm::APFloat &":$value), [{
174-
return $_get($_ctxt, mlir::cast<CIRFPTypeInterface>(type), value);
173+
return $_get($_ctxt, mlir::cast<FPTypeInterface>(type), value);
175174
}]>,
176175
];
177176
let extraClassDeclaration = [{

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,8 @@ def FuncOp : CIR_Op<"func", [
17721772
OptionalAttr<StrAttr>:$sym_visibility,
17731773
UnitAttr:$comdat,
17741774
OptionalAttr<DictArrayAttr>:$arg_attrs,
1775-
OptionalAttr<DictArrayAttr>:$res_attrs);
1775+
OptionalAttr<DictArrayAttr>:$res_attrs,
1776+
OptionalAttr<FlatSymbolRefAttr>:$aliasee);
17761777

17771778
let regions = (region AnyRegion:$body);
17781779

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "mlir/IR/BuiltinAttributes.h"
1717
#include "mlir/IR/Types.h"
1818
#include "mlir/Interfaces/DataLayoutInterfaces.h"
19-
#include "clang/CIR/Interfaces/CIRFPTypeInterface.h"
19+
#include "clang/CIR/Interfaces/CIRTypeInterfaces.h"
2020

2121
namespace cir {
2222

@@ -26,6 +26,15 @@ struct RecordTypeStorage;
2626

2727
bool isValidFundamentalIntWidth(unsigned width);
2828

29+
/// Returns true if the type is a CIR sized type.
30+
///
31+
/// Types are sized if they implement SizedTypeInterface and
32+
/// return true from its method isSized.
33+
///
34+
/// Unsized types are those that do not have a size, such as
35+
/// void, or abstract types.
36+
bool isSized(mlir::Type ty);
37+
2938
} // namespace cir
3039

3140
//===----------------------------------------------------------------------===//

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

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
include "clang/CIR/Dialect/IR/CIRDialect.td"
1717
include "clang/CIR/Dialect/IR/CIRTypeConstraints.td"
18-
include "clang/CIR/Interfaces/CIRFPTypeInterface.td"
18+
include "clang/CIR/Interfaces/CIRTypeInterfaces.td"
1919
include "mlir/Interfaces/DataLayoutInterfaces.td"
2020
include "mlir/IR/AttrTypeBase.td"
2121

@@ -33,8 +33,10 @@ class CIR_Type<string name, string typeMnemonic, list<Trait> traits = [],
3333
// IntType
3434
//===----------------------------------------------------------------------===//
3535

36-
def CIR_IntType : CIR_Type<"Int", "int",
37-
[DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
36+
def CIR_IntType : CIR_Type<"Int", "int", [
37+
DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
38+
DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>
39+
]> {
3840
let summary = "Integer type with arbitrary precision up to a fixed limit";
3941
let description = [{
4042
CIR type that represents integer types with arbitrary precision, including
@@ -82,7 +84,8 @@ def CIR_IntType : CIR_Type<"Int", "int",
8284

8385
class CIR_FloatType<string name, string mnemonic> : CIR_Type<name, mnemonic, [
8486
DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
85-
DeclareTypeInterfaceMethods<CIRFPTypeInterface>
87+
DeclareTypeInterfaceMethods<CIR_FPTypeInterface>,
88+
DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>
8689
]>;
8790

8891
def CIR_Single : CIR_FloatType<"Single", "float"> {
@@ -165,9 +168,10 @@ def CIR_LongDouble : CIR_FloatType<"LongDouble", "long_double"> {
165168
// ComplexType
166169
//===----------------------------------------------------------------------===//
167170

168-
def CIR_ComplexType : CIR_Type<"Complex", "complex",
169-
[DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
170-
171+
def CIR_ComplexType : CIR_Type<"Complex", "complex", [
172+
DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
173+
DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>
174+
]> {
171175
let summary = "CIR complex type";
172176
let description = [{
173177
CIR type that represents a C complex number. `cir.complex` models the C type
@@ -215,12 +219,13 @@ def CIR_ComplexType : CIR_Type<"Complex", "complex",
215219
// PointerType
216220
//===----------------------------------------------------------------------===//
217221

218-
def CIR_PointerType : CIR_Type<"Pointer", "ptr",
219-
[DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
220-
222+
def CIR_PointerType : CIR_Type<"Pointer", "ptr", [
223+
DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
224+
DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>
225+
]> {
221226
let summary = "CIR pointer type";
222227
let description = [{
223-
The `cir.ptr` type represents C and C++ pointer types and C++ reference
228+
The `!cir.ptr` type represents C and C++ pointer types and C++ reference
224229
types, other than pointers-to-members. The `pointee` type is the type
225230
pointed to.
226231

@@ -279,26 +284,27 @@ def CIR_PointerType : CIR_Type<"Pointer", "ptr",
279284
// BoolType
280285
//===----------------------------------------------------------------------===//
281286

282-
def CIR_BoolType :
283-
CIR_Type<"Bool", "bool",
284-
[DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
285-
287+
def CIR_BoolType : CIR_Type<"Bool", "bool", [
288+
DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
289+
DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>
290+
]> {
286291
let summary = "CIR bool type";
287292
let description = [{
288-
`cir.bool` represents C++ bool type.
293+
`!cir.bool` represents C++ bool type.
289294
}];
290295
}
291296

292297
//===----------------------------------------------------------------------===//
293298
// ArrayType
294299
//===----------------------------------------------------------------------===//
295300

296-
def CIR_ArrayType : CIR_Type<"Array", "array",
297-
[DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
298-
301+
def CIR_ArrayType : CIR_Type<"Array", "array", [
302+
DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
303+
DeclareTypeInterfaceMethods<CIR_SizedTypeInterface, ["isSized"]>,
304+
]> {
299305
let summary = "CIR array type";
300306
let description = [{
301-
`CIR.array` represents C/C++ constant arrays.
307+
`!cir.array` represents C/C++ constant arrays.
302308
}];
303309

304310
let parameters = (ins "mlir::Type":$elementType, "uint64_t":$size);
@@ -314,15 +320,22 @@ def CIR_ArrayType : CIR_Type<"Array", "array",
314320
let assemblyFormat = [{
315321
`<` $elementType `x` $size `>`
316322
}];
323+
324+
let extraClassDefinition = [{
325+
bool $cppClass::isSized() const {
326+
return ::cir::isSized(getElementType());
327+
}
328+
}];
317329
}
318330

319331
//===----------------------------------------------------------------------===//
320332
// VectorType (fixed size)
321333
//===----------------------------------------------------------------------===//
322334

323-
def CIR_VectorType : CIR_Type<"Vector", "vector",
324-
[DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
325-
335+
def CIR_VectorType : CIR_Type<"Vector", "vector", [
336+
DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
337+
DeclareTypeInterfaceMethods<CIR_SizedTypeInterface, ["isSized"]>,
338+
]> {
326339
let summary = "CIR vector type";
327340
let description = [{
328341
The `!cir.vector` type represents a fixed-size, one-dimensional vector.
@@ -363,6 +376,12 @@ def CIR_VectorType : CIR_Type<"Vector", "vector",
363376
}]>,
364377
];
365378

379+
let extraClassDefinition = [{
380+
bool $cppClass::isSized() const {
381+
return ::cir::isSized(getElementType());
382+
}
383+
}];
384+
366385
let genVerifyDecl = 1;
367386
}
368387

@@ -459,11 +478,11 @@ def CIR_VoidType : CIR_Type<"Void", "void"> {
459478
// The base type for all RecordDecls.
460479
//===----------------------------------------------------------------------===//
461480

462-
def CIR_RecordType : CIR_Type<"Record", "record",
463-
[
464-
DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
465-
MutableType,
466-
]> {
481+
def CIR_RecordType : CIR_Type<"Record", "record", [
482+
DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
483+
DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>,
484+
MutableType,
485+
]> {
467486
let summary = "CIR record type";
468487
let description = [{
469488
Each unique clang::RecordDecl is mapped to a `cir.record` and any object in

clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h renamed to clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
//
77
//===---------------------------------------------------------------------===//
88
//
9-
// Defines the interface to generically handle CIR floating-point types.
9+
// Defines cir type interfaces.
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#ifndef LLVM_CLANG_INCLUDE_CLANG_CIR_INTERFACES_CIRFPTYPEINTERFACE_H
14-
#define LLVM_CLANG_INCLUDE_CLANG_CIR_INTERFACES_CIRFPTYPEINTERFACE_H
13+
#ifndef CLANG_CIR_INTERFACES_CIRTYPEINTERFACES_H
14+
#define CLANG_CIR_INTERFACES_CIRTYPEINTERFACES_H
1515

1616
#include "mlir/IR/Types.h"
1717
#include "llvm/ADT/APFloat.h"
1818

1919
/// Include the tablegen'd interface declarations.
20-
#include "clang/CIR/Interfaces/CIRFPTypeInterface.h.inc"
20+
#include "clang/CIR/Interfaces/CIRTypeInterfaces.h.inc"
2121

22-
#endif // LLVM_CLANG_INCLUDE_CLANG_CIR_INTERFACES_CIRFPTYPEINTERFACE_H
22+
#endif // CLANG_CIR_INTERFACES_CIRTYPEINTERFACES_H

0 commit comments

Comments
 (0)