Skip to content

Commit 1ed5ef6

Browse files
committed
rebase
Created using spr 1.3.4
2 parents 8de3fb6 + 14a58a1 commit 1ed5ef6

File tree

266 files changed

+7890
-7882
lines changed

Some content is hidden

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

266 files changed

+7890
-7882
lines changed

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -923,9 +923,21 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
923923
// As a solution, for fixed-address binaries we set LPStart to 0, and for
924924
// position-independent binaries we offset LP start by one byte.
925925
bool NeedsLPAdjustment = false;
926-
const MCSymbol *LPStartSymbol = nullptr;
927926
std::function<void(const MCSymbol *)> emitLandingPad;
928-
if (BC.HasFixedLoadAddress) {
927+
928+
// Check if there's a symbol associated with a landing pad fragment.
929+
const MCSymbol *LPStartSymbol = BF.getLPStartSymbol(FF.getFragmentNum());
930+
if (!LPStartSymbol) {
931+
// Since landing pads are not in the same fragment, we fall back to emitting
932+
// absolute addresses for this FDE.
933+
if (opts::Verbosity >= 2) {
934+
BC.outs() << "BOLT-INFO: falling back to generating absolute-address "
935+
<< "exception ranges for " << BF << '\n';
936+
}
937+
938+
assert(BC.HasFixedLoadAddress &&
939+
"Cannot emit absolute-address landing pads for PIE/DSO");
940+
929941
Streamer.emitIntValue(dwarf::DW_EH_PE_udata4, 1); // LPStart format
930942
Streamer.emitIntValue(0, 4); // LPStart
931943
emitLandingPad = [&](const MCSymbol *LPSymbol) {
@@ -936,9 +948,6 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
936948
};
937949
} else {
938950
std::optional<FragmentNum> LPFN = BF.getLPFragment(FF.getFragmentNum());
939-
LPStartSymbol = BF.getLPStartSymbol(FF.getFragmentNum());
940-
assert(LPFN && LPStartSymbol && "Expected LPStart symbol to be set");
941-
942951
const FunctionFragment &LPFragment = BF.getLayout().getFragment(*LPFN);
943952
NeedsLPAdjustment =
944953
(!LPFragment.empty() && LPFragment.front()->isLandingPad());
@@ -987,7 +996,7 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
987996

988997
// Emit encoding of entries in the call site table. The format is used for the
989998
// call site start, length, and corresponding landing pad.
990-
if (BC.HasFixedLoadAddress)
999+
if (!LPStartSymbol)
9911000
Streamer.emitIntValue(dwarf::DW_EH_PE_sdata4, 1);
9921001
else
9931002
Streamer.emitIntValue(dwarf::DW_EH_PE_uleb128, 1);
@@ -1007,7 +1016,7 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
10071016

10081017
// Start of the range is emitted relative to the start of current
10091018
// function split part.
1010-
if (BC.HasFixedLoadAddress) {
1019+
if (!LPStartSymbol) {
10111020
Streamer.emitAbsoluteSymbolDiff(BeginLabel, StartSymbol, 4);
10121021
Streamer.emitAbsoluteSymbolDiff(EndLabel, BeginLabel, 4);
10131022
} else {

bolt/lib/Passes/SplitFunctions.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ void SplitFunctions::splitFunction(BinaryFunction &BF, SplitStrategy &S) {
901901
// have to be placed in the same fragment. When we split them, create
902902
// trampoline landing pads that will redirect the execution to real LPs.
903903
TrampolineSetType Trampolines;
904-
if (!BC.HasFixedLoadAddress && BF.hasEHRanges() && BF.isSplit()) {
904+
if (BF.hasEHRanges() && BF.isSplit()) {
905905
// If all landing pads for this fragment are grouped in one (potentially
906906
// different) fragment, we can set LPStart to the start of that fragment
907907
// and avoid trampoline code.
@@ -925,8 +925,12 @@ void SplitFunctions::splitFunction(BinaryFunction &BF, SplitStrategy &S) {
925925
} else if (LandingPadFragments.size() == 1) {
926926
BF.setLPFragment(FF.getFragmentNum(), LandingPadFragments.front());
927927
} else {
928-
NeedsTrampolines = true;
929-
break;
928+
if (!BC.HasFixedLoadAddress) {
929+
NeedsTrampolines = true;
930+
break;
931+
} else {
932+
BF.setLPFragment(FF.getFragmentNum(), std::nullopt);
933+
}
930934
}
931935
}
932936

bolt/test/X86/exceptions-compact.s

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
## Check that llvm-bolt is able to overwrite LSDA in ULEB128 format in-place for
2+
## all types of binaries.
3+
4+
# REQUIRES: system-linux
5+
6+
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
7+
# RUN: ld.lld --no-pie %t.o -o %t.exe -q
8+
# RUN: ld.lld --pie %t.o -o %t.pie -q
9+
# RUN: ld.lld --shared %t.o -o %t.so -q
10+
# RUN: llvm-bolt %t.exe -o %t.bolt --strict \
11+
# RUN: | FileCheck --check-prefix=CHECK-BOLT %s
12+
# RUN: llvm-bolt %t.pie -o %t.pie.bolt --strict \
13+
# RUN: | FileCheck --check-prefix=CHECK-BOLT %s
14+
# RUN: llvm-bolt %t.so -o %t.so.bolt --strict \
15+
# RUN: | FileCheck --check-prefix=CHECK-BOLT %s
16+
17+
# CHECK-BOLT: rewriting .gcc_except_table in-place
18+
19+
# RUN: llvm-readelf -WS %t.bolt | FileCheck --check-prefix=CHECK-ELF %s
20+
# RUN: llvm-readelf -WS %t.pie.bolt | FileCheck --check-prefix=CHECK-ELF %s
21+
# RUN: llvm-readelf -WS %t.so.bolt | FileCheck --check-prefix=CHECK-ELF %s
22+
23+
# CHECK-ELF-NOT: .bolt.org.gcc_except_table
24+
25+
.text
26+
.global foo
27+
.type foo, %function
28+
foo:
29+
.cfi_startproc
30+
ret
31+
.cfi_endproc
32+
.size foo, .-foo
33+
34+
.globl _start
35+
.type _start, %function
36+
_start:
37+
.Lfunc_begin0:
38+
.cfi_startproc
39+
.cfi_lsda 27, .Lexception0
40+
call foo
41+
.Ltmp0:
42+
call foo
43+
.Ltmp1:
44+
ret
45+
46+
## Landing pads.
47+
.LLP1:
48+
ret
49+
.LLP0:
50+
ret
51+
52+
.cfi_endproc
53+
.Lfunc_end0:
54+
.size _start, .-_start
55+
56+
## EH table.
57+
.section .gcc_except_table,"a",@progbits
58+
.p2align 2
59+
GCC_except_table0:
60+
.Lexception0:
61+
.byte 255 # @LPStart Encoding = omit
62+
.byte 255 # @TType Encoding = omit
63+
.byte 1 # Call site Encoding = uleb128
64+
.uleb128 .Lcst_end0-.Lcst_begin0
65+
.Lcst_begin0:
66+
.uleb128 .Lfunc_begin0-.Lfunc_begin0 # >> Call Site 1 <<
67+
.uleb128 .Ltmp0-.Lfunc_begin0 # Call between .Lfunc_begin0 and .Ltmp0
68+
.uleb128 .LLP0-.Lfunc_begin0 # jumps to .LLP0
69+
.byte 0 # On action: cleanup
70+
.uleb128 .Ltmp0-.Lfunc_begin0 # >> Call Site 2 <<
71+
.uleb128 .Ltmp1-.Ltmp0 # Call between .Ltmp0 and .Ltmp1
72+
.uleb128 .LLP1-.Lfunc_begin0 # jumps to .LLP1
73+
.byte 0 # On action: cleanup
74+
.Lcst_end0:
75+

clang-tools-extra/clangd/InlayHints.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,10 +626,15 @@ class InlayHintVisitor : public RecursiveASTVisitor<InlayHintVisitor> {
626626

627627
bool VisitLambdaExpr(LambdaExpr *E) {
628628
FunctionDecl *D = E->getCallOperator();
629-
if (!E->hasExplicitResultType())
630-
addReturnTypeHint(D, E->hasExplicitParameters()
631-
? D->getFunctionTypeLoc().getRParenLoc()
632-
: E->getIntroducerRange().getEnd());
629+
if (!E->hasExplicitResultType()) {
630+
SourceLocation TypeHintLoc;
631+
if (!E->hasExplicitParameters())
632+
TypeHintLoc = E->getIntroducerRange().getEnd();
633+
else if (auto FTL = D->getFunctionTypeLoc())
634+
TypeHintLoc = FTL.getRParenLoc();
635+
if (TypeHintLoc.isValid())
636+
addReturnTypeHint(D, TypeHintLoc);
637+
}
633638
return true;
634639
}
635640

clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,22 @@ TEST(TypeHints, Aliased) {
15761576
EXPECT_THAT(hintsOfKind(AST, InlayHintKind::Type), IsEmpty());
15771577
}
15781578

1579+
TEST(TypeHints, CallingConvention) {
1580+
// Check that we don't crash for lambdas without a FunctionTypeLoc
1581+
// https://github.com/clangd/clangd/issues/2223
1582+
std::string Code = R"cpp(
1583+
void test() {
1584+
[]() __cdecl {};
1585+
}
1586+
)cpp";
1587+
TestTU TU = TestTU::withCode(Code);
1588+
TU.ExtraArgs.push_back("--target=x86_64-w64-mingw32");
1589+
TU.PredefineMacros = true; // for the __cdecl
1590+
auto AST = TU.build();
1591+
1592+
EXPECT_THAT(hintsOfKind(AST, InlayHintKind::Type), IsEmpty());
1593+
}
1594+
15791595
TEST(TypeHints, Decltype) {
15801596
assertTypeHints(R"cpp(
15811597
$a[[decltype(0)]] a;

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,11 @@ Improvements to Clang's diagnostics
578578

579579
- Clang now omits shadowing warnings for parameter names in explicit object member functions (#GH95707).
580580

581+
- Improved error recovery for function call arguments with trailing commas (#GH100921).
582+
583+
- For an rvalue reference bound to a temporary struct with an integer member, Clang will detect constant integer overflow
584+
in the initializer for the integer member (#GH46755).
585+
581586
Improvements to Clang's time-trace
582587
----------------------------------
583588

@@ -847,6 +852,7 @@ RISC-V Support
847852
^^^^^^^^^^^^^^
848853

849854
- The option ``-mcmodel=large`` for the large code model is supported.
855+
- Bump RVV intrinsic to version 1.0, the spec: https://github.com/riscv-non-isa/rvv-intrinsic-doc/releases/tag/v1.0.0-rc4
850856

851857
CUDA/HIP Language Changes
852858
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Basic/Builtins.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4750,6 +4750,12 @@ def HLSLAny : LangBuiltin<"HLSL_LANG"> {
47504750
let Prototype = "bool(...)";
47514751
}
47524752

4753+
def HLSLAsDouble : LangBuiltin<"HLSL_LANG"> {
4754+
let Spellings = ["__builtin_hlsl_asdouble"];
4755+
let Attributes = [NoThrow, Const];
4756+
let Prototype = "void(...)";
4757+
}
4758+
47534759
def HLSLWaveActiveAnyTrue : LangBuiltin<"HLSL_LANG"> {
47544760
let Spellings = ["__builtin_hlsl_wave_active_any_true"];
47554761
let Attributes = [NoThrow, Const];

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,9 +1728,9 @@ def err_introducing_special_friend : Error<
17281728
def err_tagless_friend_type_template : Error<
17291729
"friend type templates must use an elaborated type">;
17301730
def err_no_matching_local_friend : Error<
1731-
"no matching function found in local scope">;
1731+
"cannot define friend function in a local class definition">;
17321732
def err_no_matching_local_friend_suggest : Error<
1733-
"no matching function %0 found in local scope; did you mean %3?">;
1733+
"cannot define friend function %0 in a local class definition; did you mean %3?">;
17341734
def err_partial_specialization_friend : Error<
17351735
"partial specialization cannot be declared as a friend">;
17361736
def err_qualified_friend_def : Error<

clang/include/clang/Driver/Options.td

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4405,7 +4405,7 @@ def fcoverage_prefix_map_EQ
44054405
HelpText<"remap file source paths <old> to <new> in coverage mapping. If there are multiple options, prefix replacement is applied in reverse order starting from the last one">;
44064406
def ffile_prefix_map_EQ
44074407
: Joined<["-"], "ffile-prefix-map=">, Group<f_Group>,
4408-
HelpText<"remap file source paths in debug info, predefined preprocessor "
4408+
HelpText<"remap file source paths in debug info, coverage mapping, predefined preprocessor "
44094409
"macros and __builtin_FILE(). Implies -ffile-reproducible.">;
44104410
def fmacro_prefix_map_EQ
44114411
: Joined<["-"], "fmacro-prefix-map=">, Group<f_Group>,
@@ -5413,6 +5413,10 @@ def mlam_bh : Flag<["-"], "mlam-bh">, Group<m_loongarch_Features_Group>,
54135413
HelpText<"Enable amswap[_db].{b/h} and amadd[_db].{b/h}">;
54145414
def mno_lam_bh : Flag<["-"], "mno-lam-bh">, Group<m_loongarch_Features_Group>,
54155415
HelpText<"Disable amswap[_db].{b/h} and amadd[_db].{b/h}">;
5416+
def mld_seq_sa : Flag<["-"], "mld-seq-sa">, Group<m_loongarch_Features_Group>,
5417+
HelpText<"Do not generate load-load barrier instructions (dbar 0x700)">;
5418+
def mno_ld_seq_sa : Flag<["-"], "mno-ld-seq-sa">, Group<m_loongarch_Features_Group>,
5419+
HelpText<"Generate load-load barrier instructions (dbar 0x700)">;
54165420
def mannotate_tablejump : Flag<["-"], "mannotate-tablejump">, Group<m_loongarch_Features_Group>,
54175421
HelpText<"Enable annotate table jump instruction to correlate it with the jump table.">;
54185422
def mno_annotate_tablejump : Flag<["-"], "mno-annotate-tablejump">, Group<m_loongarch_Features_Group>,
@@ -5884,12 +5888,24 @@ def target : Joined<["--"], "target=">, Flags<[NoXarchOption]>,
58845888
def darwin_target_variant : Separate<["-"], "darwin-target-variant">,
58855889
Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption]>,
58865890
HelpText<"Generate code for an additional runtime variant of the deployment target">;
5891+
5892+
//===----------------------------------------------------------------------===//
5893+
// Print CPU info options (clang, clang-cl, flang)
5894+
//===----------------------------------------------------------------------===//
5895+
5896+
let Visibility = [ClangOption, CC1Option, CLOption, FlangOption, FC1Option] in {
5897+
58875898
def print_supported_cpus : Flag<["-", "--"], "print-supported-cpus">,
58885899
Group<CompileOnly_Group>,
5889-
Visibility<[ClangOption, CC1Option, CLOption]>,
5890-
HelpText<"Print supported cpu models for the given target (if target is not specified,"
5891-
" it will print the supported cpus for the default target)">,
5900+
HelpText<"Print supported cpu models for the given target (if target is not "
5901+
"specified,it will print the supported cpus for the default target)">,
58925902
MarshallingInfoFlag<FrontendOpts<"PrintSupportedCPUs">>;
5903+
5904+
def : Flag<["-"], "mcpu=help">, Alias<print_supported_cpus>;
5905+
def : Flag<["-"], "mtune=help">, Alias<print_supported_cpus>;
5906+
5907+
} // let Visibility = [ClangOption, CC1Option, CLOption, FlangOption, FC1Option]
5908+
58935909
def print_supported_extensions : Flag<["-", "--"], "print-supported-extensions">,
58945910
Visibility<[ClangOption, CC1Option, CLOption]>,
58955911
HelpText<"Print supported -march extensions (RISC-V, AArch64 and ARM only)">,
@@ -5899,8 +5915,6 @@ def print_enabled_extensions : Flag<["-", "--"], "print-enabled-extensions">,
58995915
HelpText<"Print the extensions enabled by the given target and -march/-mcpu options."
59005916
" (AArch64 and RISC-V only)">,
59015917
MarshallingInfoFlag<FrontendOpts<"PrintEnabledExtensions">>;
5902-
def : Flag<["-"], "mcpu=help">, Alias<print_supported_cpus>;
5903-
def : Flag<["-"], "mtune=help">, Alias<print_supported_cpus>;
59045918
def time : Flag<["-"], "time">,
59055919
HelpText<"Time individual commands">;
59065920
def traditional_cpp : Flag<["-", "--"], "traditional-cpp">,

clang/include/clang/Parse/Parser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,8 @@ class Parser : public CodeCompletionHandler {
19341934
llvm::function_ref<void()> ExpressionStarts =
19351935
llvm::function_ref<void()>(),
19361936
bool FailImmediatelyOnInvalidExpr = false,
1937-
bool EarlyTypoCorrection = false);
1937+
bool EarlyTypoCorrection = false,
1938+
bool *HasTrailingComma = nullptr);
19381939

19391940
/// ParseSimpleExpressionList - A simple comma-separated list of expressions,
19401941
/// used for misc language extensions.

0 commit comments

Comments
 (0)