Skip to content

Commit ae9886a

Browse files
Merge branch 'llvm:main' into nested-impl-do-data
2 parents 6858898 + 1aea024 commit ae9886a

File tree

217 files changed

+3489
-2312
lines changed

Some content is hidden

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

217 files changed

+3489
-2312
lines changed

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2582,9 +2582,9 @@ the configuration (without a prefix: ``Auto``).
25822582

25832583
.. _BracedInitializerIndentWidth:
25842584

2585-
**BracedInitializerIndentWidth** (``Unsigned``) :versionbadge:`clang-format 17` :ref:`<BracedInitializerIndentWidth>`
2585+
**BracedInitializerIndentWidth** (``Integer``) :versionbadge:`clang-format 17` :ref:`<BracedInitializerIndentWidth>`
25862586
The number of columns to use to indent the contents of braced init lists.
2587-
If unset, ``ContinuationIndentWidth`` is used.
2587+
If unset or negative, ``ContinuationIndentWidth`` is used.
25882588

25892589
.. code-block:: c++
25902590

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ Bug Fixes in This Version
225225

226226
- Clang now outputs correct values when #embed data contains bytes with negative
227227
signed char values (#GH102798).
228+
- Fixed rejects-valid problem when #embed appears in std::initializer_list or
229+
when it can affect template argument deduction (#GH122306).
228230

229231
Bug Fixes to Compiler Builtins
230232
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/Expr.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5189,6 +5189,16 @@ class InitListExpr : public Expr {
51895189

51905190
unsigned getNumInits() const { return InitExprs.size(); }
51915191

5192+
/// getNumInits but if the list has an EmbedExpr inside includes full length
5193+
/// of embedded data.
5194+
unsigned getNumInitsWithEmbedExpanded() const {
5195+
unsigned Sum = InitExprs.size();
5196+
for (auto *IE : InitExprs)
5197+
if (auto *EE = dyn_cast<EmbedExpr>(IE))
5198+
Sum += EE->getDataElementCount() - 1;
5199+
return Sum;
5200+
}
5201+
51925202
/// Retrieve the set of initializers.
51935203
Expr **getInits() { return reinterpret_cast<Expr **>(InitExprs.data()); }
51945204

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -544,29 +544,29 @@ TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x16_bf8_fp8_w64_gfx12, "V4fiiV4f",
544544
TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x16_bf8_bf8_w64_gfx12, "V4fiiV4f", "nc", "gfx12-insts,wavefrontsize64")
545545
TARGET_BUILTIN(__builtin_amdgcn_wmma_i32_16x16x32_iu4_w64_gfx12, "V4iIbiIbiV4iIb", "nc", "gfx12-insts,wavefrontsize64")
546546

547-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_f16_w32, "V8fV8hV16hV8fs", "nc", "gfx12-insts,wavefrontsize32")
548-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_bf16_w32, "V8fV8sV16sV8fs", "nc", "gfx12-insts,wavefrontsize32")
549-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f16_16x16x32_f16_w32, "V8hV8hV16hV8hs", "nc", "gfx12-insts,wavefrontsize32")
550-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_bf16_16x16x32_bf16_w32, "V8sV8sV16sV8ss", "nc", "gfx12-insts,wavefrontsize32")
551-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_i32_16x16x32_iu8_w32, "V8iIbV2iIbV4iV8isIb", "nc", "gfx12-insts,wavefrontsize32")
552-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_i32_16x16x32_iu4_w32, "V8iIbiIbV2iV8isIb", "nc", "gfx12-insts,wavefrontsize32")
553-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_i32_16x16x64_iu4_w32, "V8iIbV2iIbV4iV8isIb", "nc", "gfx12-insts,wavefrontsize32")
554-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_fp8_fp8_w32, "V8fV2iV4iV8fs", "nc", "gfx12-insts,wavefrontsize32")
555-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_fp8_bf8_w32, "V8fV2iV4iV8fs", "nc", "gfx12-insts,wavefrontsize32")
556-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_bf8_fp8_w32, "V8fV2iV4iV8fs", "nc", "gfx12-insts,wavefrontsize32")
557-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_bf8_bf8_w32, "V8fV2iV4iV8fs", "nc", "gfx12-insts,wavefrontsize32")
558-
559-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_f16_w64, "V4fV4hV8hV4fs", "nc", "gfx12-insts,wavefrontsize64")
560-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_bf16_w64, "V4fV4sV8sV4fs", "nc", "gfx12-insts,wavefrontsize64")
561-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f16_16x16x32_f16_w64, "V4hV4hV8hV4hs", "nc", "gfx12-insts,wavefrontsize64")
562-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_bf16_16x16x32_bf16_w64, "V4sV4sV8sV4ss", "nc", "gfx12-insts,wavefrontsize64")
563-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_i32_16x16x32_iu8_w64, "V4iIbiIbV2iV4isIb", "nc", "gfx12-insts,wavefrontsize64")
564-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_i32_16x16x32_iu4_w64, "V4iIbiIbiV4isIb", "nc", "gfx12-insts,wavefrontsize64")
565-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_i32_16x16x64_iu4_w64, "V4iIbiIbV2iV4isIb", "nc", "gfx12-insts,wavefrontsize64")
566-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_fp8_fp8_w64, "V4fiV2iV4fs", "nc", "gfx12-insts,wavefrontsize64")
567-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_fp8_bf8_w64, "V4fiV2iV4fs", "nc", "gfx12-insts,wavefrontsize64")
568-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_bf8_fp8_w64, "V4fiV2iV4fs", "nc", "gfx12-insts,wavefrontsize64")
569-
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_bf8_bf8_w64, "V4fiV2iV4fs", "nc", "gfx12-insts,wavefrontsize64")
547+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_f16_w32, "V8fV8hV16hV8fi", "nc", "gfx12-insts,wavefrontsize32")
548+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_bf16_w32, "V8fV8sV16sV8fi", "nc", "gfx12-insts,wavefrontsize32")
549+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f16_16x16x32_f16_w32, "V8hV8hV16hV8hi", "nc", "gfx12-insts,wavefrontsize32")
550+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_bf16_16x16x32_bf16_w32, "V8sV8sV16sV8si", "nc", "gfx12-insts,wavefrontsize32")
551+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_i32_16x16x32_iu8_w32, "V8iIbV2iIbV4iV8iiIb", "nc", "gfx12-insts,wavefrontsize32")
552+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_i32_16x16x32_iu4_w32, "V8iIbiIbV2iV8iiIb", "nc", "gfx12-insts,wavefrontsize32")
553+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_i32_16x16x64_iu4_w32, "V8iIbV2iIbV4iV8iiIb", "nc", "gfx12-insts,wavefrontsize32")
554+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_fp8_fp8_w32, "V8fV2iV4iV8fi", "nc", "gfx12-insts,wavefrontsize32")
555+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_fp8_bf8_w32, "V8fV2iV4iV8fi", "nc", "gfx12-insts,wavefrontsize32")
556+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_bf8_fp8_w32, "V8fV2iV4iV8fi", "nc", "gfx12-insts,wavefrontsize32")
557+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_bf8_bf8_w32, "V8fV2iV4iV8fi", "nc", "gfx12-insts,wavefrontsize32")
558+
559+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_f16_w64, "V4fV4hV8hV4fi", "nc", "gfx12-insts,wavefrontsize64")
560+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_bf16_w64, "V4fV4sV8sV4fi", "nc", "gfx12-insts,wavefrontsize64")
561+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f16_16x16x32_f16_w64, "V4hV4hV8hV4hi", "nc", "gfx12-insts,wavefrontsize64")
562+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_bf16_16x16x32_bf16_w64, "V4sV4sV8sV4si", "nc", "gfx12-insts,wavefrontsize64")
563+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_i32_16x16x32_iu8_w64, "V4iIbiIbV2iV4iiIb", "nc", "gfx12-insts,wavefrontsize64")
564+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_i32_16x16x32_iu4_w64, "V4iIbiIbiV4iiIb", "nc", "gfx12-insts,wavefrontsize64")
565+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_i32_16x16x64_iu4_w64, "V4iIbiIbV2iV4iiIb", "nc", "gfx12-insts,wavefrontsize64")
566+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_fp8_fp8_w64, "V4fiV2iV4fi", "nc", "gfx12-insts,wavefrontsize64")
567+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_fp8_bf8_w64, "V4fiV2iV4fi", "nc", "gfx12-insts,wavefrontsize64")
568+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_bf8_fp8_w64, "V4fiV2iV4fi", "nc", "gfx12-insts,wavefrontsize64")
569+
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x32_bf8_bf8_w64, "V4fiV2iV4fi", "nc", "gfx12-insts,wavefrontsize64")
570570

571571
TARGET_BUILTIN(__builtin_amdgcn_prng_b32, "UiUi", "nc", "prng-inst")
572572
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk32_fp6_f16, "V6UiV32hf", "nc", "f16bf16-to-fp6bf6-cvt-scale-insts")

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,11 @@ def err_test_module_file_extension_format : Error<
563563
def err_drv_module_output_with_multiple_arch : Error<
564564
"option '-fmodule-output' cannot be used with multiple arch options">;
565565

566+
def err_drv_reduced_module_output_overrided : Warning<
567+
"the implicit output of reduced BMI may be overrided by the output file specified by '--precompile'. "
568+
"please consider use '-fmodule-output=' to specify the output file for reduced BMI explicitly">,
569+
InGroup<DiagGroup<"reduced-bmi-output-overrided">>;
570+
566571
def warn_drv_delayed_template_parsing_after_cxx20 : Warning<
567572
"-fdelayed-template-parsing is deprecated after C++20">,
568573
InGroup<DiagGroup<"delayed-template-parsing-in-cxx20">>;

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3176,7 +3176,7 @@ def modules_reduced_bmi : Flag<["-"], "fmodules-reduced-bmi">,
31763176
HelpText<"Generate the reduced BMI">,
31773177
MarshallingInfoFlag<FrontendOpts<"GenReducedBMI">>;
31783178

3179-
def experimental_modules_reduced_bmi : Flag<["-"], "fexperimental-modules-reduced-bmi">,
3179+
def experimental_modules_reduced_bmi : Flag<["-"], "fexperimental-modules-reduced-bmi">,
31803180
Group<f_Group>, Visibility<[ClangOption, CC1Option]>, Alias<modules_reduced_bmi>;
31813181

31823182
def fmodules_embed_all_files : Joined<["-"], "fmodules-embed-all-files">,
@@ -7431,7 +7431,7 @@ def fuse_register_sized_bitfield_access: Flag<["-"], "fuse-register-sized-bitfie
74317431
def relaxed_aliasing : Flag<["-"], "relaxed-aliasing">,
74327432
HelpText<"Turn off Type Based Alias Analysis">,
74337433
MarshallingInfoFlag<CodeGenOpts<"RelaxedAliasing">>;
7434-
defm pointer_tbaa: BoolOption<"", "pointer-tbaa", CodeGenOpts<"PointerTBAA">,
7434+
defm pointer_tbaa: BoolOption<"", "pointer-tbaa", CodeGenOpts<"PointerTBAA">,
74357435
DefaultTrue,
74367436
PosFlag<SetTrue, [], [ClangOption], "Enable">,
74377437
NegFlag<SetFalse, [], [ClangOption], "Disable">,

clang/include/clang/Format/Format.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ struct FormatStyle {
12891289
BitFieldColonSpacingStyle BitFieldColonSpacing;
12901290

12911291
/// The number of columns to use to indent the contents of braced init lists.
1292-
/// If unset, ``ContinuationIndentWidth`` is used.
1292+
/// If unset or negative, ``ContinuationIndentWidth`` is used.
12931293
/// \code
12941294
/// AlignAfterOpenBracket: AlwaysBreak
12951295
/// BracedInitializerIndentWidth: 2
@@ -1319,7 +1319,7 @@ struct FormatStyle {
13191319
/// }
13201320
/// \endcode
13211321
/// \version 17
1322-
std::optional<unsigned> BracedInitializerIndentWidth;
1322+
int BracedInitializerIndentWidth;
13231323

13241324
/// Different ways to wrap braces after control statements.
13251325
enum BraceWrappingAfterControlStatementStyle : int8_t {

clang/lib/CodeGen/CGCoroutine.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,20 @@ void CodeGenFunction::EmitCoroutineBody(const CoroutineBodyStmt &S) {
855855
// Create parameter copies. We do it before creating a promise, since an
856856
// evolution of coroutine TS may allow promise constructor to observe
857857
// parameter copies.
858+
for (const ParmVarDecl *Parm : FnArgs) {
859+
// If the original param is in an alloca, exclude it from the coroutine
860+
// frame. The parameter copy will be part of the frame, but the original
861+
// parameter memory should remain on the stack. This is necessary to
862+
// ensure that parameters destroyed in callees, as with `trivial_abi` or
863+
// in the MSVC C++ ABI, are appropriately destroyed after setting up the
864+
// coroutine.
865+
Address ParmAddr = GetAddrOfLocalVar(Parm);
866+
if (auto *ParmAlloca =
867+
dyn_cast<llvm::AllocaInst>(ParmAddr.getBasePointer())) {
868+
ParmAlloca->setMetadata(llvm::LLVMContext::MD_coro_outside_frame,
869+
llvm::MDNode::get(CGM.getLLVMContext(), {}));
870+
}
871+
}
858872
for (auto *PM : S.getParamMoves()) {
859873
EmitStmt(PM);
860874
ParamReplacer.addCopy(cast<DeclStmt>(PM));
@@ -942,9 +956,16 @@ void CodeGenFunction::EmitCoroutineBody(const CoroutineBodyStmt &S) {
942956
if (Stmt *Ret = S.getReturnStmt()) {
943957
// Since we already emitted the return value above, so we shouldn't
944958
// emit it again here.
945-
if (GroManager.DirectEmit)
959+
Expr *PreviousRetValue = nullptr;
960+
if (GroManager.DirectEmit) {
961+
PreviousRetValue = cast<ReturnStmt>(Ret)->getRetValue();
946962
cast<ReturnStmt>(Ret)->setRetValue(nullptr);
963+
}
947964
EmitStmt(Ret);
965+
// Set the return value back. The code generator, as the AST **Consumer**,
966+
// shouldn't change the AST.
967+
if (PreviousRetValue)
968+
cast<ReturnStmt>(Ret)->setRetValue(PreviousRetValue);
948969
}
949970

950971
// LLVM require the frontend to mark the coroutine.

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4250,10 +4250,18 @@ static bool RenderModulesOptions(Compilation &C, const Driver &D,
42504250

42514251
if (Args.hasArg(options::OPT_fmodule_output_EQ))
42524252
Args.AddLastArg(CmdArgs, options::OPT_fmodule_output_EQ);
4253-
else
4253+
else {
4254+
if (Args.hasArg(options::OPT__precompile) &&
4255+
(!Args.hasArg(options::OPT_o) ||
4256+
Args.getLastArg(options::OPT_o)->getValue() ==
4257+
getCXX20NamedModuleOutputPath(Args, Input.getBaseInput()))) {
4258+
D.Diag(diag::err_drv_reduced_module_output_overrided);
4259+
}
4260+
42544261
CmdArgs.push_back(Args.MakeArgString(
42554262
"-fmodule-output=" +
42564263
getCXX20NamedModuleOutputPath(Args, Input.getBaseInput())));
4264+
}
42574265
}
42584266

42594267
// Noop if we see '-fmodules-reduced-bmi' with other translation

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,9 +1921,9 @@ void ContinuationIndenter::moveStatePastScopeOpener(LineState &State,
19211921
NewIndent = Style.IndentWidth +
19221922
std::min(State.Column, CurrentState.NestedBlockIndent);
19231923
} else if (Current.is(tok::l_brace)) {
1924-
NewIndent =
1925-
CurrentState.LastSpace + Style.BracedInitializerIndentWidth.value_or(
1926-
Style.ContinuationIndentWidth);
1924+
const auto Width = Style.BracedInitializerIndentWidth;
1925+
NewIndent = CurrentState.LastSpace +
1926+
(Width < 0 ? Style.ContinuationIndentWidth : Width);
19271927
} else {
19281928
NewIndent = CurrentState.LastSpace + Style.ContinuationIndentWidth;
19291929
}

0 commit comments

Comments
 (0)