Skip to content

Commit 016c242

Browse files
authored
merge main into amd-staging (llvm#734)
2 parents 6f54821 + 61a0f11 commit 016c242

File tree

167 files changed

+4303
-1455
lines changed

Some content is hidden

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

167 files changed

+4303
-1455
lines changed

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ namespace opts {
8080
extern cl::list<std::string> HotTextMoveSections;
8181
extern cl::opt<bool> Hugify;
8282
extern cl::opt<bool> Instrument;
83+
extern cl::opt<uint32_t> InstrumentationSleepTime;
8384
extern cl::opt<bool> KeepNops;
8485
extern cl::opt<bool> Lite;
8586
extern cl::list<std::string> PrintOnly;
@@ -1507,6 +1508,9 @@ Error RewriteInstance::discoverRtFiniAddress() {
15071508
}
15081509

15091510
if (!BC->FiniArrayAddress || !BC->FiniArraySize) {
1511+
// Missing fini hooks are allowed when instrumentation-sleep-time is in use.
1512+
if (opts::InstrumentationSleepTime > 0)
1513+
return Error::success();
15101514
return createStringError(
15111515
std::errc::not_supported,
15121516
"Instrumentation needs either DT_FINI or DT_FINI_ARRAY");
@@ -1616,9 +1620,13 @@ Error RewriteInstance::updateRtFiniReloc() {
16161620
if (!RT || !RT->getRuntimeFiniAddress())
16171621
return Error::success();
16181622

1619-
if (!BC->FiniArrayAddress || !BC->FiniArraySize)
1623+
if (!BC->FiniArrayAddress || !BC->FiniArraySize) {
1624+
// Missing fini hooks are allowed when instrumentation-sleep-time is in use.
1625+
if (opts::InstrumentationSleepTime > 0)
1626+
return Error::success();
16201627
return createStringError(std::errc::not_supported,
16211628
"inconsistent .fini_array state");
1629+
}
16221630

16231631
ErrorOr<BinarySection &> FiniArraySection =
16241632
BC->getSectionForAddress(*BC->FiniArrayAddress);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Test that BOLT will produce error by default and pass with instrumentation-sleep-time option
2+
3+
# REQUIRES: system-linux,bolt-runtime,target=aarch64{{.*}}
4+
5+
# RUN: llvm-mc -triple aarch64 -filetype=obj %s -o %t.o
6+
# RUN: ld.lld -q -pie -o %t.exe %t.o
7+
# RUN: llvm-readelf -d %t.exe | FileCheck --check-prefix=CHECK-NO-FINI %s
8+
# RUN: not llvm-bolt --instrument -o %t.out %t.exe 2>&1 | FileCheck %s --check-prefix=CHECK-BOLT-FAIL
9+
# RUN: llvm-bolt --instrument --instrumentation-sleep-time=1 -o %t.out %t.exe 2>&1 | FileCheck %s --check-prefix=CHECK-BOLT-PASS
10+
11+
# CHECK-NO-FINI: INIT
12+
# CHECK-NO-FINI-NOT: FINI
13+
# CHECK-NO-FINI-NOT: FINI_ARRAY
14+
15+
# CHECK-BOLT-FAIL: Instrumentation needs either DT_FINI or DT_FINI_ARRAY
16+
17+
# CHECK-BOLT-PASS-NOT: Instrumentation needs either DT_FINI or DT_FINI_ARRAY
18+
# CHECK-BOLT-PASS: runtime library initialization was hooked via DT_INIT
19+
20+
.text
21+
.globl _start
22+
.type _start, %function
23+
_start:
24+
# BOLT errs when instrumenting without relocations; create a dummy one.
25+
.reloc 0, R_AARCH64_NONE
26+
ret
27+
.size _start, .-_start
28+
29+
.globl _init
30+
.type _init, %function
31+
# Force DT_INIT to be created (needed for instrumentation).
32+
_init:
33+
ret
34+
.size _init, .-_init

bolt/test/X86/instrument-no-fini.s

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Test that BOLT will produce error by default and pass with instrumentation-sleep-time option
2+
3+
# REQUIRES: system-linux,bolt-runtime,target=x86_64-{{.*}}
4+
5+
# RUN: llvm-mc -triple x86_64 -filetype=obj %s -o %t.o
6+
# RUN: ld.lld -q -pie -o %t.exe %t.o
7+
# RUN: llvm-readelf -d %t.exe | FileCheck --check-prefix=CHECK-NO-FINI %s
8+
# RUN: not llvm-bolt --instrument -o %t.out %t.exe 2>&1 | FileCheck %s --check-prefix=CHECK-BOLT-FAIL
9+
# RUN: llvm-bolt --instrument --instrumentation-sleep-time=1 -o %t.out %t.exe 2>&1 | FileCheck %s --check-prefix=CHECK-BOLT-PASS
10+
11+
# CHECK-NO-FINI: INIT
12+
# CHECK-NO-FINI-NOT: FINI
13+
# CHECK-NO-FINI-NOT: FINI_ARRAY
14+
15+
# CHECK-BOLT-FAIL: Instrumentation needs either DT_FINI or DT_FINI_ARRAY
16+
17+
# CHECK-BOLT-PASS-NOT: Instrumentation needs either DT_FINI or DT_FINI_ARRAY
18+
# CHECK-BOLT-PASS: runtime library initialization was hooked via DT_INIT
19+
20+
.text
21+
.globl _start
22+
.type _start, %function
23+
_start:
24+
# BOLT errs when instrumenting without relocations; create a dummy one.
25+
.reloc 0, R_X86_64_NONE
26+
retq
27+
.size _start, .-_start
28+
29+
.globl _init
30+
.type _init, %function
31+
# Force DT_INIT to be created (needed for instrumentation).
32+
_init:
33+
retq
34+
.size _init, .-_init

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ Bug Fixes to C++ Support
806806
- Fix for clang incorrectly rejecting the default construction of a union with
807807
nontrivial member when another member has an initializer. (#GH81774)
808808
- Fixed a template depth issue when parsing lambdas inside a type constraint. (#GH162092)
809+
- Fix the support of zero-length arrays in SFINAE context. (#GH170040)
809810
- Diagnose unresolved overload sets in non-dependent compound requirements. (#GH51246) (#GH97753)
810811
- Fix a crash when extracting unavailable member type from alias in template deduction. (#GH165560)
811812
- Fix incorrect diagnostics for lambdas with init-captures inside braced initializers. (#GH163498)
@@ -890,6 +891,9 @@ RISC-V Support
890891
- `__GCC_CONSTRUCTIVE_SIZE` and `__GCC_DESTRUCTIVE_SIZE` are changed to 64. These values are
891892
unstable according to `Clang's documentation <https://clang.llvm.org/docs/LanguageExtensions.html#gcc-destructive-size-and-gcc-constructive-size>`_.
892893

894+
- DWARF fission is now compatible with linker relaxations, allowing `-gsplit-dwarf` and `-mrelax`
895+
to be used together when building for the RISC-V platform.
896+
893897
CUDA/HIP Language Changes
894898
^^^^^^^^^^^^^^^^^^^^^^^^^
895899

clang/include/clang/Basic/TokenKinds.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ inline bool isLiteral(TokenKind K) {
9898
const bool isInLiteralRange =
9999
K >= tok::numeric_constant && K <= tok::utf32_string_literal;
100100

101-
#if !NDEBUG
101+
#ifndef NDEBUG
102102
const bool isLiteralExplicit =
103103
K == tok::numeric_constant || K == tok::char_constant ||
104104
K == tok::wide_char_constant || K == tok::utf8_char_constant ||

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

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,44 +1085,10 @@ def CIR_TypeInfoAttr : CIR_Attr<"TypeInfo", "typeinfo", [TypedAttrInterface]> {
10851085
//===----------------------------------------------------------------------===//
10861086

10871087
def CIR_InlineKind : CIR_I32EnumAttr<"InlineKind", "inlineKind", [
1088-
I32EnumAttrCase<"NoInline", 1, "never">,
1089-
I32EnumAttrCase<"AlwaysInline", 2, "always">,
1090-
I32EnumAttrCase<"InlineHint", 3, "hint">
1091-
]> {
1092-
let genSpecializedAttr = 0;
1093-
}
1094-
1095-
def CIR_InlineAttr : CIR_EnumAttr<CIR_InlineKind, "inline"> {
1096-
let summary = "Inline attribute";
1097-
let description = [{
1098-
Inline attribute represents user directives for inlining behavior.
1099-
This attribute is only used by `cir.func` operations.
1100-
1101-
Values:
1102-
- `never`: Prevents the function from being inlined (__attribute__((noinline)))
1103-
- `always`: Forces the function to be inlined (__attribute__((always_inline)))
1104-
- `hint`: Suggests the function should be inlined (inline keyword)
1105-
1106-
Example:
1107-
```
1108-
cir.func @noinline_func(%arg0: !s32i) -> !s32i inline(never) {
1109-
cir.return %arg0 : !s32i
1110-
}
1111-
cir.func @always_inline_func() -> !s32i inline(always) {
1112-
%0 = cir.const #cir.int<42> : !s32i
1113-
cir.return %0 : !s32i
1114-
}
1115-
```
1116-
}];
1117-
1118-
let cppClassName = "InlineAttr";
1119-
1120-
let extraClassDeclaration = [{
1121-
bool isNoInline() const { return getValue() == InlineKind::NoInline; };
1122-
bool isAlwaysInline() const { return getValue() == InlineKind::AlwaysInline; };
1123-
bool isInlineHint() const { return getValue() == InlineKind::InlineHint; };
1124-
}];
1125-
}
1088+
I32EnumAttrCase<"NoInline", 1, "no_inline">,
1089+
I32EnumAttrCase<"AlwaysInline", 2, "always_inline">,
1090+
I32EnumAttrCase<"InlineHint", 3, "inline_hint">
1091+
]>;
11261092

11271093
//===----------------------------------------------------------------------===//
11281094
// CatchAllAttr & UnwindAttr

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

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,9 +2564,9 @@ def CIR_FuncOp : CIR_Op<"func", [
25642564
Similarly, for global destructors both `global_dtor` and
25652565
`global_dtor(<priority>)` are available.
25662566

2567-
The `inline(never)` keyword marks a function that should not be inlined.
2568-
The `inline(always)` keyword marks a function that should always be inlined.
2569-
The `inline(hint)` keyword suggests that the function should be inlined.
2567+
The `no_inline` attribute marks a function that should not be inlined.
2568+
The `always_inline` attribute marks a function that should always be inlined.
2569+
The `inline_hint` attribute suggests that the function should be inlined.
25702570

25712571
Example:
25722572

@@ -2580,7 +2580,10 @@ def CIR_FuncOp : CIR_Op<"func", [
25802580

25812581
// Linkage information
25822582
cir.func linkonce_odr @some_method(...)
2583-
```
2583+
2584+
// Inline information
2585+
cir.func no_inline @some_method(...)
2586+
25842587
// Builtin function
25852588
cir.func builtin @__builtin_coro_end(!cir.ptr<i8>, !cir.bool) -> !cir.bool
25862589
// Coroutine
@@ -2592,26 +2595,29 @@ def CIR_FuncOp : CIR_Op<"func", [
25922595
```
25932596
}];
25942597

2595-
let arguments = (ins SymbolNameAttr:$sym_name,
2596-
CIR_VisibilityAttr:$global_visibility,
2597-
TypeAttrOf<CIR_FuncType>:$function_type,
2598-
UnitAttr:$builtin,
2599-
UnitAttr:$coroutine,
2600-
UnitAttr:$lambda,
2601-
UnitAttr:$no_proto,
2602-
UnitAttr:$dso_local,
2603-
DefaultValuedAttr<CIR_GlobalLinkageKind,
2604-
"cir::GlobalLinkageKind::ExternalLinkage">:$linkage,
2605-
OptionalAttr<CIR_InlineAttr>:$inline_kind,
2606-
OptionalAttr<StrAttr>:$sym_visibility,
2607-
UnitAttr:$comdat,
2608-
OptionalAttr<DictArrayAttr>:$arg_attrs,
2609-
OptionalAttr<DictArrayAttr>:$res_attrs,
2610-
OptionalAttr<FlatSymbolRefAttr>:$aliasee,
2611-
CIR_OptionalPriorityAttr:$global_ctor_priority,
2612-
CIR_OptionalPriorityAttr:$global_dtor_priority,
2613-
OptionalAttr<CIR_CXXSpecialMemberAttr>:$cxx_special_member
2614-
);
2598+
let arguments = (ins
2599+
SymbolNameAttr:$sym_name,
2600+
CIR_VisibilityAttr:$global_visibility,
2601+
TypeAttrOf<CIR_FuncType>:$function_type,
2602+
UnitAttr:$builtin,
2603+
UnitAttr:$coroutine,
2604+
OptionalAttr<CIR_InlineKind>:$inline_kind,
2605+
UnitAttr:$lambda,
2606+
UnitAttr:$no_proto,
2607+
UnitAttr:$dso_local,
2608+
DefaultValuedAttr<
2609+
CIR_GlobalLinkageKind,
2610+
"cir::GlobalLinkageKind::ExternalLinkage"
2611+
>:$linkage,
2612+
OptionalAttr<StrAttr>:$sym_visibility,
2613+
UnitAttr:$comdat,
2614+
OptionalAttr<DictArrayAttr>:$arg_attrs,
2615+
OptionalAttr<DictArrayAttr>:$res_attrs,
2616+
OptionalAttr<FlatSymbolRefAttr>:$aliasee,
2617+
CIR_OptionalPriorityAttr:$global_ctor_priority,
2618+
CIR_OptionalPriorityAttr:$global_dtor_priority,
2619+
OptionalAttr<CIR_CXXSpecialMemberAttr>:$cxx_special_member
2620+
);
26152621

26162622
let regions = (region AnyRegion:$body);
26172623

0 commit comments

Comments
 (0)