diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/debian/changelog rustc-1.65.0+dfsg0ubuntu1~llvm2/debian/changelog --- rustc-1.65.0+dfsg0ubuntu1~llvm/debian/changelog 2023-01-20 17:23:46.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/debian/changelog 2023-01-25 17:02:05.000000000 +0000 @@ -1,3 +1,11 @@ +rustc (1.65.0+dfsg0ubuntu1~llvm2-0ubuntu0.20.04) focal; urgency=medium + + * Update the vendored LLVM 15 to the latest bugfix release to fix ppc64el + build. + * Cherry-pick upstream patch to fix FTBFS on ppc64el and arm64 + + -- Simon Chopin Wed, 25 Jan 2023 18:02:05 +0100 + rustc (1.65.0+dfsg0ubuntu1~llvm-0ubuntu0.20.04) focal; urgency=medium * Backport to focal (LP: #2000839) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/debian/patches/series rustc-1.65.0+dfsg0ubuntu1~llvm2/debian/patches/series --- rustc-1.65.0+dfsg0ubuntu1~llvm/debian/patches/series 2023-01-20 17:20:07.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/debian/patches/series 2023-01-25 17:02:05.000000000 +0000 @@ -63,3 +63,4 @@ ubuntu-ignore-arm-doctest.patch ubuntu-vendor-no-workspace.patch ubuntu-Revert-Use-constant-eval-to-do-strict-validity-check.patch +ubuntu-Set-exec-env-RUST_BACKTRACE-0-in-const-eval-select-t.patch diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/debian/patches/ubuntu-Set-exec-env-RUST_BACKTRACE-0-in-const-eval-select-t.patch rustc-1.65.0+dfsg0ubuntu1~llvm2/debian/patches/ubuntu-Set-exec-env-RUST_BACKTRACE-0-in-const-eval-select-t.patch --- rustc-1.65.0+dfsg0ubuntu1~llvm/debian/patches/ubuntu-Set-exec-env-RUST_BACKTRACE-0-in-const-eval-select-t.patch 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/debian/patches/ubuntu-Set-exec-env-RUST_BACKTRACE-0-in-const-eval-select-t.patch 2023-01-25 17:02:05.000000000 +0000 @@ -0,0 +1,57 @@ +From 534b2bafec3a23716cd9538deea3287de7a82ea0 Mon Sep 17 00:00:00 2001 +From: Aaron Hill +Date: Wed, 21 Sep 2022 10:24:16 -0500 +Subject: [PATCH] Set 'exec-env:RUST_BACKTRACE=0' in const-eval-select tests + +This allows the tests to pass even if the user has RUST_BACKTRACE +set when running 'x.py' +--- + src/test/ui/intrinsics/const-eval-select-backtrace-std.rs | 1 + + .../ui/intrinsics/const-eval-select-backtrace-std.run.stderr | 2 +- + src/test/ui/intrinsics/const-eval-select-backtrace.rs | 1 + + src/test/ui/intrinsics/const-eval-select-backtrace.run.stderr | 2 +- + 4 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/test/ui/intrinsics/const-eval-select-backtrace-std.rs b/src/test/ui/intrinsics/const-eval-select-backtrace-std.rs +index 29aefe07162..1164a3a5b01 100644 +--- a/src/test/ui/intrinsics/const-eval-select-backtrace-std.rs ++++ b/src/test/ui/intrinsics/const-eval-select-backtrace-std.rs +@@ -1,6 +1,7 @@ + // See issue #100696. + // run-fail + // check-run-results ++// exec-env:RUST_BACKTRACE=0 + fn main() { + &""[1..]; + } +diff --git a/src/test/ui/intrinsics/const-eval-select-backtrace-std.run.stderr b/src/test/ui/intrinsics/const-eval-select-backtrace-std.run.stderr +index e53e6034620..463cd52c5aa 100644 +--- a/src/test/ui/intrinsics/const-eval-select-backtrace-std.run.stderr ++++ b/src/test/ui/intrinsics/const-eval-select-backtrace-std.run.stderr +@@ -1,2 +1,2 @@ +-thread 'main' panicked at 'byte index 1 is out of bounds of ``', $DIR/const-eval-select-backtrace-std.rs:5:6 ++thread 'main' panicked at 'byte index 1 is out of bounds of ``', $DIR/const-eval-select-backtrace-std.rs:6:6 + note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +diff --git a/src/test/ui/intrinsics/const-eval-select-backtrace.rs b/src/test/ui/intrinsics/const-eval-select-backtrace.rs +index 99f0725200c..ef1c7c4195b 100644 +--- a/src/test/ui/intrinsics/const-eval-select-backtrace.rs ++++ b/src/test/ui/intrinsics/const-eval-select-backtrace.rs +@@ -2,6 +2,7 @@ + // See issue #100696. + // run-fail + // check-run-results ++// exec-env:RUST_BACKTRACE=0 + + #[track_caller] + fn uhoh() { +diff --git a/src/test/ui/intrinsics/const-eval-select-backtrace.run.stderr b/src/test/ui/intrinsics/const-eval-select-backtrace.run.stderr +index 2fd730ac7a6..54e28db5e53 100644 +--- a/src/test/ui/intrinsics/const-eval-select-backtrace.run.stderr ++++ b/src/test/ui/intrinsics/const-eval-select-backtrace.run.stderr +@@ -1,2 +1,2 @@ +-thread 'main' panicked at 'Aaah!', $DIR/const-eval-select-backtrace.rs:16:9 ++thread 'main' panicked at 'Aaah!', $DIR/const-eval-select-backtrace.rs:17:9 + note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +-- +2.37.2 + diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/CMakeLists.txt rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/CMakeLists.txt --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/CMakeLists.txt 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/CMakeLists.txt 2023-01-24 23:05:56.000000000 +0000 @@ -117,6 +117,7 @@ include(TableGen) include(HandleLLVMOptions) include(VersionFromVCS) + include(CheckAtomic) include(GetErrcMessages) include(LLVMDistributionSupport) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/docs/ClangCommandLineReference.rst rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/docs/ClangCommandLineReference.rst --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/docs/ClangCommandLineReference.rst 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/docs/ClangCommandLineReference.rst 2023-01-24 23:05:56.000000000 +0000 @@ -1675,7 +1675,7 @@ .. option:: -fdiagnostics-misexpect-tolerance= -Prevent misexpect diagnostics from being output if the profile counts are within N% of the expected. +Prevent misexpect diagnostics from being output if the profile counts are within N% of the expected. .. option:: -fdiagnostics-show-hotness, -fno-diagnostics-show-hotness @@ -2578,7 +2578,6 @@ .. option:: -ftime-trace - Turn on time profiler. Generates JSON file based on output filename. Results can be analyzed with chrome://tracing or `Speedscope App `_ for flamegraph visualization. diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/docs/ReleaseNotes.rst rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/docs/ReleaseNotes.rst --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/docs/ReleaseNotes.rst 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/docs/ReleaseNotes.rst 2023-01-24 23:05:56.000000000 +0000 @@ -8,13 +8,6 @@ Written by the `LLVM Team `_ -.. only:: PreRelease - - .. warning:: - These are in-progress notes for the upcoming Clang |version| release. - Release notes for previous releases can be found on - `the Download Page `_. - Introduction ============ @@ -44,6 +37,22 @@ infrastructure are described first, followed by language-specific sections with improvements to Clang's support for those languages. +Potentially Breaking Changes +============================ +These changes are ones which we think may surprise users when upgrading to +Clang |release| because of the opportunity they pose for disruption to existing +code bases. + +- The ``-Wimplicit-function-declaration`` and ``-Wimplicit-int`` warning + diagnostics are now enabled by default in C99, C11, and C17. As of C2x, + support for implicit function declarations and implicit int has been removed, + and the warning options will have no effect. Specifying ``-Wimplicit-int`` in + C89 mode will now issue warnings instead of being a noop. + *NOTE* these warnings are expected to default to an error in Clang 16. We + recommend that projects using configure scripts verify the results do not + change before/after setting ``-Werror=implicit-function-declarations`` or + ``-Wimplicit-int`` to avoid incompatibility with Clang 16. + Major New Features ------------------ @@ -213,6 +222,15 @@ missing when used, or vice versa. This makes sure that Clang picks the correct one, where it previously would consider multiple ones as potentially acceptable (and erroneously use whichever one is tried first). +- Fix a crash when generating code coverage information for an + ``if consteval`` statement. This fixes + `Issue 57377 `_. +- Fix a crash when a ``btf_type_tag`` attribute is applied to the pointee of + a function pointer. +- Clang 14 predeclared some builtin POSIX library functions in ``gnu2x`` mode, + and Clang 15 accidentally stopped predeclaring those functions in that + language mode. Clang 16 now predeclares those functions again. This fixes + `Issue 56607 `_. Improvements to Clang's diagnostics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -249,18 +267,6 @@ without a prototype and with no arguments is an invalid redeclaration of a function with a prototype. e.g., ``void f(int); void f() {}`` is now properly diagnosed. -- The ``-Wimplicit-function-declaration`` warning diagnostic now defaults to - an error in C99 and later. Prior to C2x, it may be downgraded to a warning - with ``-Wno-error=implicit-function-declaration``, or disabled entirely with - ``-Wno-implicit-function-declaration``. As of C2x, support for implicit - function declarations has been removed, and the warning options will have no - effect. -- The ``-Wimplicit-int`` warning diagnostic now defaults to an error in C99 and - later. Prior to C2x, it may be downgraded to a warning with - ``-Wno-error=implicit-int``, or disabled entirely with ``-Wno-implicit-int``. - As of C2x, support for implicit int has been removed, and the warning options - will have no effect. Specifying ``-Wimplicit-int`` in C89 mode will now issue - warnings instead of being a noop. - No longer issue a "declaration specifiers missing, defaulting to int" diagnostic in C89 mode because it is not an extension in C89, it was valid code. The diagnostic has been removed entirely as it did not have a @@ -549,6 +555,12 @@ - As per "Conditionally Trivial Special Member Functions" (P0848), it is now possible to overload destructors using concepts. Note that the rest of the paper about other special member functions is not yet implemented. +- Skip rebuilding lambda expressions in arguments of immediate invocations. + This fixes `GH56183 `_, + `GH51695 `_, + `GH50455 `_, + `GH54872 `_, + `GH54587 `_. C++2b Feature Support ^^^^^^^^^^^^^^^^^^^^^ @@ -669,6 +681,20 @@ Operations found in the :ref:`Clang Language Extensions ` document. +RISC-V Support in Clang +----------------------- + +- Updates to the RISC-V vector intrinsics to align with ongoing additions to + the RISC-V Vector intrinsics specification. Additionally, these intrinsics + are now generated lazily, resulting a substantial improvement in + compile-time for code including the vector intrinsics header. +- Intrinsics added for the RISC-V scalar crypto ('K') extensions. +- Intrinsics added for the RISC-V CLZ and CTZ instructions in the Zbb + extension. +- An ABI lowering bug (resulting in incorrect LLVM IR generation) was fixed. + The bug could be triggered in particular circumstances in C++ when passing a + data-only struct that inherits from another struct. + SPIR-V Support in Clang ----------------------- diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/include/clang/Basic/DiagnosticSemaKinds.td rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/include/clang/Basic/DiagnosticSemaKinds.td --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/include/clang/Basic/DiagnosticSemaKinds.td 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/include/clang/Basic/DiagnosticSemaKinds.td 2023-01-24 23:05:56.000000000 +0000 @@ -419,7 +419,7 @@ InGroup, DefaultIgnore; def ext_implicit_function_decl_c99 : ExtWarn< "call to undeclared function %0; ISO C99 and later do not support implicit " - "function declarations">, InGroup, DefaultError; + "function declarations">, InGroup; def note_function_suggestion : Note<"did you mean %0?">; def err_ellipsis_first_param : Error< @@ -705,7 +705,7 @@ def ext_implicit_lib_function_decl_c99 : ExtWarn< "call to undeclared library function '%0' with type %1; ISO C99 and later " "do not support implicit function declarations">, - InGroup, DefaultError; + InGroup; def note_include_header_or_declare : Note< "include the header <%0> or explicitly provide a declaration for '%1'">; def note_previous_builtin_declaration : Note<"%0 is a builtin with type %1">; @@ -4359,7 +4359,7 @@ "a parameter list without types is only allowed in a function definition">; def ext_param_not_declared : ExtWarn< "parameter %0 was not declared, defaults to 'int'; ISO C99 and later do not " - "support implicit int">, InGroup, DefaultError; + "support implicit int">, InGroup; def err_param_default_argument : Error< "C does not support default arguments">; def err_param_default_argument_redefinition : Error< @@ -10029,7 +10029,7 @@ def note_method_sent_forward_class : Note<"method %0 is used for the forward class">; def ext_missing_type_specifier : ExtWarn< "type specifier missing, defaults to 'int'; ISO C99 and later do not support " - "implicit int">, InGroup, DefaultError; + "implicit int">, InGroup; def err_missing_type_specifier : Error< "a type specifier is required for all declarations">; def err_decimal_unsupported : Error< diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/AST/StmtPrinter.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/AST/StmtPrinter.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/AST/StmtPrinter.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/AST/StmtPrinter.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -1993,7 +1993,7 @@ cast(DRE->getDecl())->getTemplateSpecializationArgs(); assert(Args); - if (Args->size() != 1) { + if (Args->size() != 1 || Args->get(0).getKind() != TemplateArgument::Pack) { const TemplateParameterList *TPL = nullptr; if (!DRE->hadMultipleCandidates()) if (const auto *TD = dyn_cast(DRE->getDecl())) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Basic/CMakeLists.txt rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Basic/CMakeLists.txt --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Basic/CMakeLists.txt 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Basic/CMakeLists.txt 2023-01-24 23:05:56.000000000 +0000 @@ -110,3 +110,7 @@ omp_gen ) +target_link_libraries(clangBasic + PRIVATE + ${LLVM_ATOMIC_LIB} +) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/CodeGen/CGStmt.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/CodeGen/CGStmt.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/CodeGen/CGStmt.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/CodeGen/CGStmt.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -1509,6 +1509,21 @@ llvm::ConstantInt *CaseVal = Builder.getInt(S.getLHS()->EvaluateKnownConstInt(getContext())); + + // Emit debuginfo for the case value if it is an enum value. + const ConstantExpr *CE; + if (auto ICE = dyn_cast(S.getLHS())) + CE = dyn_cast(ICE->getSubExpr()); + else + CE = dyn_cast(S.getLHS()); + if (CE) { + if (auto DE = dyn_cast(CE->getSubExpr())) + if (CGDebugInfo *Dbg = getDebugInfo()) + if (CGM.getCodeGenOpts().hasReducedDebugInfo()) + Dbg->EmitGlobalVariable(DE->getDecl(), + APValue(llvm::APSInt(CaseVal->getValue()))); + } + if (SwitchLikelihood) SwitchLikelihood->push_back(Stmt::getLikelihood(Attrs)); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/CodeGen/CoverageMappingGen.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/CodeGen/CoverageMappingGen.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/CodeGen/CoverageMappingGen.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/CodeGen/CoverageMappingGen.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -1377,19 +1377,23 @@ // Extend into the condition before we propagate through it below - this is // needed to handle macros that generate the "if" but not the condition. - extendRegion(S->getCond()); + if (!S->isConsteval()) + extendRegion(S->getCond()); Counter ParentCount = getRegion().getCounter(); Counter ThenCount = getRegionCounter(S); - // Emitting a counter for the condition makes it easier to interpret the - // counter for the body when looking at the coverage. - propagateCounts(ParentCount, S->getCond()); - - // The 'then' count applies to the area immediately after the condition. - auto Gap = findGapAreaBetween(S->getRParenLoc(), getStart(S->getThen())); - if (Gap) - fillGapAreaWithCount(Gap->getBegin(), Gap->getEnd(), ThenCount); + if (!S->isConsteval()) { + // Emitting a counter for the condition makes it easier to interpret the + // counter for the body when looking at the coverage. + propagateCounts(ParentCount, S->getCond()); + + // The 'then' count applies to the area immediately after the condition. + Optional Gap = + findGapAreaBetween(S->getRParenLoc(), getStart(S->getThen())); + if (Gap) + fillGapAreaWithCount(Gap->getBegin(), Gap->getEnd(), ThenCount); + } extendRegion(S->getThen()); Counter OutCount = propagateCounts(ThenCount, S->getThen()); @@ -1398,9 +1402,9 @@ if (const Stmt *Else = S->getElse()) { bool ThenHasTerminateStmt = HasTerminateStmt; HasTerminateStmt = false; - // The 'else' count applies to the area immediately after the 'then'. - Gap = findGapAreaBetween(getEnd(S->getThen()), getStart(Else)); + Optional Gap = + findGapAreaBetween(getEnd(S->getThen()), getStart(Else)); if (Gap) fillGapAreaWithCount(Gap->getBegin(), Gap->getEnd(), ElseCount); extendRegion(Else); @@ -1416,9 +1420,11 @@ GapRegionCounter = OutCount; } - // Create Branch Region around condition. - createBranchRegion(S->getCond(), ThenCount, - subtractCounters(ParentCount, ThenCount)); + if (!S->isConsteval()) { + // Create Branch Region around condition. + createBranchRegion(S->getCond(), ThenCount, + subtractCounters(ParentCount, ThenCount)); + } } void VisitCXXTryStmt(const CXXTryStmt *S) { diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/CodeGen/TargetInfo.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/CodeGen/TargetInfo.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/CodeGen/TargetInfo.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/CodeGen/TargetInfo.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -7047,10 +7047,10 @@ // Empty records are ignored for parameter passing purposes. if (isEmptyRecord(getContext(), Ty, true)) { - Address Addr = Address(CGF.Builder.CreateLoad(VAListAddr), - getVAListElementType(CGF), SlotSize); - Addr = CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty)); - return Addr; + VAListAddr = CGF.Builder.CreateElementBitCast(VAListAddr, CGF.Int8PtrTy); + auto *Load = CGF.Builder.CreateLoad(VAListAddr); + Address Addr = Address(Load, CGF.Int8Ty, SlotSize); + return CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty)); } CharUnits TySize = getContext().getTypeSizeInChars(Ty); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -2139,31 +2139,21 @@ // and gcc-toolsets. if (SysRoot.empty() && TargetTriple.getOS() == llvm::Triple::Linux && D.getVFS().exists("/opt/rh")) { - // Find the directory in /opt/rh/ starting with gcc-toolset-* or - // devtoolset-* with the highest version number and add that - // one to our prefixes. - std::string ChosenToolsetDir; - unsigned ChosenToolsetVersion = 0; - std::error_code EC; - for (llvm::vfs::directory_iterator LI = D.getVFS().dir_begin("/opt/rh", EC), - LE; - !EC && LI != LE; LI = LI.increment(EC)) { - StringRef ToolsetDir = llvm::sys::path::filename(LI->path()); - unsigned ToolsetVersion; - if ((!ToolsetDir.startswith("gcc-toolset-") && - !ToolsetDir.startswith("devtoolset-")) || - ToolsetDir.substr(ToolsetDir.rfind('-') + 1) - .getAsInteger(10, ToolsetVersion)) - continue; - - if (ToolsetVersion > ChosenToolsetVersion) { - ChosenToolsetVersion = ToolsetVersion; - ChosenToolsetDir = "/opt/rh/" + ToolsetDir.str(); - } - } - - if (ChosenToolsetVersion > 0) - Prefixes.push_back(ChosenToolsetDir + "/root/usr"); + // TODO: We may want to remove this, since the functionality + // can be achieved using config files. + Prefixes.push_back("/opt/rh/gcc-toolset-12/root/usr"); + Prefixes.push_back("/opt/rh/gcc-toolset-11/root/usr"); + Prefixes.push_back("/opt/rh/gcc-toolset-10/root/usr"); + Prefixes.push_back("/opt/rh/devtoolset-12/root/usr"); + Prefixes.push_back("/opt/rh/devtoolset-11/root/usr"); + Prefixes.push_back("/opt/rh/devtoolset-10/root/usr"); + Prefixes.push_back("/opt/rh/devtoolset-9/root/usr"); + Prefixes.push_back("/opt/rh/devtoolset-8/root/usr"); + Prefixes.push_back("/opt/rh/devtoolset-7/root/usr"); + Prefixes.push_back("/opt/rh/devtoolset-6/root/usr"); + Prefixes.push_back("/opt/rh/devtoolset-4/root/usr"); + Prefixes.push_back("/opt/rh/devtoolset-3/root/usr"); + Prefixes.push_back("/opt/rh/devtoolset-2/root/usr"); } // Fall back to /usr which is used by most non-Solaris systems. diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Format/TokenAnnotator.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Format/TokenAnnotator.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Format/TokenAnnotator.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Format/TokenAnnotator.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -2329,25 +2329,6 @@ !PrevToken->MatchingParen) return TT_PointerOrReference; - // For "} &&" - if (PrevToken->is(tok::r_brace) && Tok.is(tok::ampamp)) { - const FormatToken *MatchingLBrace = PrevToken->MatchingParen; - - // We check whether there is a TemplateCloser(">") to indicate it's a - // template or not. If it's not a template, "&&" is likely a reference - // operator. - // struct {} &&ref = {}; - if (!MatchingLBrace) - return TT_PointerOrReference; - FormatToken *BeforeLBrace = MatchingLBrace->getPreviousNonComment(); - if (!BeforeLBrace || BeforeLBrace->isNot(TT_TemplateCloser)) - return TT_PointerOrReference; - - // If it is a template, "&&" is a binary operator. - // enable_if<>{} && ... - return TT_BinaryOperator; - } - if (PrevToken->Tok.isLiteral() || PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true, tok::kw_false, tok::r_brace)) { diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Sema/SemaExpr.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Sema/SemaExpr.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Sema/SemaExpr.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Sema/SemaExpr.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -17600,6 +17600,11 @@ DRSet.erase(E); return E; } + ExprResult TransformLambdaExpr(LambdaExpr *E) { + // Do not rebuild lambdas to avoid creating a new type. + // Lambdas have already been processed inside their eval context. + return E; + } bool AlwaysRebuild() { return false; } bool ReplacingOriginal() { return true; } bool AllowSkippingCXXConstructExpr() { diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Sema/SemaInit.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Sema/SemaInit.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Sema/SemaInit.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Sema/SemaInit.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -695,10 +695,10 @@ // member of reference type uninitialized, the program is // ill-formed. SemaRef.Diag(Loc, diag::err_init_reference_member_uninitialized) - << Field->getType() - << ILE->getSyntacticForm()->getSourceRange(); - SemaRef.Diag(Field->getLocation(), - diag::note_uninit_reference_member); + << Field->getType() + << (ILE->isSyntacticForm() ? ILE : ILE->getSyntacticForm()) + ->getSourceRange(); + SemaRef.Diag(Field->getLocation(), diag::note_uninit_reference_member); } hadError = true; return; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Sema/SemaLookup.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Sema/SemaLookup.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Sema/SemaLookup.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Sema/SemaLookup.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -939,11 +939,9 @@ // If this is a builtin on this (or all) targets, create the decl. if (unsigned BuiltinID = II->getBuiltinID()) { - // In C++, C2x, and OpenCL (spec v1.2 s6.9.f), we don't have any - // predefined library functions like 'malloc'. Instead, we'll just - // error. - if ((getLangOpts().CPlusPlus || getLangOpts().OpenCL || - getLangOpts().C2x) && + // In C++ and OpenCL (spec v1.2 s6.9.f), we don't have any predefined + // library functions like 'malloc'. Instead, we'll just error. + if ((getLangOpts().CPlusPlus || getLangOpts().OpenCL) && Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) return false; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Sema/SemaType.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Sema/SemaType.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Sema/SemaType.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Sema/SemaType.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -6443,6 +6443,9 @@ CurrTL = TL.getNextTypeLoc().getUnqualifiedLoc(); } + while (BTFTagAttributedTypeLoc TL = CurrTL.getAs()) + CurrTL = TL.getNextTypeLoc().getUnqualifiedLoc(); + while (DependentAddressSpaceTypeLoc TL = CurrTL.getAs()) { fillDependentAddressSpaceTypeLoc(TL, D.getTypeObject(i).getAttrs()); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -2839,6 +2839,12 @@ return; } + if (const auto *TPO = dyn_cast(D)) { + // FIXME: We should meaningfully implement this. + (void)TPO; + return; + } + llvm_unreachable("Support for this Decl not implemented."); } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -165,8 +165,8 @@ const unsigned OldPos = Pos; std::unique_ptr Arg(OptTable.ParseOneArg( ArgList, Pos, - /* Include */ ClangCLMode ? CoreOption | CLOption : 0, - /* Exclude */ ClangCLMode ? 0 : CLOption)); + /* Include */ ClangCLMode ? CoreOption | CLOption | CLDXCOption : 0, + /* Exclude */ ClangCLMode ? 0 : CLOption | CLDXCOption)); if (!Arg) continue; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Tooling/Syntax/Tokens.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Tooling/Syntax/Tokens.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/lib/Tooling/Syntax/Tokens.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/lib/Tooling/Syntax/Tokens.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -55,45 +55,140 @@ return {Begin, End}; } -// Finds the smallest expansion range that contains expanded tokens First and -// Last, e.g.: +// Finds the range within FID corresponding to expanded tokens [First, Last]. +// Prev precedes First and Next follows Last, these must *not* be included. +// If no range satisfies the criteria, returns an invalid range. +// // #define ID(x) x // ID(ID(ID(a1) a2)) // ~~ -> a1 // ~~ -> a2 // ~~~~~~~~~ -> a1 a2 -SourceRange findCommonRangeForMacroArgs(const syntax::Token &First, - const syntax::Token &Last, - const SourceManager &SM) { - SourceRange Res; - auto FirstLoc = First.location(), LastLoc = Last.location(); - // Keep traversing up the spelling chain as longs as tokens are part of the - // same expansion. - while (!FirstLoc.isFileID() && !LastLoc.isFileID()) { - auto ExpInfoFirst = SM.getSLocEntry(SM.getFileID(FirstLoc)).getExpansion(); - auto ExpInfoLast = SM.getSLocEntry(SM.getFileID(LastLoc)).getExpansion(); - // Stop if expansions have diverged. - if (ExpInfoFirst.getExpansionLocStart() != - ExpInfoLast.getExpansionLocStart()) +SourceRange spelledForExpandedSlow(SourceLocation First, SourceLocation Last, + SourceLocation Prev, SourceLocation Next, + FileID TargetFile, + const SourceManager &SM) { + // There are two main parts to this algorithm: + // - identifying which spelled range covers the expanded tokens + // - validating that this range doesn't cover any extra tokens (First/Last) + // + // We do these in order. However as we transform the expanded range into the + // spelled one, we adjust First/Last so the validation remains simple. + + assert(SM.getSLocEntry(TargetFile).isFile()); + // In most cases, to select First and Last we must return their expansion + // range, i.e. the whole of any macros they are included in. + // + // When First and Last are part of the *same macro arg* of a macro written + // in TargetFile, we that slice of the arg, i.e. their spelling range. + // + // Unwrap such macro calls. If the target file has A(B(C)), the + // SourceLocation stack of a token inside C shows us the expansion of A first, + // then B, then any macros inside C's body, then C itself. + // (This is the reverse of the order the PP applies the expansions in). + while (First.isMacroID() && Last.isMacroID()) { + auto DecFirst = SM.getDecomposedLoc(First); + auto DecLast = SM.getDecomposedLoc(Last); + auto &ExpFirst = SM.getSLocEntry(DecFirst.first).getExpansion(); + auto &ExpLast = SM.getSLocEntry(DecLast.first).getExpansion(); + + if (!ExpFirst.isMacroArgExpansion() || !ExpLast.isMacroArgExpansion()) + break; + // Locations are in the same macro arg if they expand to the same place. + // (They may still have different FileIDs - an arg can have >1 chunks!) + if (ExpFirst.getExpansionLocStart() != ExpLast.getExpansionLocStart()) break; - // Do not continue into macro bodies. - if (!ExpInfoFirst.isMacroArgExpansion() || - !ExpInfoLast.isMacroArgExpansion()) + // Careful, given: + // #define HIDE ID(ID(a)) + // ID(ID(HIDE)) + // The token `a` is wrapped in 4 arg-expansions, we only want to unwrap 2. + // We distinguish them by whether the macro expands into the target file. + // Fortunately, the target file ones will always appear first. + auto &ExpMacro = + SM.getSLocEntry(SM.getFileID(ExpFirst.getExpansionLocStart())) + .getExpansion(); + if (ExpMacro.getExpansionLocStart().isMacroID()) break; - FirstLoc = SM.getImmediateSpellingLoc(FirstLoc); - LastLoc = SM.getImmediateSpellingLoc(LastLoc); - // Update the result afterwards, as we want the tokens that triggered the - // expansion. - Res = {FirstLoc, LastLoc}; + // Replace each endpoint with its spelling inside the macro arg. + // (This is getImmediateSpellingLoc without repeating lookups). + First = ExpFirst.getSpellingLoc().getLocWithOffset(DecFirst.second); + Last = ExpLast.getSpellingLoc().getLocWithOffset(DecLast.second); + + // Now: how do we adjust the previous/next bounds? Three cases: + // A) If they are also part of the same macro arg, we translate them too. + // This will ensure that we don't select any macros nested within the + // macro arg that cover extra tokens. Critical case: + // #define ID(X) X + // ID(prev target) // selecting 'target' succeeds + // #define LARGE ID(prev target) + // LARGE // selecting 'target' fails. + // B) They are not in the macro at all, then their expansion range is a + // sibling to it, and we can safely substitute that. + // #define PREV prev + // #define ID(X) X + // PREV ID(target) // selecting 'target' succeeds. + // #define LARGE PREV ID(target) + // LARGE // selecting 'target' fails. + // C) They are in a different arg of this macro, or the macro body. + // Now selecting the whole macro arg is fine, but the whole macro is not. + // Model this by setting using the edge of the macro call as the bound. + // #define ID2(X, Y) X Y + // ID2(prev, target) // selecting 'target' succeeds + // #define LARGE ID2(prev, target) + // LARGE // selecting 'target' fails + auto AdjustBound = [&](SourceLocation &Bound) { + if (Bound.isInvalid() || !Bound.isMacroID()) // Non-macro must be case B. + return; + auto DecBound = SM.getDecomposedLoc(Bound); + auto &ExpBound = SM.getSLocEntry(DecBound.first).getExpansion(); + if (ExpBound.isMacroArgExpansion() && + ExpBound.getExpansionLocStart() == ExpFirst.getExpansionLocStart()) { + // Case A: translate to (spelling) loc within the macro arg. + Bound = ExpBound.getSpellingLoc().getLocWithOffset(DecBound.second); + return; + } + while (Bound.isMacroID()) { + SourceRange Exp = SM.getImmediateExpansionRange(Bound).getAsRange(); + if (Exp.getBegin() == ExpMacro.getExpansionLocStart()) { + // Case B: bounds become the macro call itself. + Bound = (&Bound == &Prev) ? Exp.getBegin() : Exp.getEnd(); + return; + } + // Either case C, or expansion location will later find case B. + // We choose the upper bound for Prev and the lower one for Next: + // ID(prev) target ID(next) + // ^ ^ + // new-prev new-next + Bound = (&Bound == &Prev) ? Exp.getEnd() : Exp.getBegin(); + } + }; + AdjustBound(Prev); + AdjustBound(Next); + } + + // In all remaining cases we need the full containing macros. + // If this overlaps Prev or Next, then no range is possible. + SourceRange Candidate = + SM.getExpansionRange(SourceRange(First, Last)).getAsRange(); + auto DecFirst = SM.getDecomposedExpansionLoc(Candidate.getBegin()); + auto DecLast = SM.getDecomposedLoc(Candidate.getEnd()); + // Can end up in the wrong file due to bad input or token-pasting shenanigans. + if (Candidate.isInvalid() || DecFirst.first != TargetFile || DecLast.first != TargetFile) + return SourceRange(); + // Check bounds, which may still be inside macros. + if (Prev.isValid()) { + auto Dec = SM.getDecomposedLoc(SM.getExpansionRange(Prev).getBegin()); + if (Dec.first != DecFirst.first || Dec.second >= DecFirst.second) + return SourceRange(); + } + if (Next.isValid()) { + auto Dec = SM.getDecomposedLoc(SM.getExpansionRange(Next).getEnd()); + if (Dec.first != DecLast.first || Dec.second <= DecLast.second) + return SourceRange(); } - // Normally mapping back to expansion location here only changes FileID, as - // we've already found some tokens expanded from the same macro argument, and - // they should map to a consecutive subset of spelled tokens. Unfortunately - // SourceManager::isBeforeInTranslationUnit discriminates sourcelocations - // based on their FileID in addition to offsets. So even though we are - // referring to same tokens, SourceManager might tell us that one is before - // the other if they've got different FileIDs. - return SM.getExpansionRange(CharSourceRange(Res, true)).getAsRange(); + // Now we know that Candidate is a file range that covers [First, Last] + // without encroaching on {Prev, Next}. Ship it! + return Candidate; } } // namespace @@ -363,51 +458,50 @@ // of the range, bail out in that case. if (Expanded.empty()) return llvm::None; + const syntax::Token *First = &Expanded.front(); + const syntax::Token *Last = &Expanded.back(); + const syntax::Token *FirstSpelled, *LastSpelled; + const TokenBuffer::Mapping *FirstMapping, *LastMapping; + std::tie(FirstSpelled, FirstMapping) = spelledForExpandedToken(First); + std::tie(LastSpelled, LastMapping) = spelledForExpandedToken(Last); - const syntax::Token *BeginSpelled; - const Mapping *BeginMapping; - std::tie(BeginSpelled, BeginMapping) = - spelledForExpandedToken(&Expanded.front()); - - const syntax::Token *LastSpelled; - const Mapping *LastMapping; - std::tie(LastSpelled, LastMapping) = - spelledForExpandedToken(&Expanded.back()); - - FileID FID = SourceMgr->getFileID(BeginSpelled->location()); + FileID FID = SourceMgr->getFileID(FirstSpelled->location()); // FIXME: Handle multi-file changes by trying to map onto a common root. if (FID != SourceMgr->getFileID(LastSpelled->location())) return llvm::None; const MarkedFile &File = Files.find(FID)->second; - // If both tokens are coming from a macro argument expansion, try and map to - // smallest part of the macro argument. BeginMapping && LastMapping check is - // only for performance, they are a prerequisite for Expanded.front() and - // Expanded.back() being part of a macro arg expansion. - if (BeginMapping && LastMapping && - SourceMgr->isMacroArgExpansion(Expanded.front().location()) && - SourceMgr->isMacroArgExpansion(Expanded.back().location())) { - auto CommonRange = findCommonRangeForMacroArgs(Expanded.front(), - Expanded.back(), *SourceMgr); - // It might be the case that tokens are arguments of different macro calls, - // in that case we should continue with the logic below instead of returning - // an empty range. - if (CommonRange.isValid()) - return getTokensCovering(File.SpelledTokens, CommonRange, *SourceMgr); + // If the range is within one macro argument, the result may be only part of a + // Mapping. We must use the general (SourceManager-based) algorithm. + if (FirstMapping && FirstMapping == LastMapping && + SourceMgr->isMacroArgExpansion(First->location()) && + SourceMgr->isMacroArgExpansion(Last->location())) { + // We use excluded Prev/Next token for bounds checking. + SourceLocation Prev = (First == &ExpandedTokens.front()) + ? SourceLocation() + : (First - 1)->location(); + SourceLocation Next = (Last == &ExpandedTokens.back()) + ? SourceLocation() + : (Last + 1)->location(); + SourceRange Range = spelledForExpandedSlow( + First->location(), Last->location(), Prev, Next, FID, *SourceMgr); + if (Range.isInvalid()) + return llvm::None; + return getTokensCovering(File.SpelledTokens, Range, *SourceMgr); } + // Otherwise, use the fast version based on Mappings. // Do not allow changes that doesn't cover full expansion. - unsigned BeginExpanded = Expanded.begin() - ExpandedTokens.data(); - unsigned EndExpanded = Expanded.end() - ExpandedTokens.data(); - if (BeginMapping && BeginExpanded != BeginMapping->BeginExpanded) + unsigned FirstExpanded = Expanded.begin() - ExpandedTokens.data(); + unsigned LastExpanded = Expanded.end() - ExpandedTokens.data(); + if (FirstMapping && FirstExpanded != FirstMapping->BeginExpanded) return llvm::None; - if (LastMapping && LastMapping->EndExpanded != EndExpanded) + if (LastMapping && LastMapping->EndExpanded != LastExpanded) return llvm::None; - // All is good, return the result. return llvm::makeArrayRef( - BeginMapping ? File.SpelledTokens.data() + BeginMapping->BeginSpelled - : BeginSpelled, + FirstMapping ? File.SpelledTokens.data() + FirstMapping->BeginSpelled + : FirstSpelled, LastMapping ? File.SpelledTokens.data() + LastMapping->EndSpelled : LastSpelled + 1); } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Analysis/template-param-objects.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Analysis/template-param-objects.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Analysis/template-param-objects.cpp 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Analysis/template-param-objects.cpp 2023-01-24 23:05:57.000000000 +0000 @@ -0,0 +1,33 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \ +// RUN: -analyzer-config eagerly-assume=false -std=c++20 -verify %s + +template void clang_analyzer_dump(T); +void clang_analyzer_eval(bool); + +struct Box { + int value; +}; +bool operator ==(Box lhs, Box rhs) { + return lhs.value == rhs.value; +} +template void dumps() { + clang_analyzer_dump(V); // expected-warning {{lazyCompoundVal}} + clang_analyzer_dump(&V); // expected-warning {{Unknown}} + clang_analyzer_dump(V.value); // expected-warning {{Unknown}} FIXME: It should be '6 S32b'. + clang_analyzer_dump(&V.value); // expected-warning {{Unknown}} +} +template void dumps(); + +// [temp.param].7.3.2: +// "All such template parameters in the program of the same type with the +// same value denote the same template parameter object." +template void stable_addresses() { + clang_analyzer_eval(&A1 == &A2); // expected-warning {{UNKNOWN}} FIXME: It should be TRUE. + clang_analyzer_eval(&B1 == &B2); // expected-warning {{UNKNOWN}} FIXME: It should be TRUE. + clang_analyzer_eval(&A1 == &B2); // expected-warning {{UNKNOWN}} FIXME: It should be FALSE. + + clang_analyzer_eval(A1 == A2); // expected-warning {{UNKNOWN}} FIXME: It should be TRUE. + clang_analyzer_eval(B1 == B2); // expected-warning {{UNKNOWN}} FIXME: It should be TRUE. + clang_analyzer_eval(A1 == B2); // expected-warning {{UNKNOWN}} FIXME: It should be FALSE. +} +template void stable_addresses(); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/C/drs/dr0xx.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/C/drs/dr0xx.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/C/drs/dr0xx.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/C/drs/dr0xx.c 2023-01-24 23:05:57.000000000 +0000 @@ -110,7 +110,7 @@ * of treated as declaring a parameter of type 'int (*)(dr009_t);' */ typedef int dr009_t; -void dr009_f((dr009_t)); /* c99untilc2x-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} +void dr009_f((dr009_t)); /* c99untilc2x-warning {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} c2xandup-error {{a type specifier is required for all declarations}} */ /* WG14 DR010: diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/C/drs/dr1xx.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/C/drs/dr1xx.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/C/drs/dr1xx.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/C/drs/dr1xx.c 2023-01-24 23:05:57.000000000 +0000 @@ -369,7 +369,7 @@ int i; i = undeclared; /* expected-error {{use of undeclared identifier 'undeclared'}} */ sdfsdfsf = 1; /* expected-error {{use of undeclared identifier 'sdfsdfsf'}} */ - i = also_undeclared(); /* c99untilc2x-error {{call to undeclared function 'also_undeclared'; ISO C99 and later do not support implicit function declarations}} + i = also_undeclared(); /* c99untilc2x-warning {{call to undeclared function 'also_undeclared'; ISO C99 and later do not support implicit function declarations}} c2xandup-error {{use of undeclared identifier 'also_undeclared'}} */ } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/CodeGen/arm-vaarg.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/CodeGen/arm-vaarg.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/CodeGen/arm-vaarg.c 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/CodeGen/arm-vaarg.c 2023-01-24 23:05:57.000000000 +0000 @@ -0,0 +1,23 @@ +// RUN: %clang -Xclang -no-opaque-pointers -mfloat-abi=soft -target arm-linux-gnu -emit-llvm -S -o - %s | FileCheck %s + +struct Empty {}; + +struct Empty emptyvar; + +void take_args(int a, ...) { +// CHECK: [[ALLOCA_VA_LIST:%[a-zA-Z0-9._]+]] = alloca %struct.__va_list, align 4 +// CHECK: call void @llvm.va_start +// CHECK-NEXT: [[AP_ADDR:%[a-zA-Z0-9._]+]] = bitcast %struct.__va_list* [[ALLOCA_VA_LIST]] to i8** +// CHECK-NEXT: [[LOAD_AP:%[a-zA-Z0-9._]+]] = load i8*, i8** [[AP_ADDR]], align 4 +// CHECK-NEXT: [[EMPTY_PTR:%[a-zA-Z0-9._]+]] = bitcast i8* [[LOAD_AP]] to %struct.Empty* + + // It's conceivable that EMPTY_PTR may not actually be a valid pointer + // (e.g. it's at the very bottom of the stack and the next page is + // invalid). This doesn't matter provided it's never loaded (there's no + // well-defined way to tell), but it becomes a problem if we do try to use it. +// CHECK-NOT: load %struct.Empty, %struct.Empty* [[EMPTY_PTR]] + __builtin_va_list l; + __builtin_va_start(l, a); + emptyvar = __builtin_va_arg(l, struct Empty); + __builtin_va_end(l); +} diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/CodeGen/attr-btf_type_tag-func-ptr.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/CodeGen/attr-btf_type_tag-func-ptr.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/CodeGen/attr-btf_type_tag-func-ptr.c 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/CodeGen/attr-btf_type_tag-func-ptr.c 2023-01-24 23:05:57.000000000 +0000 @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s + +struct t { + int (__attribute__((btf_type_tag("rcu"))) *f)(); + int a; +}; +int foo(struct t *arg) { + return arg->a; +} + +// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "f" +// CHECK-SAME: baseType: ![[L18:[0-9]+]] +// CHECK: ![[L18]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[#]], size: [[#]], annotations: ![[L21:[0-9]+]]) +// CHECK: ![[L21]] = !{![[L22:[0-9]+]]} +// CHECK: ![[L22]] = !{!"btf_type_tag", !"rcu"} diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/CodeGen/builtins-arm-msvc-compat-only.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/CodeGen/builtins-arm-msvc-compat-only.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/CodeGen/builtins-arm-msvc-compat-only.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/CodeGen/builtins-arm-msvc-compat-only.c 2023-01-24 23:05:57.000000000 +0000 @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -triple thumbv7-windows -fms-extensions -emit-llvm -o - %s \ // RUN: | FileCheck %s -check-prefix CHECK-MSVC -// RUN: not %clang_cc1 -triple armv7-eabi -emit-llvm %s -o /dev/null 2>&1 \ +// RUN: %clang_cc1 -triple armv7-eabi -emit-llvm %s -o /dev/null 2>&1 \ // RUN: | FileCheck %s -check-prefix CHECK-EABI // REQUIRES: arm-registered-target @@ -9,7 +9,7 @@ } // CHECK-MSVC: call void asm sideeffect ".inst.n 0xDEFE", ""() -// CHECK-EABI: error: call to undeclared function '__emit' +// CHECK-EABI: warning: call to undeclared function '__emit' void emit_truncated() { __emit(0x11110000); // movs r0, r0 diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/CodeGen/debug-info-enum-case-val.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/CodeGen/debug-info-enum-case-val.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/CodeGen/debug-info-enum-case-val.c 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/CodeGen/debug-info-enum-case-val.c 2023-01-24 23:05:57.000000000 +0000 @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s + +enum { A = 1 }; +int func1(int a) { + switch(a) { + case A: return 10; + default: break; + } + return 0; +} +// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type +// CHECK-SAME: elements: [[TEST1_ENUMS:![0-9]*]] +// CHECK: [[TEST1_ENUMS]] = !{[[TEST1_E:![0-9]*]]} +// CHECK: [[TEST1_E]] = !DIEnumerator(name: "A", value: 1) + +// Test ImplicitCast of switch case enum value +enum { B = 2 }; +typedef unsigned long long __t1; +typedef __t1 __t2; +int func2(__t2 a) { + switch(a) { + case B: return 10; + default: break; + } + return 0; +} +// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type +// CHECK-SAME: elements: [[TEST2_ENUMS:![0-9]*]] +// CHECK: [[TEST2_ENUMS]] = !{[[TEST2_E:![0-9]*]]} +// CHECK: [[TEST2_E]] = !DIEnumerator(name: "B", value: 2) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/CodeGen/neon-crypto.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/CodeGen/neon-crypto.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/CodeGen/neon-crypto.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/CodeGen/neon-crypto.c 2023-01-24 23:05:57.000000000 +0000 @@ -14,7 +14,7 @@ uint8x16_t test_vaeseq_u8(uint8x16_t data, uint8x16_t key) { // CHECK-LABEL: @test_vaeseq_u8 - // CHECK-NO-CRYPTO: error: call to undeclared function 'vaeseq_u8' + // CHECK-NO-CRYPTO: warning: call to undeclared function 'vaeseq_u8' return vaeseq_u8(data, key); // CHECK: call <16 x i8> @llvm.{{arm.neon|aarch64.crypto}}.aese(<16 x i8> %data, <16 x i8> %key) } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/CodeGen/PowerPC/builtins-ppc-p8vector.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/CodeGen/PowerPC/builtins-ppc-p8vector.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/CodeGen/PowerPC/builtins-ppc-p8vector.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/CodeGen/PowerPC/builtins-ppc-p8vector.c 2023-01-24 23:05:57.000000000 +0000 @@ -143,7 +143,7 @@ res_vui = vec_mergee(vui, vui); // CHECK: @llvm.ppc.altivec.vperm // CHECK-LE: @llvm.ppc.altivec.vperm -// CHECK-PPC: error: call to undeclared function 'vec_mergee' +// CHECK-PPC: warning: call to undeclared function 'vec_mergee' res_vbll = vec_mergee(vbll, vbll); // CHECK: @llvm.ppc.altivec.vperm @@ -177,7 +177,7 @@ res_vui = vec_mergeo(vui, vui); // CHECK: @llvm.ppc.altivec.vperm // CHECK-LE: @llvm.ppc.altivec.vperm -// CHECK-PPC: error: call to undeclared function 'vec_mergeo' +// CHECK-PPC: warning: call to undeclared function 'vec_mergeo' /* vec_cmpeq */ res_vbll = vec_cmpeq(vbll, vbll); @@ -403,7 +403,7 @@ res_vsc = vec_cntlz(vsc); // CHECK: call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> %{{.+}}, i1 false) // CHECK-LE: call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> %{{.+}}, i1 false) -// CHECK-PPC: error: call to undeclared function 'vec_cntlz' +// CHECK-PPC: warning: call to undeclared function 'vec_cntlz' res_vuc = vec_cntlz(vuc); // CHECK: call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> %{{.+}}, i1 false) @@ -754,19 +754,19 @@ res_vsi = vec_vpksdss(vsll, vsll); // CHECK: llvm.ppc.altivec.vpksdss // CHECK-LE: llvm.ppc.altivec.vpksdss -// CHECK-PPC: error: call to undeclared function 'vec_vpksdss' +// CHECK-PPC: warning: call to undeclared function 'vec_vpksdss' /* vec_vpksdus */ res_vui = vec_vpksdus(vsll, vsll); // CHECK: llvm.ppc.altivec.vpksdus // CHECK-LE: llvm.ppc.altivec.vpksdus -// CHECK-PPC: error: call to undeclared function 'vec_vpksdus' +// CHECK-PPC: warning: call to undeclared function 'vec_vpksdus' /* vec_vpkudum */ res_vsi = vec_vpkudum(vsll, vsll); // CHECK: vperm // CHECK-LE: vperm -// CHECK-PPC: error: call to undeclared function 'vec_vpkudum' +// CHECK-PPC: warning: call to undeclared function 'vec_vpkudum' res_vui = vec_vpkudum(vull, vull); // CHECK: vperm @@ -775,13 +775,13 @@ res_vui = vec_vpkudus(vull, vull); // CHECK: llvm.ppc.altivec.vpkudus // CHECK-LE: llvm.ppc.altivec.vpkudus -// CHECK-PPC: error: call to undeclared function 'vec_vpkudus' +// CHECK-PPC: warning: call to undeclared function 'vec_vpkudus' /* vec_vupkhsw */ res_vsll = vec_vupkhsw(vsi); // CHECK: llvm.ppc.altivec.vupkhsw // CHECK-LE: llvm.ppc.altivec.vupklsw -// CHECK-PPC: error: call to undeclared function 'vec_vupkhsw' +// CHECK-PPC: warning: call to undeclared function 'vec_vupkhsw' res_vbll = vec_vupkhsw(vbi); // CHECK: llvm.ppc.altivec.vupkhsw @@ -791,7 +791,7 @@ res_vsll = vec_vupklsw(vsi); // CHECK: llvm.ppc.altivec.vupklsw // CHECK-LE: llvm.ppc.altivec.vupkhsw -// CHECK-PPC: error: call to undeclared function 'vec_vupklsw' +// CHECK-PPC: warning: call to undeclared function 'vec_vupklsw' res_vbll = vec_vupklsw(vbi); // CHECK: llvm.ppc.altivec.vupklsw @@ -845,7 +845,7 @@ // CHECK: xor <16 x i8> [[T1]], // CHECK-LE: [[T1:%.+]] = and <16 x i8> // CHECK-LE: xor <16 x i8> [[T1]], -// CHECK-PPC: error: call to undeclared function 'vec_nand' +// CHECK-PPC: warning: call to undeclared function 'vec_nand' res_vbc = vec_nand(vbc, vbc); // CHECK: [[T1:%.+]] = and <16 x i8> @@ -937,7 +937,7 @@ // CHECK: or <16 x i8> {{%.+}}, [[T1]] // CHECK-LE: [[T1:%.+]] = xor <16 x i8> {{%.+}}, // CHECK-LE: or <16 x i8> {{%.+}}, [[T1]] -// CHECK-PPC: error: call to undeclared function 'vec_orc' +// CHECK-PPC: warning: call to undeclared function 'vec_orc' res_vsc = vec_orc(vsc, vbc); // CHECK: [[T1:%.+]] = xor <16 x i8> {{%.+}}, @@ -1166,7 +1166,7 @@ res_vsll = vec_vbpermq(vuc, vuc); // CHECK: llvm.ppc.altivec.vbpermq // CHECK-LE: llvm.ppc.altivec.vbpermq -// CHECK-PPC: error: call to undeclared function 'vec_vbpermq' +// CHECK-PPC: warning: call to undeclared function 'vec_vbpermq' /* vec_vgbbd */ res_vsc = vec_vgbbd(vsc); @@ -1176,12 +1176,12 @@ res_vuc = vec_vgbbd(vuc); // CHECK: llvm.ppc.altivec.vgbbd // CHECK-LE: llvm.ppc.altivec.vgbbd -// CHECK-PPC: error: call to undeclared function 'vec_vgbbd' +// CHECK-PPC: warning: call to undeclared function 'vec_vgbbd' res_vuc = vec_gb(vuc); // CHECK: llvm.ppc.altivec.vgbbd // CHECK-LE: llvm.ppc.altivec.vgbbd -// CHECK-PPC: error: call to undeclared function 'vec_gb' +// CHECK-PPC: warning: call to undeclared function 'vec_gb' res_vsll = vec_gbb(vsll); // CHECK: llvm.ppc.altivec.vgbbd diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/CoverageMapping/if.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/CoverageMapping/if.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/CoverageMapping/if.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/CoverageMapping/if.cpp 2023-01-24 23:05:57.000000000 +0000 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++1z -triple %itanium_abi_triple -main-file-name if.cpp %s | FileCheck %s +// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++2b -triple %itanium_abi_triple -main-file-name if.cpp %s | FileCheck %s int nop() { return 0; } @@ -13,6 +13,22 @@ ++j; // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:7 -> [[@LINE-1]]:8 = #1, (#0 - #1) } // CHECK-NEXT: [[@LINE-2]]:9 -> [[@LINE-1]]:5 = #1 // CHECK-NEXT: [[@LINE-2]]:5 -> [[@LINE-2]]:8 = #1 + +// FIXME: Do not generate coverage for discarded branches in if consteval and if constexpr statements +constexpr int check_consteval(int i) { + if consteval { + i++; + } + if !consteval { + i++; + } + if consteval { + return 42; + } else { + return i; + } +} + // CHECK-LABEL: main: int main() { // CHECK: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0 int i = 0; @@ -50,6 +66,10 @@ // CHECK-NEXT: File 0, [[@LINE+1]]:14 -> [[@LINE+1]]:20 = #6 i = i == 0?i + 12:i + 10; // CHECK-NEXT: File 0, [[@LINE]]:21 -> [[@LINE]]:27 = (#0 - #6) + // GH-57377 + constexpr int c_i = check_consteval(0); + check_consteval(i); + return 0; } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Driver/cxx_for_opencl.clcpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Driver/cxx_for_opencl.clcpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Driver/cxx_for_opencl.clcpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Driver/cxx_for_opencl.clcpp 2023-01-24 23:05:58.000000000 +0000 @@ -13,6 +13,6 @@ auto a = get_local_id(1); #ifndef __OPENCL_CPP_VERSION__ //expected-error@-2{{OpenCL C version 2.0 does not support the 'auto' storage class specifier}} -//expected-error@-3{{type specifier missing, defaults to 'int'}} +//expected-warning@-3{{type specifier missing, defaults to 'int'}} #endif } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/FixIt/fixit.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/FixIt/fixit.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/FixIt/fixit.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/FixIt/fixit.c 2023-01-24 23:05:58.000000000 +0000 @@ -29,7 +29,7 @@ // CHECK: int x // CHECK: int y -void f1(x, y) // expected-error 2{{was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}} +void f1(x, y) // expected-warning 2{{was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}} { } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Frontend/fixed_point_errors.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Frontend/fixed_point_errors.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Frontend/fixed_point_errors.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Frontend/fixed_point_errors.c 2023-01-24 23:05:58.000000000 +0000 @@ -228,9 +228,9 @@ // Using auto auto auto_fract = 0r; // expected-error{{invalid suffix 'r' on integer constant}} - // expected-error@-1{{type specifier missing, defaults to 'int'}} + // expected-warning@-1{{type specifier missing, defaults to 'int'}} auto auto_accum = 0k; // expected-error{{invalid suffix 'k' on integer constant}} - // expected-error@-1{{type specifier missing, defaults to 'int'}} + // expected-warning@-1{{type specifier missing, defaults to 'int'}} } // Ok conversions diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Frontend/fixed_point_not_enabled.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Frontend/fixed_point_not_enabled.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Frontend/fixed_point_not_enabled.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Frontend/fixed_point_not_enabled.c 2023-01-24 23:05:58.000000000 +0000 @@ -11,7 +11,7 @@ // Aliased fixed point types short _Accum short_accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}} _Accum accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}} - // expected-error@-1{{type specifier missing, defaults to 'int'}} + // expected-warning@-1{{type specifier missing, defaults to 'int'}} long _Accum long_accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}} // Cannot use fixed point suffixes diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Frontend/system-header-line-directive.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Frontend/system-header-line-directive.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Frontend/system-header-line-directive.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Frontend/system-header-line-directive.c 2023-01-24 23:05:58.000000000 +0000 @@ -3,7 +3,7 @@ #include #include -// expected-error@line-directive.h:* {{type specifier missing, defaults to 'int'}} +// expected-warning@line-directive.h:* {{type specifier missing, defaults to 'int'}} #include "line-directive.h" // This tests that "#line" directives in system headers preserve system diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Headers/arm-cmse-header-ns.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Headers/arm-cmse-header-ns.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Headers/arm-cmse-header-ns.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Headers/arm-cmse-header-ns.c 2023-01-24 23:05:58.000000000 +0000 @@ -1,4 +1,4 @@ -// RUN: not %clang_cc1 -triple thumbv8m.base-eabi -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-c %s +// RUN: %clang_cc1 -triple thumbv8m.base-eabi -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-c %s // RUN: not %clang_cc1 -triple thumbv8m.base-eabi -fsyntax-only -x c++ %s 2>&1 | FileCheck --check-prefix=CHECK-cpp %s #include @@ -16,10 +16,10 @@ cmse_TTAT(p); cmse_TTA_fptr(fptr); cmse_TTAT_fptr(fptr); -// CHECK-c: error: call to undeclared function 'cmse_TTA' -// CHECK-c: error: call to undeclared function 'cmse_TTAT' -// CHECK-c: error: call to undeclared function 'cmse_TTA_fptr' -// CHECK-c: error: call to undeclared function 'cmse_TTAT_fptr' +// CHECK-c: warning: call to undeclared function 'cmse_TTA' +// CHECK-c: warning: call to undeclared function 'cmse_TTAT' +// CHECK-c: warning: call to undeclared function 'cmse_TTA_fptr' +// CHECK-c: warning: call to undeclared function 'cmse_TTAT_fptr' // CHECK-cpp: error: use of undeclared identifier 'cmse_TTA' // CHECK-cpp: error: use of undeclared identifier 'cmse_TTAT' // CHECK-cpp: error: use of undeclared identifier 'cmse_TTA_fptr' diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Modules/config_macros.m rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Modules/config_macros.m --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Modules/config_macros.m 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Modules/config_macros.m 2023-01-24 23:05:59.000000000 +0000 @@ -5,7 +5,7 @@ } char *test_bar(void) { - return bar(); // expected-error{{call to undeclared function 'bar'; ISO C99 and later do not support implicit function declarations}} \ + return bar(); // expected-warning{{call to undeclared function 'bar'; ISO C99 and later do not support implicit function declarations}} \ // expected-error{{incompatible integer to pointer conversion}} } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Modules/malformed-overload.m rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Modules/malformed-overload.m --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Modules/malformed-overload.m 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Modules/malformed-overload.m 2023-01-24 23:05:59.000000000 +0000 @@ -1,6 +1,6 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fsyntax-only -I%S/Inputs/malformed-overload -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Wno-strict-prototypes -verify %s -NSLog(@"%@", path); // expected-error {{expected parameter declarator}} expected-error {{expected ')'}} expected-error {{type specifier missing}} expected-warning {{incompatible redeclaration}} expected-note {{to match this '('}} expected-note {{'NSLog' is a builtin with type}} +NSLog(@"%@", path); // expected-error {{expected parameter declarator}} expected-error {{expected ')'}} expected-warning {{type specifier missing}} expected-warning {{incompatible redeclaration}} expected-note {{to match this '('}} expected-note {{'NSLog' is a builtin with type}} #import "X.h" @class NSString; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Modules/modulemap-locations.m rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Modules/modulemap-locations.m --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Modules/modulemap-locations.m 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Modules/modulemap-locations.m 2023-01-24 23:05:59.000000000 +0000 @@ -12,9 +12,7 @@ void test(void) { will_be_found1(); - wont_be_found1(); // expected-error{{call to undeclared function 'wont_be_found1'; ISO C99 and later do not support implicit function declarations}} \ - expected-note {{did you mean 'will_be_found1'?}} \ - expected-note@Inputs/ModuleMapLocations/Module_ModuleMap/a.h:1 {{'will_be_found1' declared here}} + wont_be_found1(); // expected-warning{{call to undeclared function 'wont_be_found1'; ISO C99 and later do not support implicit function declarations}} will_be_found2(); - wont_be_found2(); // expected-error{{call to undeclared function 'wont_be_found2'; ISO C99 and later do not support implicit function declarations}} + wont_be_found2(); // expected-warning{{call to undeclared function 'wont_be_found2'; ISO C99 and later do not support implicit function declarations}} } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/OpenMP/declare_mapper_messages.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/OpenMP/declare_mapper_messages.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/OpenMP/declare_mapper_messages.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/OpenMP/declare_mapper_messages.c 2023-01-24 23:05:59.000000000 +0000 @@ -42,9 +42,9 @@ {} #pragma omp target map(mapper:vv) // expected-error {{expected '(' after 'mapper'}} {} -#pragma omp target map(mapper( :vv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-error {{call to undeclared function 'mapper'}} expected-note {{to match this '('}} +#pragma omp target map(mapper( :vv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-warning {{call to undeclared function 'mapper'}} expected-note {{to match this '('}} {} -#pragma omp target map(mapper(aa :vv) // expected-error {{use of undeclared identifier 'aa'}} expected-error {{expected ')'}} expected-error {{call to undeclared function 'mapper'}} expected-note {{to match this '('}} +#pragma omp target map(mapper(aa :vv) // expected-error {{use of undeclared identifier 'aa'}} expected-error {{expected ')'}} expected-warning {{call to undeclared function 'mapper'}} expected-note {{to match this '('}} {} #pragma omp target map(mapper(ab) :vv) // expected-error {{missing map type}} expected-error {{cannot find a valid user-defined mapper for type 'struct vec' with name 'ab'}} {} diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Parser/altivec.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Parser/altivec.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Parser/altivec.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Parser/altivec.c 2023-01-24 23:05:59.000000000 +0000 @@ -97,8 +97,8 @@ // These should have warnings. __vector long double vv_ld; // expected-error {{cannot use 'long double' with '__vector'}} vector long double v_ld; // expected-error {{cannot use 'long double' with '__vector'}} -vector bool v_b; // expected-error {{type specifier missing, defaults to 'int'}} -vector __bool v___b; // expected-error {{type specifier missing, defaults to 'int'}} +vector bool v_b; // expected-warning {{type specifier missing, defaults to 'int'}} +vector __bool v___b; // expected-warning {{type specifier missing, defaults to 'int'}} // These should have errors. #ifndef __VSX__ diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Parser/attributes.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Parser/attributes.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Parser/attributes.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Parser/attributes.c 2023-01-24 23:05:59.000000000 +0000 @@ -7,7 +7,7 @@ } -__attribute__(()) y; // expected-error {{type specifier missing, defaults to 'int'}} +__attribute__(()) y; // expected-warning {{type specifier missing, defaults to 'int'}} // PR2796 int (__attribute__(()) *z)(long y); @@ -19,8 +19,8 @@ // This is parsed as a normal argument list (with two args that are implicit // int) because the __attribute__ is a declspec. -void f3(__attribute__(()) x, // expected-error {{type specifier missing, defaults to 'int'}} - y); // expected-error {{type specifier missing, defaults to 'int'}} +void f3(__attribute__(()) x, // expected-warning {{type specifier missing, defaults to 'int'}} + y); // expected-warning {{type specifier missing, defaults to 'int'}} void f4(__attribute__(())); // expected-error {{expected parameter declarator}} @@ -30,14 +30,14 @@ void g1(void (*f1)(__attribute__(()) int x)); void g2(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}} -void g3(void (*f3)(__attribute__(()) x, int y)); // expected-error {{type specifier missing, defaults to 'int'}} +void g3(void (*f3)(__attribute__(()) x, int y)); // expected-warning {{type specifier missing, defaults to 'int'}} void g4(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}} void (*h1)(void (*f1)(__attribute__(()) int x)); void (*h2)(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}} -void (*h3)(void (*f3)(__attribute__(()) x)); // expected-error {{type specifier missing, defaults to 'int'}} +void (*h3)(void (*f3)(__attribute__(()) x)); // expected-warning {{type specifier missing, defaults to 'int'}} void (*h4)(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}} diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Parser/declarators.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Parser/declarators.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Parser/declarators.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Parser/declarators.c 2023-01-24 23:05:59.000000000 +0000 @@ -6,7 +6,7 @@ void f1(int [*]); void f2(int [const *]); void f3(int [volatile const*]); -int f4(*XX)(void); /* expected-error {{cannot return}} expected-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} */ +int f4(*XX)(void); /* expected-error {{cannot return}} expected-warning {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} */ int f5(int [static]); /* expected-error {{'static' may not be used without an array size}} */ char ((((*X)))); @@ -64,9 +64,9 @@ // Verify that implicit int still works. -static f; // expected-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} -static g = 4; // expected-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} -static h // expected-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} +static f; // expected-warning {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} +static g = 4; // expected-warning {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} +static h // expected-warning {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} __asm__("foo"); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Parser/objc-forcollection-neg-2.m rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Parser/objc-forcollection-neg-2.m --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Parser/objc-forcollection-neg-2.m 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Parser/objc-forcollection-neg-2.m 2023-01-24 23:05:59.000000000 +0000 @@ -24,7 +24,7 @@ @implementation MyList (BasicTest) - (void)compilerTestAgainst { - static i;// expected-error {{type specifier missing, defaults to 'int'}} + static i;// expected-warning {{type specifier missing, defaults to 'int'}} for (id el, elem in self) // expected-error {{only one element declaration is allowed}} ++i; for (id el in self) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/PCH/chain-macro-override.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/PCH/chain-macro-override.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/PCH/chain-macro-override.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/PCH/chain-macro-override.c 2023-01-24 23:05:59.000000000 +0000 @@ -10,7 +10,7 @@ f(); g(); h(); - h2(); // expected-error {{call to undeclared function 'h2'; ISO C99 and later do not support implicit function declarations}} + h2(); // expected-warning {{call to undeclared function 'h2'; ISO C99 and later do not support implicit function declarations}} h3(); return x; } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Preprocessor/macro_paste_msextensions.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Preprocessor/macro_paste_msextensions.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Preprocessor/macro_paste_msextensions.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Preprocessor/macro_paste_msextensions.c 2023-01-24 23:05:59.000000000 +0000 @@ -32,7 +32,7 @@ // rdar://8197149 - VC++ allows invalid token pastes: (##baz #define foo(x) abc(x) #define bar(y) foo(##baz(y)) -bar(q) // expected-error {{type specifier missing}} expected-error {{invalid preprocessing token}} expected-error {{parameter list without types}} +bar(q) // expected-warning {{type specifier missing}} expected-error {{invalid preprocessing token}} expected-error {{parameter list without types}} // CHECK: abc(baz(q)) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/aarch64-tme-errors.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/aarch64-tme-errors.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/aarch64-tme-errors.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/aarch64-tme-errors.c 2023-01-24 23:05:59.000000000 +0000 @@ -3,6 +3,6 @@ #include "arm_acle.h" void test_no_tme_funcs(void) { - __tstart(); // expected-error{{call to undeclared function '__tstart'; ISO C99 and later do not support implicit function declarations}} + __tstart(); // expected-warning{{call to undeclared function '__tstart'; ISO C99 and later do not support implicit function declarations}} __builtin_tstart(); // expected-error{{use of unknown builtin '__builtin_tstart'}} } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/address_spaces.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/address_spaces.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/address_spaces.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/address_spaces.c 2023-01-24 23:05:59.000000000 +0000 @@ -9,7 +9,7 @@ void foo(_AS3 float *a, _AS1 float b) // expected-error {{parameter may not be qualified with an address space}} { - _AS2 *x;// expected-error {{type specifier missing, defaults to 'int'}} + _AS2 *x;// expected-warning {{type specifier missing, defaults to 'int'}} _AS1 float * _AS2 *B; int _AS1 _AS2 *Y; // expected-error {{multiple address spaces specified for type}} diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/auto-type.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/auto-type.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/auto-type.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/auto-type.c 2023-01-24 23:05:59.000000000 +0000 @@ -37,7 +37,7 @@ // GCC does not accept this either, for the same reason. _Atomic(__auto_type) aat2 = a; // expected-error {{'__auto_type' not allowed here}} \ - // expected-error {{type specifier missing, defaults to 'int'}} + // expected-warning {{type specifier missing, defaults to 'int'}} // Ensure the types are what we expect them to be, regardless of order we // pass the types. diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/bitfield.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/bitfield.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/bitfield.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/bitfield.c 2023-01-24 23:05:59.000000000 +0000 @@ -84,5 +84,5 @@ }; struct PR36157 { - int n : 1 ? 1 : implicitly_declare_function(); // expected-error {{call to undeclared function 'implicitly_declare_function'; ISO C99 and later do not support implicit function declarations}} + int n : 1 ? 1 : implicitly_declare_function(); // expected-warning {{call to undeclared function 'implicitly_declare_function'; ISO C99 and later do not support implicit function declarations}} }; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/block-args.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/block-args.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/block-args.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/block-args.c 2023-01-24 23:05:59.000000000 +0000 @@ -37,7 +37,7 @@ // rdar://problem/8962770 void test4(void) { - int (^f)(void) = ^((x)) { }; // expected-error {{type specifier missing}} expected-error {{type-id cannot have a name}} + int (^f)(void) = ^((x)) { }; // expected-warning {{type specifier missing}} expected-error {{type-id cannot have a name}} } // rdar://problem/9170609 diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/block-literal.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/block-literal.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/block-literal.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/block-literal.c 2023-01-24 23:05:59.000000000 +0000 @@ -41,7 +41,7 @@ foo: takeblock(^{ x = 4; }); // expected-error {{variable is not assignable (missing __block type specifier)}} - __block y = 7; // expected-error {{type specifier missing, defaults to 'int'}} + __block y = 7; // expected-warning {{type specifier missing, defaults to 'int'}} takeblock(^{ y = 8; }); } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/builtins.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/builtins.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/builtins.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/builtins.c 2023-01-24 23:05:59.000000000 +0000 @@ -206,9 +206,9 @@ } void no_ms_builtins(void) { - __assume(1); // expected-error {{call to undeclared function '__assume'; ISO C99 and later do not support implicit function declarations}} - __noop(1); // expected-error {{call to undeclared function '__noop'; ISO C99 and later do not support implicit function declarations}} - __debugbreak(); // expected-error {{call to undeclared function '__debugbreak'; ISO C99 and later do not support implicit function declarations}} + __assume(1); // expected-warning {{call to undeclared function '__assume'; ISO C99 and later do not support implicit function declarations}} + __noop(1); // expected-warning {{call to undeclared function '__noop'; ISO C99 and later do not support implicit function declarations}} + __debugbreak(); // expected-warning {{call to undeclared function '__debugbreak'; ISO C99 and later do not support implicit function declarations}} } void unavailable(void) { diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/builtin-setjmp.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/builtin-setjmp.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/builtin-setjmp.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/builtin-setjmp.c 2023-01-24 23:05:59.000000000 +0000 @@ -35,10 +35,10 @@ setjmp(0); #if NO_SETJMP // cxx-error@-2 {{undeclared identifier 'setjmp'}} - // c-error@-3 {{call to undeclared function 'setjmp'; ISO C99 and later do not support implicit function declarations}} + // c-warning@-3 {{call to undeclared function 'setjmp'; ISO C99 and later do not support implicit function declarations}} #elif ONLY_JMP_BUF // cxx-error@-5 {{undeclared identifier 'setjmp'}} - // c-error@-6 {{call to undeclared library function 'setjmp' with type 'int (jmp_buf)' (aka 'int (int *)'); ISO C99 and later do not support implicit function declarations}} + // c-warning@-6 {{call to undeclared library function 'setjmp' with type 'int (jmp_buf)' (aka 'int (int *)'); ISO C99 and later do not support implicit function declarations}} // c-note@-7 {{include the header or explicitly provide a declaration for 'setjmp'}} #else // cxx-no-diagnostics diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/crash-invalid-builtin.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/crash-invalid-builtin.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/crash-invalid-builtin.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/crash-invalid-builtin.c 2023-01-24 23:05:59.000000000 +0000 @@ -1,4 +1,4 @@ // RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s // PR23086 -__builtin_isinf(...); // expected-error {{type specifier missing, defaults to 'int'}} expected-error {{ISO C requires a named parameter before '...'}} // expected-error {{cannot redeclare builtin function '__builtin_isinf'}} // expected-note {{'__builtin_isinf' is a builtin with type 'int ()'}} +__builtin_isinf(...); // expected-warning {{type specifier missing, defaults to 'int'}} expected-error {{ISO C requires a named parameter before '...'}} // expected-error {{cannot redeclare builtin function '__builtin_isinf'}} // expected-note {{'__builtin_isinf' is a builtin with type 'int ()'}} diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/cxx-as-c.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/cxx-as-c.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/cxx-as-c.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/cxx-as-c.c 2023-01-24 23:05:59.000000000 +0000 @@ -2,7 +2,7 @@ // PR36157 struct Foo { - Foo(int n) : n_(n) {} // expected-error 1+{{}} + Foo(int n) : n_(n) {} // expected-error 1+{{}} expected-warning 1+{{}} private: int n; }; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/function.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/function.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/function.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/function.c 2023-01-24 23:05:59.000000000 +0000 @@ -18,7 +18,7 @@ // PR1965 int t5(b); // expected-error {{parameter list without types}} -int t6(int x, g); // expected-error {{type specifier missing, defaults to 'int'}} +int t6(int x, g); // expected-warning {{type specifier missing, defaults to 'int'}} int t7(, ); // expected-error {{expected parameter declarator}} expected-error {{expected parameter declarator}} int t8(, int a); // expected-error {{expected parameter declarator}} @@ -41,8 +41,8 @@ } // -y(y) { return y; } // expected-error{{parameter 'y' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}} \ - // expected-error{{type specifier missing, defaults to 'int'}} +y(y) { return y; } // expected-warning{{parameter 'y' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}} \ + // expected-warning{{type specifier missing, defaults to 'int'}} // PR3137, diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/gnu-builtins.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/gnu-builtins.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/gnu-builtins.c 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/gnu-builtins.c 2023-01-24 23:05:59.000000000 +0000 @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify=gnu -std=gnu17 %s +// RUN: %clang_cc1 -fsyntax-only -verify=gnu -std=gnu2x %s +// RUN: %clang_cc1 -fsyntax-only -verify=std -std=c17 %s +// RUN: %clang_cc1 -fsyntax-only -verify=std -std=c2x %s + +// std-no-diagnostics + +// 'index' is a builtin library function, but only in GNU mode. So this should +// give an error in GNU modes but be okay in non-GNU mode. +// FIXME: the error is correct, but these notes are pretty awful. +int index; // gnu-error {{redefinition of 'index' as different kind of symbol}} \ + gnu-note {{unguarded header; consider using #ifdef guards or #pragma once}} \ + gnu-note {{previous definition is here}} diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/implicit-builtin-decl.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/implicit-builtin-decl.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/implicit-builtin-decl.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/implicit-builtin-decl.c 2023-01-24 23:05:59.000000000 +0000 @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -Wno-strict-prototypes -verify %s void f() { - int *ptr = malloc(sizeof(int) * 10); // expected-error{{call to undeclared library function 'malloc' with type}} \ + int *ptr = malloc(sizeof(int) * 10); // expected-warning{{call to undeclared library function 'malloc' with type}} \ // expected-note{{include the header or explicitly provide a declaration for 'malloc'}} \ // expected-note{{'malloc' is a builtin with type 'void *}} } @@ -24,7 +24,7 @@ void f2() { fprintf(0, "foo"); // expected-warning{{declaration of built-in function 'fprintf' requires inclusion of the header }} \ - expected-error {{call to undeclared function 'fprintf'; ISO C99 and later do not support implicit function declarations}} + expected-warning {{call to undeclared function 'fprintf'; ISO C99 and later do not support implicit function declarations}} } // PR2892 diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/implicit-decl.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/implicit-decl.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/implicit-decl.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/implicit-decl.c 2023-01-24 23:05:59.000000000 +0000 @@ -1,55 +1,60 @@ -// RUN: %clang_cc1 %s -verify -fsyntax-only -Werror=implicit-function-declaration -std=c99 -// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11 +// RUN: %clang_cc1 %s -verify=werror,both -fsyntax-only -Werror=implicit-function-declaration -std=c99 +// RUN: %clang_cc1 %s -verify=expected,both -fsyntax-only -std=c11 // RUN: %clang_cc1 %s -verify=c2x -fsyntax-only -std=c2x /// -Werror-implicit-function-declaration is a deprecated alias used by many projects. -// RUN: %clang_cc1 %s -verify -fsyntax-only -Werror-implicit-function-declaration +// RUN: %clang_cc1 %s -verify=werror,both -fsyntax-only -Werror-implicit-function-declaration // c2x-note@*:* {{'__builtin_va_list' declared here}} typedef int int32_t; typedef unsigned char Boolean; -extern int printf(__const char *__restrict __format, ...); // expected-note{{'printf' declared here}} \ +extern int printf(__const char *__restrict __format, ...); // werror-note{{'printf' declared here}} \ c2x-note {{'printf' declared here}} void func(void) { int32_t *vector[16]; const char compDesc[16 + 1]; int32_t compCount = 0; - if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-error {{call to undeclared function '_CFCalendarDecomposeAbsoluteTimeV'; ISO C99 and later do not support implicit function declarations}} \ - expected-note {{previous implicit declaration}} \ + if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // werror-error {{call to undeclared function '_CFCalendarDecomposeAbsoluteTimeV'; ISO C99 and later do not support implicit function declarations}} \ + both-note {{previous implicit declaration}} \ + expected-warning {{call to undeclared function '_CFCalendarDecomposeAbsoluteTimeV'; ISO C99 and later do not support implicit function declarations}} \ c2x-error {{use of undeclared identifier '_CFCalendarDecomposeAbsoluteTimeV'}} } - printg("Hello, World!\n"); // expected-error{{call to undeclared function 'printg'; ISO C99 and later do not support implicit function declarations}} \ - expected-note{{did you mean 'printf'?}} \ + printg("Hello, World!\n"); // werror-error{{call to undeclared function 'printg'; ISO C99 and later do not support implicit function declarations}} \ + werror-note{{did you mean 'printf'?}} \ + expected-warning{{call to undeclared function 'printg'; ISO C99 and later do not support implicit function declarations}} \ c2x-error {{use of undeclared identifier 'printg'; did you mean 'printf'?}} - __builtin_is_les(1, 3); // expected-error{{use of unknown builtin '__builtin_is_les'}} \ + __builtin_is_les(1, 3); // both-error{{use of unknown builtin '__builtin_is_les'}} \ c2x-error {{unknown type name '__builtin_is_les'; did you mean '__builtin_va_list'?}} \ c2x-error {{expected identifier or '('}} \ c2x-error {{expected ')'}} \ c2x-note {{to match this '('}} } -Boolean _CFCalendarDecomposeAbsoluteTimeV(const char *componentDesc, int32_t **vector, int32_t count) { // expected-error {{conflicting types}} +Boolean _CFCalendarDecomposeAbsoluteTimeV(const char *componentDesc, int32_t **vector, int32_t count) { // both-error {{conflicting types}} return 0; } // Test the typo-correction callback in Sema::ImplicitlyDefineFunction -extern int sformatf(char *str, __const char *__restrict __format, ...); // expected-note{{'sformatf' declared here}} +extern int sformatf(char *str, __const char *__restrict __format, ...); // werror-note{{'sformatf' declared here}} void test_implicit(void) { int formats = 0; // c2x-note {{'formats' declared here}} - formatd("Hello, World!\n"); // expected-error{{call to undeclared function 'formatd'; ISO C99 and later do not support implicit function declarations}} \ - expected-note{{did you mean 'sformatf'?}} \ + formatd("Hello, World!\n"); // werror-error{{call to undeclared function 'formatd'; ISO C99 and later do not support implicit function declarations}} \ + werror-note{{did you mean 'sformatf'?}} \ + expected-warning{{call to undeclared function 'formatd'; ISO C99 and later do not support implicit function declarations}} \ c2x-error {{use of undeclared identifier 'formatd'; did you mean 'formats'?}} \ c2x-error {{called object type 'int' is not a function or function pointer}} } void test_suggestion(void) { - bark(); // expected-error {{call to undeclared function 'bark'; ISO C99 and later do not support implicit function declarations}} \ + bark(); // werror-error {{call to undeclared function 'bark'; ISO C99 and later do not support implicit function declarations}} \ + expected-warning {{call to undeclared function 'bark'; ISO C99 and later do not support implicit function declarations}} \ c2x-error {{use of undeclared identifier 'bark'}} - bork(); // expected-error {{call to undeclared function 'bork'; ISO C99 and later do not support implicit function declarations}} \ + bork(); // werror-error {{call to undeclared function 'bork'; ISO C99 and later do not support implicit function declarations}} \ + expected-warning {{call to undeclared function 'bork'; ISO C99 and later do not support implicit function declarations}} \ c2x-error {{use of undeclared identifier 'bork'}} } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/implicit-int.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/implicit-int.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/implicit-int.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/implicit-int.c 2023-01-24 23:05:59.000000000 +0000 @@ -4,18 +4,18 @@ */ foo(void) { /* expected-warning {{type specifier missing, defaults to 'int'}} \ - ext-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \ + ext-warning {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \ unsupported-error {{a type specifier is required for all declarations}} */ return 0; } y; /* expected-warning {{type specifier missing, defaults to 'int'}} \ - ext-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \ + ext-warning {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \ unsupported-error {{a type specifier is required for all declarations}} */ /* rdar://6131634 */ void f((x)); /* expected-warning {{type specifier missing, defaults to 'int'}} \ - ext-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \ + ext-warning {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \ unsupported-error {{a type specifier is required for all declarations}} */ /* PR3702 */ @@ -26,18 +26,18 @@ #define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */ void -h19_insline(n) /* ext-error {{parameter 'n' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}} \ +h19_insline(n) /* ext-warning {{parameter 'n' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}} \ unsupported-error {{unknown type name 'n'}} */ { ILPAD(); /* expected-warning {{type specifier missing, defaults to 'int'}} \ - ext-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \ + ext-warning {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \ unsupported-error {{a type specifier is required for all declarations}} */ } struct foo { __extension__ __attribute__((packed)) x : 4; /* expected-warning {{type specifier missing, defaults to 'int'}} \ - ext-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \ + ext-warning {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \ unsupported-error {{unknown type name 'x'}} */ }; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/implicit-intel-builtin-decl.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/implicit-intel-builtin-decl.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/implicit-intel-builtin-decl.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/implicit-intel-builtin-decl.c 2023-01-24 23:05:59.000000000 +0000 @@ -3,26 +3,26 @@ void f(void) { (void)_mm_getcsr(); // cxx-warning{{implicitly declaring library function '_mm_getcsr'}} \ - c-error{{call to undeclared library function '_mm_getcsr'}} \ + c-warning{{call to undeclared library function '_mm_getcsr'}} \ expected-note{{include the header or explicitly provide a declaration for '_mm_getcsr'}} _mm_setcsr(1); // cxx-warning{{implicitly declaring library function '_mm_setcsr'}} \ - c-error{{call to undeclared library function '_mm_setcsr'}} \ + c-warning{{call to undeclared library function '_mm_setcsr'}} \ expected-note{{include the header or explicitly provide a declaration for '_mm_setcsr'}} _mm_sfence(); // cxx-warning{{implicitly declaring library function '_mm_sfence'}} \ - c-error{{call to undeclared library function '_mm_sfence'}} \ + c-warning{{call to undeclared library function '_mm_sfence'}} \ expected-note{{include the header or explicitly provide a declaration for '_mm_sfence'}} _mm_clflush((void*)0); // cxx-warning{{implicitly declaring library function '_mm_clflush'}} \ - c-error{{call to undeclared library function '_mm_clflush'}} \ + c-warning{{call to undeclared library function '_mm_clflush'}} \ expected-note{{include the header or explicitly provide a declaration for '_mm_clflush'}} _mm_lfence(); // cxx-warning{{implicitly declaring library function '_mm_lfence'}} \ - c-error{{call to undeclared library function '_mm_lfence'}} \ + c-warning{{call to undeclared library function '_mm_lfence'}} \ expected-note{{include the header or explicitly provide a declaration for '_mm_lfence'}} _mm_mfence(); // cxx-warning{{implicitly declaring library function '_mm_mfence'}} \ - c-error{{call to undeclared library function '_mm_mfence'}} \ + c-warning{{call to undeclared library function '_mm_mfence'}} \ expected-note{{include the header or explicitly provide a declaration for '_mm_mfence'}} _mm_pause(); // cxx-warning{{implicitly declaring library function '_mm_pause'}} \ - c-error{{call to undeclared library function '_mm_pause'}} \ + c-warning{{call to undeclared library function '_mm_pause'}} \ expected-note{{include the header or explicitly provide a declaration for '_mm_pause'}} } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/implicit-ms-builtin-decl.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/implicit-ms-builtin-decl.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/implicit-ms-builtin-decl.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/implicit-ms-builtin-decl.c 2023-01-24 23:05:59.000000000 +0000 @@ -2,9 +2,9 @@ // RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -verify %s -fms-extensions void f(void) { - (void)_byteswap_ushort(42); // expected-error{{call to undeclared library function '_byteswap_ushort'}} \ + (void)_byteswap_ushort(42); // expected-warning{{call to undeclared library function '_byteswap_ushort'}} \ // expected-note{{include the header or explicitly provide a declaration for '_byteswap_ushort'}} - (void)_byteswap_uint64(42LL); // expected-error{{call to undeclared library function '_byteswap_uint64'}} \ + (void)_byteswap_uint64(42LL); // expected-warning{{call to undeclared library function '_byteswap_uint64'}} \ // expected-note{{include the header or explicitly provide a declaration for '_byteswap_uint64'}} } @@ -21,9 +21,9 @@ #if defined(__x86_64__) void h(void) { - (void)__mulh(21, 2); // expected-error{{call to undeclared library function '__mulh'}} \ + (void)__mulh(21, 2); // expected-warning{{call to undeclared library function '__mulh'}} \ // expected-note{{include the header or explicitly provide a declaration for '__mulh'}} - (void)__umulh(21, 2); // expected-error{{call to undeclared library function '__umulh'}} \ + (void)__umulh(21, 2); // expected-warning{{call to undeclared library function '__umulh'}} \ // expected-note{{include the header or explicitly provide a declaration for '__umulh'}} } @@ -38,7 +38,7 @@ #if defined(i386) void h(void) { - (void)__mulh(21LL, 2LL); // expected-error{{call to undeclared function '__mulh'; ISO C99 and later do not support implicit function declarations}} - (void)__umulh(21ULL, 2ULL); // expected-error{{call to undeclared function '__umulh'; ISO C99 and later do not support implicit function declarations}} + (void)__mulh(21LL, 2LL); // expected-warning{{call to undeclared function '__mulh'; ISO C99 and later do not support implicit function declarations}} + (void)__umulh(21ULL, 2ULL); // expected-warning{{call to undeclared function '__umulh'; ISO C99 and later do not support implicit function declarations}} } #endif diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/invalid-decl.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/invalid-decl.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/invalid-decl.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/invalid-decl.c 2023-01-24 23:05:59.000000000 +0000 @@ -6,7 +6,7 @@ // PR2400 -typedef xtype (*x)(void* handle); // expected-error {{function cannot return function type}} expected-error 2{{type specifier missing, defaults to 'int'}} +typedef xtype (*x)(void* handle); // expected-error {{function cannot return function type}} expected-warning 2{{type specifier missing, defaults to 'int'}} typedef void ytype(); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/invalid-struct-init.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/invalid-struct-init.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/invalid-struct-init.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/invalid-struct-init.c 2023-01-24 23:05:59.000000000 +0000 @@ -3,7 +3,7 @@ typedef struct _zend_module_entry zend_module_entry; struct _zend_module_entry { _efree((p)); // expected-error{{type name requires a specifier or qualifier}} \ - expected-error {{type specifier missing, defaults to 'int'}} + expected-warning {{type specifier missing, defaults to 'int'}} }; typedef struct _zend_function_entry { } zend_function_entry; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/redefinition.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/redefinition.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/redefinition.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/redefinition.c 2023-01-24 23:05:59.000000000 +0000 @@ -4,7 +4,7 @@ int f(int a) { return 0; } // expected-error {{redefinition of 'f'}} // -int foo(x) { // expected-error {{parameter 'x' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}} +int foo(x) { // expected-warning {{parameter 'x' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}} return 0; } int x = 1; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/__try.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/__try.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/__try.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/__try.c 2023-01-24 23:05:59.000000000 +0000 @@ -50,7 +50,7 @@ } // expected-error{{expected '__except' or '__finally' block}} void TEST(void) { - __except (FilterExpression()) { // expected-error{{call to undeclared function '__except'; ISO C99 and later do not support implicit function declarations}} \ + __except (FilterExpression()) { // expected-warning{{call to undeclared function '__except'; ISO C99 and later do not support implicit function declarations}} \ // expected-error{{too few arguments to function call, expected 1, have 0}} \ // expected-error{{expected ';' after expression}} } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/typo-correction.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/typo-correction.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/typo-correction.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/typo-correction.c 2023-01-24 23:05:59.000000000 +0000 @@ -10,11 +10,11 @@ x = (float)arst; // expected-error-re {{use of undeclared identifier 'arst'{{$}}}} } -a = b ? : 0; // expected-error {{type specifier missing, defaults to 'int'}} \ +a = b ? : 0; // expected-warning {{type specifier missing, defaults to 'int'}} \ // expected-error {{use of undeclared identifier 'b'}} int foobar; // expected-note {{'foobar' declared here}} -new_a = goobar ?: 4; // expected-error {{type specifier missing, defaults to 'int'}} \ +new_a = goobar ?: 4; // expected-warning {{type specifier missing, defaults to 'int'}} \ // expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}} \ // expected-error {{initializer element is not a compile-time constant}} @@ -37,7 +37,7 @@ typedef long long __m128i __attribute__((__vector_size__(16))); int PR23101(__m128i __x) { - return foo((__v2di)__x); // expected-error {{call to undeclared function 'foo'; ISO C99 and later do not support implicit function declarations}} \ + return foo((__v2di)__x); // expected-warning {{call to undeclared function 'foo'; ISO C99 and later do not support implicit function declarations}} \ // expected-error {{use of undeclared identifier '__v2di'}} } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/varargs.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/varargs.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/varargs.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/varargs.c 2023-01-24 23:05:59.000000000 +0000 @@ -114,7 +114,7 @@ } void f14(int e, ...) { - // expected-error@+3 {{call to undeclared library function 'va_start'}} + // expected-warning@+3 {{call to undeclared library function 'va_start'}} // expected-note@+2 {{include the header }} // expected-error@+1 {{too few arguments to function call}} va_start(); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/vla.c rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/vla.c --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Sema/vla.c 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Sema/vla.c 2023-01-24 23:05:59.000000000 +0000 @@ -72,7 +72,7 @@ // PR36157 struct { int a[ // expected-error {{variable length array in struct}} - implicitly_declared() // expected-error {{call to undeclared function 'implicitly_declared'; ISO C99 and later do not support implicit function declarations}} + implicitly_declared() // expected-warning {{call to undeclared function 'implicitly_declared'; ISO C99 and later do not support implicit function declarations}} ]; }; int (*use_implicitly_declared)(void) = implicitly_declared; // ok, was implicitly declared at file scope diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp 2023-01-24 23:05:59.000000000 +0000 @@ -766,3 +766,72 @@ static_assert(c == 8); } } + +// https://github.com/llvm/llvm-project/issues/51695 +namespace GH51695 { +// Original ======================================== +template +struct type_t {}; + +template +struct list_t {}; + +template +consteval auto pop_front(list_t) -> auto { + return list_t{}; +} + +template +consteval auto apply(list_t, F fn) -> auto { + return fn(type_t{}...); +} + +void test1() { + constexpr auto x = apply(pop_front(list_t{}), + [](type_t...) { return 42; }); + static_assert(x == 42); +} +// Reduced 1 ======================================== +consteval bool zero() { return false; } + +template +consteval bool foo(bool, F f) { + return f(); +} + +void test2() { + constexpr auto x = foo(zero(), []() { return true; }); + static_assert(x); +} + +// Reduced 2 ======================================== +template +consteval auto bar(F f) { return f;} + +void test3() { + constexpr auto t1 = bar(bar(bar(bar([]() { return true; }))))(); + static_assert(t1); + + int a = 1; // expected-note {{declared here}} + auto t2 = bar(bar(bar(bar([=]() { return a; }))))(); // expected-error-re {{call to consteval function 'GH51695::bar<(lambda at {{.*}})>' is not a constant expression}} + // expected-note@-1 {{read of non-const variable 'a' is not allowed in a constant expression}} + + constexpr auto t3 = bar(bar([x=bar(42)]() { return x; }))(); + static_assert(t3==42); + constexpr auto t4 = bar(bar([x=bar(42)]() consteval { return x; }))(); + static_assert(t4==42); +} + +} // namespace GH51695 + +// https://github.com/llvm/llvm-project/issues/50455 +namespace GH50455 { +void f() { + []() consteval { int i{}; }(); + []() consteval { int i{}; ++i; }(); +} +void g() { + (void)[](int i) consteval { return i; }(0); + (void)[](int i) consteval { return i; }(0); +} +} // namespace GH50455 diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/SemaCXX/specialization-diagnose-crash.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/SemaCXX/specialization-diagnose-crash.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/SemaCXX/specialization-diagnose-crash.cpp 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/SemaCXX/specialization-diagnose-crash.cpp 2023-01-24 23:05:59.000000000 +0000 @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fsyntax-only %s --std=c++17 -verify +// This is a reduction of GH57370 and GH58028, originally appearing +// in libstdc++'s variant code. + +struct V1 {}; +struct V2 : V1 { + int &a; +}; + +template using void_t = void; + +template struct X { T x; }; + +template struct Variant { + Variant() = delete; // expected-note {{deleted here}} +}; + +template +struct Variant{T1()})>> {}; + +void f() { + Variant(); + Variant(); // expected-error {{call to deleted constructor}} +} diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/SemaObjC/builtin_objc_lib_functions.m rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/SemaObjC/builtin_objc_lib_functions.m --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/SemaObjC/builtin_objc_lib_functions.m 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/SemaObjC/builtin_objc_lib_functions.m 2023-01-24 23:05:59.000000000 +0000 @@ -1,29 +1,29 @@ // RUN: %clang_cc1 -x objective-c %s -fsyntax-only -verify // rdar://8592641 -Class f0(void) { return objc_getClass("a"); } // expected-error {{call to undeclared library function 'objc_getClass' with type 'id (const char *)'}} \ +Class f0(void) { return objc_getClass("a"); } // expected-warning {{call to undeclared library function 'objc_getClass' with type 'id (const char *)'}} \ // expected-note {{include the header or explicitly provide a declaration for 'objc_getClass'}} // rdar://8735023 -Class f1(void) { return objc_getMetaClass("a"); } // expected-error {{call to undeclared library function 'objc_getMetaClass' with type 'id (const char *)'}} \ +Class f1(void) { return objc_getMetaClass("a"); } // expected-warning {{call to undeclared library function 'objc_getMetaClass' with type 'id (const char *)'}} \ // expected-note {{include the header or explicitly provide a declaration for 'objc_getMetaClass'}} -void f2(id val) { objc_enumerationMutation(val); } // expected-error {{call to undeclared library function 'objc_enumerationMutation' with type 'void (id)'}} \ +void f2(id val) { objc_enumerationMutation(val); } // expected-warning {{call to undeclared library function 'objc_enumerationMutation' with type 'void (id)'}} \ // expected-note {{include the header or explicitly provide a declaration for 'objc_enumerationMutation'}} -long double f3(id self, SEL op) { return objc_msgSend_fpret(self, op); } // expected-error {{call to undeclared library function 'objc_msgSend_fpret' with type 'long double (id, SEL, ...)'}} \ +long double f3(id self, SEL op) { return objc_msgSend_fpret(self, op); } // expected-warning {{call to undeclared library function 'objc_msgSend_fpret' with type 'long double (id, SEL, ...)'}} \ // expected-note {{include the header or explicitly provide a declaration for 'objc_msgSend_fpret'}} id f4(struct objc_super *super, SEL op) { // expected-warning {{declaration of 'struct objc_super' will not be visible outside of this function}} - return objc_msgSendSuper(super, op); // expected-error {{call to undeclared library function 'objc_msgSendSuper' with type 'id (struct objc_super *, SEL, ...)'}} \ + return objc_msgSendSuper(super, op); // expected-warning {{call to undeclared library function 'objc_msgSendSuper' with type 'id (struct objc_super *, SEL, ...)'}} \ // expected-note {{include the header or explicitly provide a declaration for 'objc_msgSendSuper'}} } id f5(id val, id *dest) { - return objc_assign_strongCast(val, dest); // expected-error {{call to undeclared library function 'objc_assign_strongCast' with type 'id (id, id *)'}} \ + return objc_assign_strongCast(val, dest); // expected-warning {{call to undeclared library function 'objc_assign_strongCast' with type 'id (id, id *)'}} \ // expected-note {{include the header or explicitly provide a declaration for 'objc_assign_strongCast'}} } int f6(Class exceptionClass, id exception) { - return objc_exception_match(exceptionClass, exception); // expected-error {{call to undeclared library function 'objc_exception_match' with type 'int (id, id)'}} \ + return objc_exception_match(exceptionClass, exception); // expected-warning {{call to undeclared library function 'objc_exception_match' with type 'int (id, id)'}} \ // expected-note {{include the header or explicitly provide a declaration for 'objc_exception_match'}} } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/SemaObjC/builtin_objc_nslog.m rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/SemaObjC/builtin_objc_nslog.m --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/SemaObjC/builtin_objc_nslog.m 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/SemaObjC/builtin_objc_nslog.m 2023-01-24 23:05:59.000000000 +0000 @@ -3,11 +3,11 @@ #include void f1(id arg) { - NSLog(@"%@", arg); // expected-error {{call to undeclared library function 'NSLog' with type 'void (id, ...)'}} \ + NSLog(@"%@", arg); // expected-warning {{call to undeclared library function 'NSLog' with type 'void (id, ...)'}} \ // expected-note {{include the header or explicitly provide a declaration for 'NSLog'}} } void f2(id str, va_list args) { - NSLogv(@"%@", args); // expected-error {{call to undeclared library function 'NSLogv' with type }} \ + NSLogv(@"%@", args); // expected-warning {{call to undeclared library function 'NSLogv' with type }} \ // expected-note {{include the header or explicitly provide a declaration for 'NSLogv'}} } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/SemaObjC/ivar-lookup-resolution-builtin.m rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/SemaObjC/ivar-lookup-resolution-builtin.m --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/SemaObjC/ivar-lookup-resolution-builtin.m 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/SemaObjC/ivar-lookup-resolution-builtin.m 2023-01-24 23:05:59.000000000 +0000 @@ -28,7 +28,7 @@ @implementation Test1 - (int) InstMethod { - return index; // expected-error {{call to undeclared library function 'index'}} \ + return index; // expected-warning {{call to undeclared library function 'index'}} \ // expected-note {{include the header or explicitly provide a declaration for 'index'}} \ // expected-error {{incompatible pointer to integer conversion returning}} } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/SemaObjC/protocols.m rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/SemaObjC/protocols.m --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/SemaObjC/protocols.m 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/SemaObjC/protocols.m 2023-01-24 23:05:59.000000000 +0000 @@ -62,6 +62,6 @@ @end @protocol P -- (int)test:(int)param, ..; // expected-error{{type specifier missing}} \ +- (int)test:(int)param, ..; // expected-warning{{type specifier missing}} \ // expected-error{{expected ';' after method prototype}} @end diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl 2023-01-24 23:05:59.000000000 +0000 @@ -10,7 +10,7 @@ // expected-error@-5 {{C++ for OpenCL version 2021 does not support the 'pipe' type qualifier}} // expected-error@-6 {{access qualifier can only be used for pipe and image type}} #else -// expected-error@-8 {{type specifier missing, defaults to 'int'}} +// expected-warning@-8 {{type specifier missing, defaults to 'int'}} // expected-error@-9 {{access qualifier can only be used for pipe and image type}} // expected-error@-10 {{expected ')'}} expected-note@-10 {{to match this '('}} #endif diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Unit/lit.cfg.py rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Unit/lit.cfg.py --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/test/Unit/lit.cfg.py 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/test/Unit/lit.cfg.py 2023-01-24 23:06:00.000000000 +0000 @@ -45,7 +45,7 @@ config.environment[var] = os.environ[var] def find_shlibpath_var(): - if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']: + if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'OpenBSD', 'SunOS']: yield 'LD_LIBRARY_PATH' elif platform.system() == 'Darwin': yield 'DYLD_LIBRARY_PATH' diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/unittests/AST/StmtPrinterTest.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/unittests/AST/StmtPrinterTest.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/unittests/AST/StmtPrinterTest.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/unittests/AST/StmtPrinterTest.cpp 2023-01-24 23:06:00.000000000 +0000 @@ -31,7 +31,7 @@ namespace { -enum class StdVer { CXX98, CXX11, CXX14, CXX17, CXX2a }; +enum class StdVer { CXX98, CXX11, CXX14, CXX17, CXX20 }; DeclarationMatcher FunctionBodyMatcher(StringRef ContainingFunction) { return functionDecl(hasName(ContainingFunction), @@ -67,7 +67,9 @@ case StdVer::CXX11: StdOpt = "-std=c++11"; break; case StdVer::CXX14: StdOpt = "-std=c++14"; break; case StdVer::CXX17: StdOpt = "-std=c++17"; break; - case StdVer::CXX2a: StdOpt = "-std=c++2a"; break; + case StdVer::CXX20: + StdOpt = "-std=c++20"; + break; } std::vector Args = { @@ -146,6 +148,35 @@ // Should be: with semicolon } +TEST(StmtPrinter, TestStringLiteralOperatorTemplate_Pack) { + ASSERT_TRUE(PrintedStmtCXXMatches(StdVer::CXX11, + R"cpp( + template constexpr double operator""_c() { return 42; } + void A() { + constexpr auto waldo = 42_c; + } +)cpp", + FunctionBodyMatcher("A"), + "constexpr auto waldo = 42_c;\n")); +} + +TEST(StmtPrinter, TestStringLiteralOperatorTemplate_Class) { + ASSERT_TRUE( + PrintedStmtCXXMatches(StdVer::CXX20, + R"cpp( + struct C { + template constexpr C(const char (&)[N]) : n(N) {} + unsigned n; + }; + template constexpr auto operator""_c() { return c.n; } + void A() { + constexpr auto waldo = "abc"_c; + } +)cpp", + FunctionBodyMatcher("A"), + "constexpr auto waldo = operator\"\"_c<{4}>();\n")); +} + TEST(StmtPrinter, TestCXXConversionDeclImplicit) { ASSERT_TRUE(PrintedStmtCXXMatches( StdVer::CXX98, @@ -201,15 +232,17 @@ "[](auto a, int b, auto c, int, auto) {\n" "}")); - ASSERT_TRUE(PrintedStmtCXXMatches(StdVer::CXX2a, - "void A() {" - " auto l = [] class T3>" - " (int a, auto, int, auto d) { };" - "}", - lambdaExpr(anything()).bind("id"), - "[] class T3>(int a, auto, int, auto d) {\n" - "}")); + ASSERT_TRUE( + PrintedStmtCXXMatches(StdVer::CXX20, + "void A() {" + " auto l = [] class T3>" + " (int a, auto, int, auto d) { };" + "}", + lambdaExpr(anything()).bind("id"), + "[] class T3>(int a, auto, int, auto d) {\n" + "}")); } TEST(StmtPrinter, TestNoImplicitBases) { diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/unittests/Driver/ToolChainTest.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/unittests/Driver/ToolChainTest.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/unittests/Driver/ToolChainTest.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/unittests/Driver/ToolChainTest.cpp 2023-01-24 23:06:00.000000000 +0000 @@ -18,7 +18,6 @@ #include "clang/Driver/Driver.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/MC/TargetRegistry.h" -#include "llvm/Support/Host.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/VirtualFileSystem.h" #include "llvm/Support/raw_ostream.h" @@ -570,95 +569,4 @@ Diags.Clear(); DiagConsumer->clear(); } - -TEST(ToolChainTest, Toolsets) { - // Ignore this test on Windows hosts. - llvm::Triple Host(llvm::sys::getProcessTriple()); - if (Host.isOSWindows()) - GTEST_SKIP(); - - IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions(); - IntrusiveRefCntPtr DiagID(new DiagnosticIDs()); - - // Check (newer) GCC toolset installation. - { - IntrusiveRefCntPtr InMemoryFileSystem( - new llvm::vfs::InMemoryFileSystem); - - // These should be ignored. - InMemoryFileSystem->addFile("/opt/rh/gcc-toolset-2", 0, - llvm::MemoryBuffer::getMemBuffer("\n")); - InMemoryFileSystem->addFile("/opt/rh/gcc-toolset-", 0, - llvm::MemoryBuffer::getMemBuffer("\n")); - InMemoryFileSystem->addFile("/opt/rh/gcc-toolset--", 0, - llvm::MemoryBuffer::getMemBuffer("\n")); - InMemoryFileSystem->addFile("/opt/rh/gcc-toolset--1", 0, - llvm::MemoryBuffer::getMemBuffer("\n")); - - // File needed for GCC installation detection. - InMemoryFileSystem->addFile("/opt/rh/gcc-toolset-12/root/usr/lib/gcc/" - "x86_64-redhat-linux/11/crtbegin.o", - 0, llvm::MemoryBuffer::getMemBuffer("\n")); - - DiagnosticsEngine Diags(DiagID, &*DiagOpts, new SimpleDiagnosticConsumer); - Driver TheDriver("/bin/clang", "x86_64-redhat-linux", Diags, - "clang LLVM compiler", InMemoryFileSystem); - std::unique_ptr C( - TheDriver.BuildCompilation({"clang", "--gcc-toolchain="})); - ASSERT_TRUE(C); - std::string S; - { - llvm::raw_string_ostream OS(S); - C->getDefaultToolChain().printVerboseInfo(OS); - } - EXPECT_EQ("Found candidate GCC installation: " - "/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/11\n" - "Selected GCC installation: " - "/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/11\n" - "Candidate multilib: .;@m64\n" - "Selected multilib: .;@m64\n", - S); - } - - // And older devtoolset. - { - IntrusiveRefCntPtr InMemoryFileSystem( - new llvm::vfs::InMemoryFileSystem); - - // These should be ignored. - InMemoryFileSystem->addFile("/opt/rh/devtoolset-2", 0, - llvm::MemoryBuffer::getMemBuffer("\n")); - InMemoryFileSystem->addFile("/opt/rh/devtoolset-", 0, - llvm::MemoryBuffer::getMemBuffer("\n")); - InMemoryFileSystem->addFile("/opt/rh/devtoolset--", 0, - llvm::MemoryBuffer::getMemBuffer("\n")); - InMemoryFileSystem->addFile("/opt/rh/devtoolset--1", 0, - llvm::MemoryBuffer::getMemBuffer("\n")); - - // File needed for GCC installation detection. - InMemoryFileSystem->addFile("/opt/rh/devtoolset-12/root/usr/lib/gcc/" - "x86_64-redhat-linux/11/crtbegin.o", - 0, llvm::MemoryBuffer::getMemBuffer("\n")); - - DiagnosticsEngine Diags(DiagID, &*DiagOpts, new SimpleDiagnosticConsumer); - Driver TheDriver("/bin/clang", "x86_64-redhat-linux", Diags, - "clang LLVM compiler", InMemoryFileSystem); - std::unique_ptr C( - TheDriver.BuildCompilation({"clang", "--gcc-toolchain="})); - ASSERT_TRUE(C); - std::string S; - { - llvm::raw_string_ostream OS(S); - C->getDefaultToolChain().printVerboseInfo(OS); - } - EXPECT_EQ("Found candidate GCC installation: " - "/opt/rh/devtoolset-12/root/usr/lib/gcc/x86_64-redhat-linux/11\n" - "Selected GCC installation: " - "/opt/rh/devtoolset-12/root/usr/lib/gcc/x86_64-redhat-linux/11\n" - "Candidate multilib: .;@m64\n" - "Selected multilib: .;@m64\n", - S); - } -} - } // end anonymous namespace. diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/unittests/Format/FormatTest.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/unittests/Format/FormatTest.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/unittests/Format/FormatTest.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/unittests/Format/FormatTest.cpp 2023-01-24 23:06:00.000000000 +0000 @@ -10474,6 +10474,7 @@ verifyFormat("class {\n" "}&& ptr = {};", Style); + verifyFormat("bool b = 3 == int{3} && true;"); Style.PointerAlignment = FormatStyle::PAS_Middle; verifyFormat("struct {\n" diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/unittests/Format/TokenAnnotatorTest.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/unittests/Format/TokenAnnotatorTest.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/unittests/Format/TokenAnnotatorTest.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/unittests/Format/TokenAnnotatorTest.cpp 2023-01-24 23:06:00.000000000 +0000 @@ -86,6 +86,10 @@ EXPECT_EQ(Tokens.size(), 5u) << Tokens; EXPECT_TOKEN(Tokens[1], tok::amp, TT_UnaryOperator); + Tokens = annotate("bool b = 3 == int{3} && true;\n"); + EXPECT_EQ(Tokens.size(), 13u) << Tokens; + EXPECT_TOKEN(Tokens[9], tok::ampamp, TT_BinaryOperator); + Tokens = annotate("struct {\n" "} *ptr;"); EXPECT_EQ(Tokens.size(), 7u) << Tokens; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/unittests/Tooling/Syntax/TokensTest.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/unittests/Tooling/Syntax/TokensTest.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang/unittests/Tooling/Syntax/TokensTest.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang/unittests/Tooling/Syntax/TokensTest.cpp 2023-01-24 23:06:00.000000000 +0000 @@ -743,6 +743,62 @@ ValueIs(SameRange(findSpelled("ID2 ( a4 , a5 a6 a7 )")))); // Should fail, spans multiple invocations. EXPECT_EQ(Buffer.spelledForExpanded(findExpanded("a1 a2 a3 a4")), llvm::None); + + // https://github.com/clangd/clangd/issues/1289 + recordTokens(R"cpp( + #define FOO(X) foo(X) + #define INDIRECT FOO(y) + INDIRECT // expands to foo(y) + )cpp"); + EXPECT_EQ(Buffer.spelledForExpanded(findExpanded("y")), llvm::None); + + recordTokens(R"cpp( + #define FOO(X) a X b + FOO(y) + )cpp"); + EXPECT_THAT(Buffer.spelledForExpanded(findExpanded("y")), + ValueIs(SameRange(findSpelled("y")))); + + recordTokens(R"cpp( + #define ID(X) X + #define BAR ID(1) + BAR + )cpp"); + EXPECT_THAT(Buffer.spelledForExpanded(findExpanded("1")), + ValueIs(SameRange(findSpelled(") BAR").drop_front()))); + + // Critical cases for mapping of Prev/Next in spelledForExpandedSlow. + recordTokens(R"cpp( + #define ID(X) X + ID(prev ID(good)) + #define LARGE ID(prev ID(bad)) + LARGE + )cpp"); + EXPECT_THAT(Buffer.spelledForExpanded(findExpanded("good")), + ValueIs(SameRange(findSpelled("good")))); + EXPECT_EQ(Buffer.spelledForExpanded(findExpanded("bad")), llvm::None); + + recordTokens(R"cpp( + #define PREV prev + #define ID(X) X + PREV ID(good) + #define LARGE PREV ID(bad) + LARGE + )cpp"); + EXPECT_THAT(Buffer.spelledForExpanded(findExpanded("good")), + ValueIs(SameRange(findSpelled("good")))); + EXPECT_EQ(Buffer.spelledForExpanded(findExpanded("bad")), llvm::None); + + recordTokens(R"cpp( + #define ID(X) X + #define ID2(X, Y) X Y + ID2(prev, ID(good)) + #define LARGE ID2(prev, bad) + LARGE + )cpp"); + EXPECT_THAT(Buffer.spelledForExpanded(findExpanded("good")), + ValueIs(SameRange(findSpelled("good")))); + EXPECT_EQ(Buffer.spelledForExpanded(findExpanded("bad")), llvm::None); } TEST_F(TokenBufferTest, ExpandedTokensForRange) { diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -486,6 +486,9 @@ // we need to complete 'forward<$1>($0)'. return "($0)"; + if (Snippet->empty()) + return ""; + bool MayHaveArgList = Completion.Kind == CompletionItemKind::Function || Completion.Kind == CompletionItemKind::Method || Completion.Kind == CompletionItemKind::Constructor || @@ -524,8 +527,6 @@ return *Snippet; // Replace argument snippets with a simplified pattern. - if (Snippet->empty()) - return ""; if (MayHaveArgList) { // Functions snippets can be of 2 types: // - containing only function arguments, e.g. diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/CompileCommands.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/CompileCommands.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/CompileCommands.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/CompileCommands.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -220,10 +220,13 @@ ArgList = OptTable.ParseArgs( llvm::makeArrayRef(OriginalArgs).drop_front(), IgnoredCount, IgnoredCount, /*FlagsToInclude=*/ - IsCLMode ? (driver::options::CLOption | driver::options::CoreOption) + IsCLMode ? (driver::options::CLOption | driver::options::CoreOption | + driver::options::CLDXCOption) : /*everything*/ 0, /*FlagsToExclude=*/driver::options::NoDriverOption | - (IsCLMode ? 0 : driver::options::CLOption)); + (IsCLMode + ? 0 + : (driver::options::CLOption | driver::options::CLDXCOption))); llvm::SmallVector IndicesToDrop; // Having multiple architecture options (e.g. when building fat binaries) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/Headers.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/Headers.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/Headers.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/Headers.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -22,9 +22,17 @@ namespace clang { namespace clangd { -const char IWYUPragmaKeep[] = "// IWYU pragma: keep"; -const char IWYUPragmaExport[] = "// IWYU pragma: export"; -const char IWYUPragmaBeginExports[] = "// IWYU pragma: begin_exports"; +llvm::Optional parseIWYUPragma(const char *Text) { + // This gets called for every comment seen in the preamble, so it's quite hot. + constexpr llvm::StringLiteral IWYUPragma = "// IWYU pragma: "; + if (strncmp(Text, IWYUPragma.data(), IWYUPragma.size())) + return llvm::None; + Text += IWYUPragma.size(); + const char *End = Text; + while (*End != 0 && *End != '\n') + ++End; + return StringRef(Text, End - Text); +} class IncludeStructure::RecordHeaders : public PPCallbacks, public CommentHandler { @@ -129,10 +137,10 @@ } bool HandleComment(Preprocessor &PP, SourceRange Range) override { - bool Err = false; - llvm::StringRef Text = SM.getCharacterData(Range.getBegin(), &Err); - if (Err) + auto Pragma = parseIWYUPragma(SM.getCharacterData(Range.getBegin())); + if (!Pragma) return false; + if (inMainFile()) { // Given: // @@ -150,8 +158,7 @@ // will know that the next inclusion is behind the IWYU pragma. // FIXME: Support "IWYU pragma: begin_exports" and "IWYU pragma: // end_exports". - if (!Text.startswith(IWYUPragmaExport) && - !Text.startswith(IWYUPragmaKeep)) + if (!Pragma->startswith("export") && !Pragma->startswith("keep")) return false; unsigned Offset = SM.getFileOffset(Range.getBegin()); LastPragmaKeepInMainFileLine = @@ -161,8 +168,7 @@ // does not support them properly yet, so they will be not marked as // unused. // FIXME: Once IncludeCleaner supports export pragmas, remove this. - if (!Text.startswith(IWYUPragmaExport) && - !Text.startswith(IWYUPragmaBeginExports)) + if (!Pragma->startswith("export") && !Pragma->startswith("begin_exports")) return false; Out->HasIWYUExport.insert( *Out->getID(SM.getFileEntryForID(SM.getFileID(Range.getBegin())))); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/Headers.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/Headers.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/Headers.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/Headers.h 2023-01-24 23:05:56.000000000 +0000 @@ -35,6 +35,12 @@ /// Returns true if \p Include is literal include like "path" or . bool isLiteralInclude(llvm::StringRef Include); +/// If Text begins an Include-What-You-Use directive, returns it. +/// Given "// IWYU pragma: keep", returns "keep". +/// Input is a null-terminated char* as provided by SM.getCharacterData(). +/// (This should not be StringRef as we do *not* want to scan for its length). +llvm::Optional parseIWYUPragma(const char *Text); + /// Represents a header file to be #include'd. struct HeaderFile { std::string File; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/index/CanonicalIncludes.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/index/CanonicalIncludes.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/index/CanonicalIncludes.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/index/CanonicalIncludes.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -17,8 +17,6 @@ namespace clang { namespace clangd { namespace { -const char IWYUPragma[] = "// IWYU pragma: private, include "; - const std::pair IncludeMappings[] = { {"include/__stddef_max_align_t.h", ""}, {"include/__wmmintrin_aes.h", ""}, @@ -712,17 +710,17 @@ PragmaCommentHandler(CanonicalIncludes *Includes) : Includes(Includes) {} bool HandleComment(Preprocessor &PP, SourceRange Range) override { - llvm::StringRef Text = - Lexer::getSourceText(CharSourceRange::getCharRange(Range), - PP.getSourceManager(), PP.getLangOpts()); - if (!Text.consume_front(IWYUPragma)) + auto Pragma = parseIWYUPragma( + PP.getSourceManager().getCharacterData(Range.getBegin())); + if (!Pragma || !Pragma->consume_front("private, include ")) return false; auto &SM = PP.getSourceManager(); // We always insert using the spelling from the pragma. if (auto *FE = SM.getFileEntryForID(SM.getFileID(Range.getBegin()))) - Includes->addMapping( - FE->getLastRef(), - isLiteralInclude(Text) ? Text.str() : ("\"" + Text + "\"").str()); + Includes->addMapping(FE->getLastRef(), + isLiteralInclude(*Pragma) + ? Pragma->str() + : ("\"" + *Pragma + "\"").str()); return false; } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/InlayHints.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/InlayHints.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/InlayHints.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/InlayHints.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -10,6 +10,7 @@ #include "Config.h" #include "HeuristicResolver.h" #include "ParsedAST.h" +#include "SourceCode.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclarationName.h" #include "clang/AST/ExprCXX.h" @@ -192,8 +193,8 @@ public: InlayHintVisitor(std::vector &Results, ParsedAST &AST, const Config &Cfg, llvm::Optional RestrictRange) - : Results(Results), AST(AST.getASTContext()), Cfg(Cfg), - RestrictRange(std::move(RestrictRange)), + : Results(Results), AST(AST.getASTContext()), Tokens(AST.getTokens()), + Cfg(Cfg), RestrictRange(std::move(RestrictRange)), MainFileID(AST.getSourceManager().getMainFileID()), Resolver(AST.getHeuristicResolver()), TypeHintPolicy(this->AST.getPrintingPolicy()), @@ -227,8 +228,7 @@ return true; } - processCall(E->getParenOrBraceRange().getBegin(), E->getConstructor(), - {E->getArgs(), E->getNumArgs()}); + processCall(E->getConstructor(), {E->getArgs(), E->getNumArgs()}); return true; } @@ -254,7 +254,7 @@ if (!Callee) return true; - processCall(E->getRParenLoc(), Callee, {E->getArgs(), E->getNumArgs()}); + processCall(Callee, {E->getArgs(), E->getNumArgs()}); return true; } @@ -278,11 +278,11 @@ return true; } - void addReturnTypeHint(FunctionDecl *D, SourceLocation Loc) { + void addReturnTypeHint(FunctionDecl *D, SourceRange Range) { auto *AT = D->getReturnType()->getContainedAutoType(); if (!AT || AT->getDeducedType().isNull()) return; - addTypeHint(Loc, D->getReturnType(), /*Prefix=*/"-> "); + addTypeHint(Range, D->getReturnType(), /*Prefix=*/"-> "); } bool VisitVarDecl(VarDecl *D) { @@ -375,21 +375,11 @@ private: using NameVec = SmallVector; - // The purpose of Anchor is to deal with macros. It should be the call's - // opening or closing parenthesis or brace. (Always using the opening would - // make more sense but CallExpr only exposes the closing.) We heuristically - // assume that if this location does not come from a macro definition, then - // the entire argument list likely appears in the main file and can be hinted. - void processCall(SourceLocation Anchor, const FunctionDecl *Callee, + void processCall(const FunctionDecl *Callee, llvm::ArrayRef Args) { if (!Cfg.InlayHints.Parameters || Args.size() == 0 || !Callee) return; - // If the anchor location comes from a macro defintion, there's nowhere to - // put hints. - if (!AST.getSourceManager().getTopMacroCallerLoc(Anchor).isFileID()) - return; - // The parameter name of a move or copy constructor is not very interesting. if (auto *Ctor = dyn_cast(Callee)) if (Ctor->isCopyOrMoveConstructor()) @@ -637,25 +627,33 @@ #undef CHECK_KIND } - auto FileRange = - toHalfOpenFileRange(AST.getSourceManager(), AST.getLangOpts(), R); - if (!FileRange) + auto LSPRange = getHintRange(R); + if (!LSPRange) return; - Range LSPRange{ - sourceLocToPosition(AST.getSourceManager(), FileRange->getBegin()), - sourceLocToPosition(AST.getSourceManager(), FileRange->getEnd())}; - Position LSPPos = Side == HintSide::Left ? LSPRange.start : LSPRange.end; + Position LSPPos = Side == HintSide::Left ? LSPRange->start : LSPRange->end; if (RestrictRange && (LSPPos < RestrictRange->start || !(LSPPos < RestrictRange->end))) return; - // The hint may be in a file other than the main file (for example, a header - // file that was included after the preamble), do not show in that case. - if (!AST.getSourceManager().isWrittenInMainFile(FileRange->getBegin())) - return; bool PadLeft = Prefix.consume_front(" "); bool PadRight = Suffix.consume_back(" "); Results.push_back(InlayHint{LSPPos, (Prefix + Label + Suffix).str(), Kind, - PadLeft, PadRight, LSPRange}); + PadLeft, PadRight, *LSPRange}); + } + + // Get the range of the main file that *exactly* corresponds to R. + llvm::Optional getHintRange(SourceRange R) { + const auto &SM = AST.getSourceManager(); + auto Spelled = Tokens.spelledForExpanded(Tokens.expandedTokens(R)); + // TokenBuffer will return null if e.g. R corresponds to only part of a + // macro expansion. + if (!Spelled || Spelled->empty()) + return llvm::None; + // Hint must be within the main file, not e.g. a non-preamble include. + if (SM.getFileID(Spelled->front().location()) != SM.getMainFileID() || + SM.getFileID(Spelled->back().location()) != SM.getMainFileID()) + return llvm::None; + return Range{sourceLocToPosition(SM, Spelled->front().location()), + sourceLocToPosition(SM, Spelled->back().endLocation())}; } void addTypeHint(SourceRange R, QualType T, llvm::StringRef Prefix) { @@ -680,6 +678,7 @@ std::vector &Results; ASTContext &AST; + const syntax::TokenBuffer &Tokens; const Config &Cfg; llvm::Optional RestrictRange; FileID MainFileID; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/test/lit.site.cfg.py.in rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/test/lit.site.cfg.py.in --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/test/lit.site.cfg.py.in 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/test/lit.site.cfg.py.in 2023-01-24 23:05:56.000000000 +0000 @@ -10,6 +10,7 @@ config.clang_tools_dir = lit_config.substitute("@CURRENT_TOOLS_DIR@") config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@") config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@") +config.llvm_shlib_dir = "@SHLIBDIR@" config.clangd_source_dir = "@CMAKE_CURRENT_SOURCE_DIR@/.." config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.." diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/TidyProvider.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/TidyProvider.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/TidyProvider.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/TidyProvider.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -212,8 +212,14 @@ // code, which is often the case when clangd // tries to build an AST. "-bugprone-use-after-move", - // Alias for bugprone-use-after-moe. - "-hicpp-invalid-access-moved"); + // Alias for bugprone-use-after-move. + "-hicpp-invalid-access-moved", + + // ----- Performance problems ----- + + // This check runs expensive analysis for each variable. + // It has been observed to increase reparse time by 10x. + "-misc-const-correctness"); size_t Size = BadChecks.size(); for (const std::string &Str : ExtraBadChecks) { diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -1014,6 +1014,23 @@ EXPECT_THAT(Results.Completions, Not(Contains(labeled("clang::")))); } +TEST(CompletionTests, EmptySnippetDoesNotCrash) { + // See https://github.com/clangd/clangd/issues/1216 + auto Results = completions(R"cpp( + int main() { + auto w = [&](auto &&f) { return f(f); }; + auto f = w([&](auto &&f) { + return [&](auto &&n) { + if (n == 0) { + return 1; + } + return n * ^(f)(n - 1); + }; + })(10); + } + )cpp"); +} + TEST(CompletionTest, BacktrackCrashes) { // Sema calls code completion callbacks twice in these cases. auto Results = completions(R"cpp( diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -415,6 +415,19 @@ // Make sure we don't crash. Mangler.adjust(Args, "foo.cc"); } + +TEST(CommandMangler, PathsAsPositional) { + const auto Mangler = CommandMangler::forTests(); + std::vector Args = { + "clang", + "--driver-mode=cl", + "-I", + "foo", + }; + // Make sure we don't crash. + Mangler.adjust(Args, "a.cc"); + EXPECT_THAT(Args, Contains("foo")); +} } // namespace } // namespace clangd } // namespace clang diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/unittests/HeadersTests.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/unittests/HeadersTests.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/unittests/HeadersTests.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/unittests/HeadersTests.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -9,6 +9,7 @@ #include "Headers.h" #include "Compiler.h" +#include "Matchers.h" #include "TestFS.h" #include "TestTU.h" #include "clang/Basic/TokenKinds.h" @@ -30,6 +31,7 @@ using ::testing::AllOf; using ::testing::Contains; using ::testing::ElementsAre; +using ::testing::Eq; using ::testing::IsEmpty; using ::testing::Not; using ::testing::UnorderedElementsAre; @@ -445,6 +447,18 @@ EXPECT_FALSE(Includes.hasIWYUExport(getID("none.h", Includes))); } +TEST(Headers, ParseIWYUPragma) { + EXPECT_THAT(parseIWYUPragma("// IWYU pragma: keep"), HasValue(Eq("keep"))); + EXPECT_THAT(parseIWYUPragma("// IWYU pragma: keep\netc"), + HasValue(Eq("keep"))); + EXPECT_EQ(parseIWYUPragma("/* IWYU pragma: keep"), llvm::None) + << "Only // comments supported!"; + EXPECT_EQ(parseIWYUPragma("// IWYU pragma: keep"), llvm::None) + << "Sensitive to whitespace"; + EXPECT_EQ(parseIWYUPragma("// IWYU pragma:keep"), llvm::None) + << "Sensitive to whitespace"; +} + } // namespace } // namespace clangd } // namespace clang diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/unittests/InlayHintTests.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/unittests/InlayHintTests.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clangd/unittests/InlayHintTests.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clangd/unittests/InlayHintTests.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -820,6 +820,15 @@ } )cpp", ExpectedHint{"param: ", "param"}); + + // If the macro expands to multiple arguments, don't hint it. + assertParameterHints(R"cpp( + void foo(double x, double y); + #define CONSTANTS 3.14, 2.72 + void bar() { + foo(CONSTANTS); + } + )cpp"); } TEST(ParameterHints, ConstructorParens) { diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -12,8 +12,6 @@ #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchers.h" -#include - using namespace clang::ast_matchers; namespace clang { @@ -132,6 +130,12 @@ VC = VariableCategory::Reference; if (Variable->getType()->isPointerType()) VC = VariableCategory::Pointer; + if (Variable->getType()->isArrayType()) { + if (const auto *ArrayT = dyn_cast(Variable->getType())) { + if (ArrayT->getElementType()->isPointerType()) + VC = VariableCategory::Pointer; + } + } // Each variable can only be in one category: Value, Pointer, Reference. // Analysis can be controlled for every category. diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -472,8 +472,8 @@ checkSingleStatement(If->getThen(), parseReturnLiteralBool); if (ThenReturnBool && ThenReturnBool.Bool != TrailingReturnBool.Bool) { - if (Check->ChainedConditionalReturn || - (!PrevIf && If->getElse() == nullptr)) { + if ((Check->ChainedConditionalReturn || !PrevIf) && + If->getElse() == nullptr) { Check->replaceCompoundReturnWithCondition( Context, cast(*Second), TrailingReturnBool.Bool, If, ThenReturnBool.Item); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst 2023-01-24 23:05:56.000000000 +0000 @@ -4,12 +4,12 @@ ====================== This check implements detection of local variables which could be declared as -``const``, but are not. Declaring variables as ``const`` is required or recommended by many +``const`` but are not. Declaring variables as ``const`` is required or recommended by many coding guidelines, such as: `CppCoreGuidelines ES.25 `_ and `AUTOSAR C++14 Rule A7-1-1 (6.7.1 Specifiers) `_. -Please note that this analysis is type-based only. Variables that are not modified +Please note that this check's analysis is type-based only. Variables that are not modified but used to create a non-const handle that might escape the scope are not diagnosed as potential ``const``. @@ -18,25 +18,29 @@ // Declare a variable, which is not ``const`` ... int i = 42; // but use it as read-only. This means that `i` can be declared ``const``. - int result = i * i; + int result = i * i; // Before transformation + int const result = i * i; // After transformation -The check can analyzes values, pointers and references but not (yet) pointees: +The check can analyze values, pointers and references but not (yet) pointees: .. code-block:: c++ // Normal values like built-ins or objects. - int potential_const_int = 42; // 'const int potential_const_int = 42' suggestion. + int potential_const_int = 42; // Before transformation + int const potential_const_int = 42; // After transformation int copy_of_value = potential_const_int; - MyClass could_be_const; // 'const MyClass could_be_const' suggestion; + MyClass could_be_const; // Before transformation + MyClass const could_be_const; // After transformation could_be_const.const_qualified_method(); // References can be declared const as well. - int &reference_value = potential_const_int; // 'const int &reference_value' suggestion. + int &reference_value = potential_const_int; // Before transformation + int const& reference_value = potential_const_int; // After transformation int another_copy = reference_value; // The similar semantics of pointers are not (yet) analyzed. - int *pointer_variable = &potential_const_int; // Not 'const int *pointer_variable' suggestion. + int *pointer_variable = &potential_const_int; // _NO_ 'const int *pointer_variable' suggestion. int last_copy = *pointer_variable; The automatic code transformation is only applied to variables that are declared in single @@ -44,18 +48,20 @@ `readability-isolate-declaration `_ first. Note that there is the check -`cppcoreguidelines-avoid-non-const-global-variables `_ +`cppcoreguidelines-avoid-non-const-global-variables <../cppcoreguidelines/avoid-non-const-global-variables.html>`_ to enforce ``const`` correctness on all globals. Known Limitations ----------------- +The check does not run on `C` code. + The check will not analyze templated variables or variables that are instantiation dependent. Different instantiations can result in different ``const`` correctness properties and in general it -is not possible to find all instantiations of a template. It might be used differently in an -independent translation unit. +is not possible to find all instantiations of a template. The template might be used differently in +an independent translation unit. -Pointees can not be analyzed for constness yet. The following code is shows this limitation. +Pointees can not be analyzed for constness yet. The following code shows this limitation. .. code-block:: c++ @@ -74,15 +80,35 @@ Options ------- -.. option:: AnalyzeValues (default = 1) +.. option:: AnalyzeValues (default = true) Enable or disable the analysis of ordinary value variables, like ``int i = 42;`` -.. option:: AnalyzeReferences (default = 1) + .. code-block:: c++ + + // Warning + int i = 42; + // No warning + int const i = 42; + + // Warning + int a[] = {42, 42, 42}; + // No warning + int const a[] = {42, 42, 42}; + +.. option:: AnalyzeReferences (default = true) Enable or disable the analysis of reference variables, like ``int &ref = i;`` -.. option:: WarnPointersAsValues (default = 0) + .. code-block:: c++ + + int i = 42; + // Warning + int& ref = i; + // No warning + int const& ref = i; + +.. option:: WarnPointersAsValues (default = false) This option enables the suggestion for ``const`` of the pointer itself. Pointer values have two possibilities to be ``const``, the pointer @@ -90,28 +116,36 @@ .. code-block:: c++ - const int value = 42; - const int * const pointer_variable = &value; + int value = 42; - // The following operations are forbidden for `pointer_variable`. - // *pointer_variable = 44; - // pointer_variable = nullptr; + // Warning + const int * pointer_variable = &value; + // No warning + const int *const pointer_variable = &value; -.. option:: TransformValues (default = 1) +.. option:: TransformValues (default = true) - Provides fixit-hints for value types that automatically adds ``const`` if its a single declaration. + Provides fixit-hints for value types that automatically add ``const`` if its a single declaration. .. code-block:: c++ - // Emits a hint for 'value' to become 'const int value = 42;'. + // Before int value = 42; + // After + int const value = 42; + + // Before + int a[] = {42, 42, 42}; + // After + int const a[] = {42, 42, 42}; + // Result is modified later in its life-time. No diagnostic and fixit hint will be emitted. int result = value * 3; result -= 10; -.. option:: TransformReferences (default = 1) +.. option:: TransformReferences (default = true) - Provides fixit-hints for reference types that automatically adds ``const`` if its a single + Provides fixit-hints for reference types that automatically add ``const`` if its a single declaration. .. code-block:: c++ @@ -120,31 +154,45 @@ // it, it can not be transformed (yet). int value = 42; // The reference 'ref_value' is not modified and can be made 'const int &ref_value = value;' + // Before int &ref_value = value; + // After + int const &ref_value = value; // Result is modified later in its life-time. No diagnostic and fixit hint will be emitted. int result = ref_value * 3; result -= 10; -.. option:: TransformPointersAsValues (default = 0) +.. option:: TransformPointersAsValues (default = false) Provides fixit-hints for pointers if their pointee is not changed. This does not analyze if the value-pointed-to is unchanged! - Requires 'WarnPointersAsValues' to be 1. + Requires 'WarnPointersAsValues' to be 'true'. .. code-block:: c++ int value = 42; - // Emits a hint that 'ptr_value' may become 'int *const ptr_value = &value' because its pointee - // is not changed. + + // Before + const int * pointer_variable = &value; + // After + const int *const pointer_variable = &value; + + // Before + const int * a[] = {&value, &value}; + // After + const int *const a[] = {&value, &value}; + + // Before int *ptr_value = &value; + // After + int *const ptr_value = &value; - int result = 100 * (*ptr_value); - // This modification of the pointee is still allowed and not analyzed/diagnosed. + int result = 100 * (*ptr_value); // Does not modify the pointer itself. + // This modification of the pointee is still allowed and not diagnosed. *ptr_value = 0; // The following pointer may not become a 'int *const'. int *changing_pointee = &value; changing_pointee = &result; - diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/docs/ReleaseNotes.rst rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/docs/ReleaseNotes.rst --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/docs/ReleaseNotes.rst 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/docs/ReleaseNotes.rst 2023-01-24 23:05:56.000000000 +0000 @@ -8,13 +8,6 @@ Written by the `LLVM Team `_ -.. only:: PreRelease - - .. warning:: - These are in-progress notes for the upcoming Extra Clang Tools |version| release. - Release notes for previous releases can be found on - `the Download Page `_. - Introduction ============ @@ -259,12 +252,12 @@ - Fixed a false positive in :doc:`misc-unused-parameters ` - where invalid parameters were implicitly being treated as being unused. + where invalid parameters were implicitly being treated as being unused. This fixes `Issue 56152 `_. - Fixed false positives in :doc:`misc-unused-using-decls ` where `using` statements bringing - operators into the scope where incorrectly marked as unused. + operators into the scope where incorrectly marked as unused. This fixes `issue 55095 `_. - Fixed a false positive in :doc:`modernize-deprecated-headers diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-values.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-values.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-values.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-values.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -10,4 +10,65 @@ double *p_local0 = &np_local0[1]; // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double *' can be declared 'const' // CHECK-FIXES: double *const p_local0 + + using doublePtr = double*; + using doubleArray = double[15]; + doubleArray np_local1; + doublePtr p_local1 = &np_local1[0]; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'doublePtr' (aka 'double *') can be declared 'const' + // CHECK-FIXES: doublePtr const p_local1 +} + +void range_for() { + int np_local0[2] = {1, 2}; + int *p_local0[2] = {&np_local0[0], &np_local0[1]}; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int *[2]' can be declared 'const' + // CHECK-FIXES: int *const p_local0[2] + for (const int *p_local1 : p_local0) { + // CHECK-MESSAGES: [[@LINE-1]]:8: warning: variable 'p_local1' of type 'const int *' can be declared 'const' + // CHECK-FIXES: for (const int *const p_local1 : p_local0) + } + + int *p_local2[2] = {nullptr, nullptr}; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local2' of type 'int *[2]' can be declared 'const' + // CHECK-FIXES: int *const p_local2[2] + for (const auto *con_ptr : p_local2) { + } + +} + +template +struct SmallVectorBase { + T data[4]; + void push_back(const T &el) {} + int size() const { return 4; } + T *begin() { return data; } + const T *begin() const { return data; } + T *end() { return data + 4; } + const T *end() const { return data + 4; } +}; + +template +struct SmallVector : SmallVectorBase {}; + +template +void EmitProtocolMethodList(T &&Methods) { + // Note: If the template is uninstantiated the analysis does not figure out, + // that p_local0 could be const. Not sure why, but probably bails because + // some expressions are type-dependent. + SmallVector p_local0; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'SmallVector' can be declared 'const' + // CHECK-FIXES: SmallVector const p_local0 + SmallVector np_local0; + for (const auto *I : Methods) { + if (I == nullptr) + np_local0.push_back(I); + } + p_local0.size(); +} +void instantiate() { + int *p_local0[4] = {nullptr, nullptr, nullptr, nullptr}; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int *[4]' can be declared 'const' + // CHECK-FIXES: int *const p_local0[4] + EmitProtocolMethodList(p_local0); } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -526,18 +526,13 @@ // CHECK-FIXES: int const p_local1[2] for (const int &const_ref : p_local1) { } +} - int *p_local2[2] = {&np_local0[0], &np_local0[1]}; - // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local2' of type 'int *[2]' can be declared 'const' - // CHECK-FIXES: int *const p_local2[2] - for (const int *con_ptr : p_local2) { - } - - int *p_local3[2] = {nullptr, nullptr}; - // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local3' of type 'int *[2]' can be declared 'const' - // CHECK-FIXES: int *const p_local3[2] - for (const auto *con_ptr : p_local3) { - } +void arrays_of_pointers_are_ignored() { + int *np_local0[2] = {nullptr, nullptr}; + + using intPtr = int*; + intPtr np_local1[2] = {nullptr, nullptr}; } inline void *operator new(decltype(sizeof(void *)), void *p) { return p; } @@ -908,41 +903,6 @@ sizeof(int[++N]); } -template -struct SmallVectorBase { - T data[4]; - void push_back(const T &el) {} - int size() const { return 4; } - T *begin() { return data; } - const T *begin() const { return data; } - T *end() { return data + 4; } - const T *end() const { return data + 4; } -}; - -template -struct SmallVector : SmallVectorBase {}; - -template -void EmitProtocolMethodList(T &&Methods) { - // Note: If the template is uninstantiated the analysis does not figure out, - // that p_local0 could be const. Not sure why, but probably bails because - // some expressions are type-dependent. - SmallVector p_local0; - // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'SmallVector' can be declared 'const' - // CHECK-FIXES: SmallVector const p_local0 - SmallVector np_local0; - for (const auto *I : Methods) { - if (I == nullptr) - np_local0.push_back(I); - } - p_local0.size(); -} -void instantiate() { - int *p_local0[4] = {nullptr, nullptr, nullptr, nullptr}; - // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int *[4]' can be declared 'const' - // CHECK-FIXES: int *const p_local0[4] - EmitProtocolMethodList(p_local0); -} struct base { int member; }; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/test/clang-tidy/checkers/readability/simplify-bool-expr-chained-conditional-return.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/test/clang-tidy/checkers/readability/simplify-bool-expr-chained-conditional-return.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/clang-tools-extra/test/clang-tidy/checkers/readability/simplify-bool-expr-chained-conditional-return.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/clang-tools-extra/test/clang-tidy/checkers/readability/simplify-bool-expr-chained-conditional-return.cpp 2023-01-24 23:05:56.000000000 +0000 @@ -92,3 +92,14 @@ // CHECK-FIXES: {{^}} }{{$}} // CHECK-FIXES: {{^ return i <= 10;$}} // CHECK-FIXES: {{^}$}} + + +bool PR57819(int x) { + // False positive introduced in clang-tidy-15 + // Expect no warning here. + if (x > 0) + return false; + else { + } + return true; +} diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/cmake/Modules/FindLibEdit.cmake rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/cmake/Modules/FindLibEdit.cmake --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/cmake/Modules/FindLibEdit.cmake 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/cmake/Modules/FindLibEdit.cmake 2023-01-24 23:06:00.000000000 +0000 @@ -21,6 +21,7 @@ include(CheckIncludeFile) if(LibEdit_INCLUDE_DIRS AND EXISTS "${LibEdit_INCLUDE_DIRS}/histedit.h") + include(CMakePushCheckState) cmake_push_check_state() list(APPEND CMAKE_REQUIRED_INCLUDES ${LibEdit_INCLUDE_DIRS}) list(APPEND CMAKE_REQUIRED_LIBRARIES ${LibEdit_LIBRARIES}) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/compiler-rt/cmake/config-ix.cmake rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/compiler-rt/cmake/config-ix.cmake --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/compiler-rt/cmake/config-ix.cmake 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/compiler-rt/cmake/config-ix.cmake 2023-01-24 23:06:00.000000000 +0000 @@ -209,7 +209,7 @@ # runtime libraries supported by our current compilers cross-compiling # abilities. set(SIMPLE_SOURCE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/simple.cc) -file(WRITE ${SIMPLE_SOURCE} "#include \n#include \nint main() { printf(\"hello, world\"); }\n") +file(WRITE ${SIMPLE_SOURCE} "#include \n#include \nint main(void) { printf(\"hello, world\"); }\n") # Detect whether the current target platform is 32-bit or 64-bit, and setup # the correct commandline flags needed to attempt to target 32-bit and 64-bit. diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake 2023-01-24 23:06:00.000000000 +0000 @@ -116,7 +116,7 @@ if(NOT TEST_COMPILE_ONLY) message(STATUS "Finding valid architectures for ${os}...") set(SIMPLE_C ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/src.c) - file(WRITE ${SIMPLE_C} "#include \nint main() { printf(__FILE__); return 0; }\n") + file(WRITE ${SIMPLE_C} "#include \nint main(void) { printf(__FILE__); return 0; }\n") set(os_linker_flags) foreach(flag ${DARWIN_${os}_LINK_FLAGS}) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/compiler-rt/cmake/Modules/CompilerRTUtils.cmake rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/compiler-rt/cmake/Modules/CompilerRTUtils.cmake --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/compiler-rt/cmake/Modules/CompilerRTUtils.cmake 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/compiler-rt/cmake/Modules/CompilerRTUtils.cmake 2023-01-24 23:06:00.000000000 +0000 @@ -484,6 +484,10 @@ set(target "${COMPILER_RT_DEFAULT_TARGET_TRIPLE}") elseif(ANDROID AND ${arch} STREQUAL "i386") set(target "i686${triple_suffix}") + elseif(${arch} STREQUAL "amd64") + set(target "x86_64${triple_suffix}") + elseif(${arch} STREQUAL "sparc64") + set(target "sparcv9${triple_suffix}") else() set(target "${arch}${triple_suffix}") endif() diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/compiler-rt/lib/builtins/CMakeLists.txt rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/compiler-rt/lib/builtins/CMakeLists.txt --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/compiler-rt/lib/builtins/CMakeLists.txt 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/compiler-rt/lib/builtins/CMakeLists.txt 2023-01-24 23:06:00.000000000 +0000 @@ -745,7 +745,7 @@ SOURCE "#if !(__ARM_FP & 0x8) #error No double-precision support! #endif - int main() { return 0; }") + int main(void) { return 0; }") if(NOT COMPILER_RT_HAS_${arch}_VFP_DP) list(REMOVE_ITEM ${arch}_SOURCES ${arm_Thumb1_VFPv2_DP_SOURCES}) endif() diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc 2023-01-24 23:06:00.000000000 +0000 @@ -6703,7 +6703,7 @@ COMMON_INTERCEPTOR_ENTER(ctx, sem_init, s, pshared, value); // Workaround a bug in glibc's "old" semaphore implementation by // zero-initializing the sem_t contents. This has to be done here because - // interceptors bind to the lowest symbols version by default, hitting the + // interceptors bind to the lowest version before glibc 2.36, hitting the // buggy code path while the non-sanitized build of the same code works fine. REAL(memset)(s, 0, sizeof(*s)); int res = REAL(sem_init)(s, pshared, value); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/compiler-rt/test/lit.common.cfg.py rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/compiler-rt/test/lit.common.cfg.py --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/compiler-rt/test/lit.common.cfg.py 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/compiler-rt/test/lit.common.cfg.py 2023-01-24 23:06:00.000000000 +0000 @@ -540,9 +540,12 @@ # We require both ld.bfd and ld.gold exist and support plugins. They are in # the same repository 'binutils-gdb' and usually built together. for exe in (config.gnu_ld_executable, config.gold_executable): - ld_cmd = subprocess.Popen([exe, '--help'], stdout=subprocess.PIPE, env={'LANG': 'C'}) - ld_out = ld_cmd.stdout.read().decode() - ld_cmd.wait() + try: + ld_cmd = subprocess.Popen([exe, '--help'], stdout=subprocess.PIPE, env={'LANG': 'C'}) + ld_out = ld_cmd.stdout.read().decode() + ld_cmd.wait() + except OSError: + return False if not '-plugin' in ld_out: return False diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cpp 2023-01-24 23:06:00.000000000 +0000 @@ -1,39 +1,36 @@ // RUN: %clangxx -O0 -g %s -lutil -o %t && %run %t // This test depends on the glibc layout of struct sem_t and checks that we // don't leave sem_t::private uninitialized. -// UNSUPPORTED: android, lsan-x86, ubsan, target-is-mips64, target-is-mips64el +// UNSUPPORTED: android, lsan-x86, ubsan #include #include #include #include #include -// On powerpc64be semval_t must be 64 bits even with "old" versions of glibc. -#if __PPC64__ && __BIG_ENDIAN__ -typedef uint64_t semval_t; - -// This condition needs to correspond to __HAVE_64B_ATOMICS macro in glibc. -#elif (defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \ - defined(__s390x__) || defined(__sparc64__) || defined(__alpha__) || \ - defined(__ia64__) || defined(__m68k__)) && __GLIBC_PREREQ(2, 21) -typedef uint64_t semval_t; -#else +// musl and glibc's __HAVE_64B_ATOMICS==0 ports (e.g. arm, i386) use 32-bit sem +// values. 64-bit glibc ports defining sem_init@GLIBC_2.0 (mips64) use 32-bit as +// well, if the sem_init interceptor picks the oldest versioned symbol +// (glibc<2.36, see https://sourceware.org/PR14932). +#if !defined(__GLIBC__) || defined(__ILP32__) || \ + !__GLIBC_PREREQ(2, 36) && defined(__mips64__) typedef unsigned semval_t; +#else +typedef uint64_t semval_t; #endif -// glibc 2.21 has introduced some changes in the way the semaphore value is -// handled for 32-bit platforms, but since these changes are not ABI-breaking -// they are not versioned. On newer platforms such as ARM, there is only one -// version of the symbol, so it's enough to check the glibc version. However, -// for old platforms such as i386, glibc contains two or even three versions of -// the sem_init symbol, and the sanitizers always pick the oldest one. -// Therefore, it is not enough to rely on the __GLIBC_PREREQ macro - we should -// instead check the platform as well to make sure we only expect the new -// behavior on platforms where the older symbols do not exist. -#if defined(__arm__) && __GLIBC_PREREQ(2, 21) -#define GET_SEM_VALUE(V) ((V) >> 1) +// glibc __HAVE_64B_ATOMICS==0 ports define a sem_init which shifts the value by +// 1 (https://sourceware.org/PR12674 glibc 2.21). The version is picked if +// either glibc>=2.36 or sem_init@GLIBC_2.0 is absent (arm and newer ports). +// +// The __GLIBC_PREREQ check is brittle in that it requires matched +// __GLIBC_PREREQ values for build time and run time. +#if defined(__GLIBC__) && defined(__ILP32__) && \ + (__GLIBC_PREREQ(2, 36) || (__GLIBC_PREREQ(2, 21) && !defined(__i386__) && \ + !defined(__mips__) && !defined(__powerpc__))) +# define GET_SEM_VALUE(V) ((V) >> 1) #else -#define GET_SEM_VALUE(V) (V) +# define GET_SEM_VALUE(V) (V) #endif void my_sem_init(bool priv, int value, semval_t *a, unsigned char *b) { diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/libunwind/cmake/config-ix.cmake rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/libunwind/cmake/config-ix.cmake --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/libunwind/cmake/config-ix.cmake 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/libunwind/cmake/config-ix.cmake 2023-01-24 23:06:00.000000000 +0000 @@ -85,7 +85,7 @@ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unknown-pragmas") check_c_source_compiles(" #pragma comment(lib, \"c\") -int main() { return 0; } +int main(void) { return 0; } " C_SUPPORTS_COMMENT_LIB_PRAGMA) cmake_pop_check_state() endif() diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/libunwind/src/UnwindRustSgx.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/libunwind/src/UnwindRustSgx.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/libunwind/src/UnwindRustSgx.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/libunwind/src/UnwindRustSgx.h 2023-01-24 23:06:00.000000000 +0000 @@ -22,24 +22,14 @@ // We have to use RWLock from rust repo, it is defined in: // src/libstd/sys/sgx/rwlock.rs. -// rwlock.rs has compile time check to ensure sizeof(RWLock) = 144. +// rwlock.rs has a compile time check to ensure the size and alignment matches +// the Rust definition. typedef struct { - unsigned char opaque[144]; + void *opaque; } RWLock; -// The below is obtained by printing initialized bytes -// for RWLock in rust repo: src/libstd/sys/sgx/rwlock.rs. -#define RWLOCK_INIT { { \ - /* 0x00 */ 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \ - /* 0x10 */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \ - /* 0x20 */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \ - /* 0x30 */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \ - /* 0x40 */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \ - /* 0x50 */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \ - /* 0x60 */ 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \ - /* 0x70 */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \ - /* 0x80 */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \ - } } +#define RWLOCK_INIT \ + { (void *)0 } // These are the functions exposed by SGX-Rust. // The rust changes are available at: diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/COFF/CMakeLists.txt rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/COFF/CMakeLists.txt --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/COFF/CMakeLists.txt 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/COFF/CMakeLists.txt 2023-01-24 23:06:00.000000000 +0000 @@ -44,6 +44,7 @@ LINK_LIBS lldCommon ${LLVM_PTHREAD_LIB} + ${LLVM_ATOMIC_LIB} DEPENDS COFFOptionsTableGen diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/COFF/Symbols.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/COFF/Symbols.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/COFF/Symbols.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/COFF/Symbols.h 2023-01-24 23:06:00.000000000 +0000 @@ -106,7 +106,10 @@ : symbolKind(k), isExternal(true), isCOMDAT(false), writtenToSymtab(false), pendingArchiveLoad(false), isGCRoot(false), isRuntimePseudoReloc(false), deferUndefined(false), canInline(true), - nameSize(n.size()), nameData(n.empty() ? nullptr : n.data()) {} + nameSize(n.size()), nameData(n.empty() ? nullptr : n.data()) { + assert((!n.empty() || k <= LastDefinedCOFFKind) && + "If the name is empty, the Symbol must be a DefinedCOFF."); + } const unsigned symbolKind : 8; unsigned isExternal : 1; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/COFF/Writer.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/COFF/Writer.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/COFF/Writer.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/COFF/Writer.cpp 2023-01-24 23:06:00.000000000 +0000 @@ -395,7 +395,7 @@ default: llvm_unreachable("Unexpected architecture"); } - Defined *d = make("", c); + Defined *d = make("range_extension_thunk", c); lastThunk = d; return {d, true}; } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/Common/CMakeLists.txt rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/Common/CMakeLists.txt --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/Common/CMakeLists.txt 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/Common/CMakeLists.txt 2023-01-24 23:06:00.000000000 +0000 @@ -1,9 +1,3 @@ -set(LLD_SYSTEM_LIBS ${LLVM_PTHREAD_LIB}) - -if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB) - list(APPEND LLD_SYSTEM_LIBS atomic) -endif() - find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc) find_first_existing_vc_file("${LLD_SOURCE_DIR}" lld_vc) @@ -54,7 +48,8 @@ Target LINK_LIBS - ${LLD_SYSTEM_LIBS} + ${LLVM_PTHREAD_LIB} + ${LLVM_ATOMIC_LIB} DEPENDS intrinsics_gen diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/docs/ReleaseNotes.rst rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/docs/ReleaseNotes.rst --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/docs/ReleaseNotes.rst 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/docs/ReleaseNotes.rst 2023-01-24 23:06:00.000000000 +0000 @@ -5,13 +5,6 @@ .. contents:: :local: -.. only:: PreRelease - - .. warning:: - These are in-progress notes for the upcoming LLVM |release| release. - Release notes for previous releases can be found on - `the Download Page `_. - Introduction ============ diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/ELF/Arch/RISCV.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/ELF/Arch/RISCV.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/ELF/Arch/RISCV.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/ELF/Arch/RISCV.cpp 2023-01-24 23:06:00.000000000 +0000 @@ -750,12 +750,13 @@ p += size; // For R_RISCV_ALIGN, we will place `offset` in a location (among NOPs) - // to satisfy the alignment requirement. If `remove` is a multiple of 4, - // it is as if we have skipped some NOPs. Otherwise we are in the middle - // of a 4-byte NOP, and we need to rewrite the NOP sequence. + // to satisfy the alignment requirement. If both `remove` and r.addend + // are multiples of 4, it is as if we have skipped some NOPs. Otherwise + // we are in the middle of a 4-byte NOP, and we need to rewrite the NOP + // sequence. int64_t skip = 0; if (r.type == R_RISCV_ALIGN) { - if (remove % 4 != 0) { + if (remove % 4 || r.addend % 4) { skip = r.addend - remove; int64_t j = 0; for (; j + 4 <= skip; j += 4) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/ELF/Driver.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/ELF/Driver.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/ELF/Driver.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/ELF/Driver.cpp 2023-01-24 23:06:00.000000000 +0000 @@ -1330,12 +1330,15 @@ parseClangOption(std::string("-") + arg->getValue(), arg->getSpelling()); // GCC collect2 passes -plugin-opt=path/to/lto-wrapper with an absolute or - // relative path. Just ignore. If not ended with "lto-wrapper", consider it an + // relative path. Just ignore. If not ended with "lto-wrapper" (or + // "lto-wrapper.exe" for GCC cross-compiled for Windows), consider it an // unsupported LLVMgold.so option and error. - for (opt::Arg *arg : args.filtered(OPT_plugin_opt_eq)) - if (!StringRef(arg->getValue()).endswith("lto-wrapper")) + for (opt::Arg *arg : args.filtered(OPT_plugin_opt_eq)) { + StringRef v(arg->getValue()); + if (!v.endswith("lto-wrapper") && !v.endswith("lto-wrapper.exe")) error(arg->getSpelling() + ": unknown plugin option '" + arg->getValue() + "'"); + } config->passPlugins = args::getStrings(args, OPT_load_pass_plugins); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/ELF/InputFiles.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/ELF/InputFiles.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/ELF/InputFiles.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/ELF/InputFiles.cpp 2023-01-24 23:06:00.000000000 +0000 @@ -1157,7 +1157,7 @@ continue; } - if (binding == STB_WEAK) + if (sym.binding == STB_WEAK || binding == STB_WEAK) continue; std::lock_guard lock(mu); ctx->duplicates.push_back({&sym, this, sec, eSym.st_value}); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/MachO/InputFiles.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/MachO/InputFiles.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/MachO/InputFiles.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/MachO/InputFiles.cpp 2023-01-24 23:06:00.000000000 +0000 @@ -1587,6 +1587,15 @@ funcSym->unwindEntry = isec; ehRelocator.commit(); } + + // __eh_frame is marked as S_ATTR_LIVE_SUPPORT in input files, because FDEs + // are normally required to be kept alive if they reference a live symbol. + // However, we've explicitly created a dependency from a symbol to its FDE, so + // dead-stripping will just work as usual, and S_ATTR_LIVE_SUPPORT will only + // serve to incorrectly prevent us from dead-stripping duplicate FDEs for a + // live symbol (e.g. if there were multiple weak copies). Remove this flag to + // let dead-stripping proceed correctly. + ehFrameSection.flags &= ~S_ATTR_LIVE_SUPPORT; } std::string ObjFile::sourceFile() const { diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/MachO/UnwindInfoSection.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/MachO/UnwindInfoSection.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/MachO/UnwindInfoSection.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/MachO/UnwindInfoSection.cpp 2023-01-24 23:06:00.000000000 +0000 @@ -158,7 +158,7 @@ public: UnwindInfoSectionImpl() : cuOffsets(target->wordSize) {} uint64_t getSize() const override { return unwindInfoSize; } - void prepareRelocations() override; + void prepare() override; void finalize() override; void writeTo(uint8_t *buf) const override; @@ -166,6 +166,7 @@ void prepareRelocations(ConcatInputSection *); void relocateCompactUnwind(std::vector &); void encodePersonalities(); + Symbol *canonicalizePersonality(Symbol *); uint64_t unwindInfoSize = 0; std::vector symbolsVec; @@ -196,13 +197,13 @@ // Record function symbols that may need entries emitted in __unwind_info, which // stores unwind data for address ranges. // -// Note that if several adjacent functions have the same unwind encoding, LSDA, -// and personality function, they share one unwind entry. For this to work, -// functions without unwind info need explicit "no unwind info" unwind entries -// -- else the unwinder would think they have the unwind info of the closest -// function with unwind info right before in the image. Thus, we add function -// symbols for each unique address regardless of whether they have associated -// unwind info. +// Note that if several adjacent functions have the same unwind encoding and +// personality function and no LSDA, they share one unwind entry. For this to +// work, functions without unwind info need explicit "no unwind info" unwind +// entries -- else the unwinder would think they have the unwind info of the +// closest function with unwind info right before in the image. Thus, we add +// function symbols for each unique address regardless of whether they have +// associated unwind info. void UnwindInfoSection::addSymbol(const Defined *d) { if (d->unwindEntry) allEntriesAreOmitted = false; @@ -218,14 +219,24 @@ } } -void UnwindInfoSectionImpl::prepareRelocations() { +void UnwindInfoSectionImpl::prepare() { // This iteration needs to be deterministic, since prepareRelocations may add // entries to the GOT. Hence the use of a MapVector for // UnwindInfoSection::symbols. for (const Defined *d : make_second_range(symbols)) - if (d->unwindEntry && - d->unwindEntry->getName() == section_names::compactUnwind) - prepareRelocations(d->unwindEntry); + if (d->unwindEntry) { + if (d->unwindEntry->getName() == section_names::compactUnwind) { + prepareRelocations(d->unwindEntry); + } else { + // We don't have to add entries to the GOT here because FDEs have + // explicit GOT relocations, so Writer::scanRelocations() will add those + // GOT entries. However, we still need to canonicalize the personality + // pointers (like prepareRelocations() does for CU entries) in order + // to avoid overflowing the 3-personality limit. + FDE &fde = cast(d->getFile())->fdes[d->unwindEntry]; + fde.personality = canonicalizePersonality(fde.personality); + } + } } // Compact unwind relocations have different semantics, so we handle them in a @@ -279,6 +290,7 @@ continue; } + // Similar to canonicalizePersonality(), but we also register a GOT entry. if (auto *defined = dyn_cast(s)) { // Check if we have created a synthetic symbol at the same address. Symbol *&personality = @@ -291,6 +303,7 @@ } continue; } + assert(isa(s)); in.got->addEntry(s); continue; @@ -320,6 +333,18 @@ } } +Symbol *UnwindInfoSectionImpl::canonicalizePersonality(Symbol *personality) { + if (auto *defined = dyn_cast_or_null(personality)) { + // Check if we have created a synthetic symbol at the same address. + Symbol *&synth = personalityTable[{defined->isec, defined->value}]; + if (synth == nullptr) + synth = defined; + else if (synth != defined) + return synth; + } + return personality; +} + // We need to apply the relocations to the pre-link compact unwind section // before converting it to post-link form. There should only be absolute // relocations here: since we are not emitting the pre-link CU section, there @@ -427,9 +452,9 @@ // assigned, so we can relocate the __LD,__compact_unwind entries // into a temporary buffer. Relocation is necessary in order to sort // the CU entries by function address. Sorting is necessary so that - // we can fold adjacent CU entries with identical - // encoding+personality+lsda. Folding is necessary because it reduces - // the number of CU entries by as much as 3 orders of magnitude! + // we can fold adjacent CU entries with identical encoding+personality + // and without any LSDA. Folding is necessary because it reduces the + // number of CU entries by as much as 3 orders of magnitude! cuEntries.resize(symbols.size()); // The "map" part of the symbols MapVector was only needed for deduplication // in addSymbol(). Now that we are done adding, move the contents to a plain @@ -445,7 +470,7 @@ return cuEntries[a].functionAddress < cuEntries[b].functionAddress; }); - // Fold adjacent entries with matching encoding+personality+lsda + // Fold adjacent entries with matching encoding+personality and without LSDA // We use three iterators on the same cuIndices to fold in-situ: // (1) `foldBegin` is the first of a potential sequence of matching entries // (2) `foldEnd` is the first non-matching entry after `foldBegin`. @@ -455,11 +480,32 @@ auto foldWrite = cuIndices.begin(); for (auto foldBegin = cuIndices.begin(); foldBegin < cuIndices.end();) { auto foldEnd = foldBegin; + // Common LSDA encodings (e.g. for C++ and Objective-C) contain offsets from + // a base address. The base address is normally not contained directly in + // the LSDA, and in that case, the personality function treats the starting + // address of the function (which is computed by the unwinder) as the base + // address and interprets the LSDA accordingly. The unwinder computes the + // starting address of a function as the address associated with its CU + // entry. For this reason, we cannot fold adjacent entries if they have an + // LSDA, because folding would make the unwinder compute the wrong starting + // address for the functions with the folded entries, which in turn would + // cause the personality function to misinterpret the LSDA for those + // functions. In the very rare case where the base address is encoded + // directly in the LSDA, two functions at different addresses would + // necessarily have different LSDAs, so their CU entries would not have been + // folded anyway. while (++foldEnd < cuIndices.end() && cuEntries[*foldBegin].encoding == cuEntries[*foldEnd].encoding && + !cuEntries[*foldBegin].lsda && !cuEntries[*foldEnd].lsda && + // If we've gotten to this point, we don't have an LSDA, which should + // also imply that we don't have a personality function, since in all + // likelihood a personality function needs the LSDA to do anything + // useful. It can be technically valid to have a personality function + // and no LSDA though (e.g. the C++ personality __gxx_personality_v0 + // is just a no-op without LSDA), so we still check for personality + // function equivalence to handle that case. cuEntries[*foldBegin].personality == cuEntries[*foldEnd].personality && - cuEntries[*foldBegin].lsda == cuEntries[*foldEnd].lsda && canFoldEncoding(cuEntries[*foldEnd].encoding)) ; *foldWrite++ = *foldBegin; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/MachO/UnwindInfoSection.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/MachO/UnwindInfoSection.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/MachO/UnwindInfoSection.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/MachO/UnwindInfoSection.h 2023-01-24 23:06:00.000000000 +0000 @@ -24,7 +24,7 @@ // section entirely. bool isNeeded() const override { return !allEntriesAreOmitted; } void addSymbol(const Defined *); - virtual void prepareRelocations() = 0; + virtual void prepare() = 0; protected: UnwindInfoSection(); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/MachO/Writer.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/MachO/Writer.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/MachO/Writer.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/MachO/Writer.cpp 2023-01-24 23:06:00.000000000 +0000 @@ -675,7 +675,7 @@ } } - in.unwindInfo->prepareRelocations(); + in.unwindInfo->prepare(); } void Writer::scanSymbols() { diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/COFF/arm64-thunks.s rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/COFF/arm64-thunks.s --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/COFF/arm64-thunks.s 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/COFF/arm64-thunks.s 2023-01-24 23:06:00.000000000 +0000 @@ -1,6 +1,6 @@ // REQUIRES: aarch64 // RUN: llvm-mc -filetype=obj -triple=aarch64-windows %s -o %t.obj -// RUN: lld-link -entry:main -subsystem:console %t.obj -out:%t.exe -verbose 2>&1 | FileCheck -check-prefix=VERBOSE %s +// RUN: lld-link -entry:main -subsystem:console %t.obj -out:%t.exe -map -verbose 2>&1 | FileCheck -check-prefix=VERBOSE %s // RUN: llvm-objdump -d %t.exe | FileCheck --check-prefix=DISASM %s // VERBOSE: Added 2 thunks with margin {{.*}} in 1 passes diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/COFF/arm-thumb-thunks.s rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/COFF/arm-thumb-thunks.s --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/COFF/arm-thumb-thunks.s 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/COFF/arm-thumb-thunks.s 2023-01-24 23:06:00.000000000 +0000 @@ -1,6 +1,6 @@ // REQUIRES: arm // RUN: llvm-mc -filetype=obj -triple=thumbv7-windows %s -o %t.obj -// RUN: lld-link -entry:main -subsystem:console %t.obj -out:%t.exe -verbose 2>&1 | FileCheck -check-prefix=VERBOSE %s +// RUN: lld-link -entry:main -subsystem:console %t.obj -out:%t.exe -map -verbose 2>&1 | FileCheck -check-prefix=VERBOSE %s // RUN: llvm-objdump -d %t.exe --start-address=0x401000 --stop-address=0x401022 | FileCheck --check-prefix=MAIN %s // RUN: llvm-objdump -d %t.exe --start-address=0x501022 --stop-address=0x501032 | FileCheck --check-prefix=FUNC1 %s // RUN: llvm-objdump -d %t.exe --start-address=0x601032 | FileCheck --check-prefix=FUNC2 %s diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/ELF/comdat-binding2.s rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/ELF/comdat-binding2.s --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/ELF/comdat-binding2.s 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/ELF/comdat-binding2.s 2023-01-24 23:06:01.000000000 +0000 @@ -0,0 +1,42 @@ +# REQUIRES: x86 +## Test we don't report duplicate definition errors when mixing Clang STB_WEAK +## and GCC STB_GNU_UNIQUE symbols. + +# RUN: rm -rf %t && split-file %s %t && cd %t +# RUN: llvm-mc -filetype=obj -triple=x86_64 weak.s -o weak.o +# RUN: llvm-mc -filetype=obj -triple=x86_64 unique.s -o unique.o +# RUN: ld.lld weak.o unique.o -o weak +# RUN: llvm-readelf -s weak | FileCheck %s --check-prefix=WEAK +# RUN: ld.lld unique.o weak.o -o unique +# RUN: llvm-readelf -s unique | FileCheck %s --check-prefix=UNIQUE + +# WEAK: OBJECT WEAK DEFAULT [[#]] _ZN1BIiE1aE +# UNIQUE: OBJECT UNIQUE DEFAULT [[#]] _ZN1BIiE1aE + +#--- weak.s +## Clang + .type _ZN1BIiE1aE,@object + .section .bss._ZN1BIiE1aE,"aGwR",@nobits,_ZN1BIiE1aE,comdat + .weak _ZN1BIiE1aE +_ZN1BIiE1aE: + .zero 4 + + .type _ZGVN1BIiE1aE,@object + .section .bss._ZGVN1BIiE1aE,"aGw",@nobits,_ZN1BIiE1aE,comdat + .weak _ZGVN1BIiE1aE +_ZGVN1BIiE1aE: + .quad 0 + +#--- unique.s +## GCC -fgnu-unique. Note the different group signature for the second group. + .weak _ZN1BIiE1aE + .section .bss._ZN1BIiE1aE,"awG",@nobits,_ZN1BIiE1aE,comdat + .type _ZN1BIiE1aE, @gnu_unique_object +_ZN1BIiE1aE: + .zero 4 + + .weak _ZGVN1BIiE1aE + .section .bss._ZGVN1BIiE1aE,"awG",@nobits,_ZGVN1BIiE1aE,comdat + .type _ZGVN1BIiE1aE, @gnu_unique_object +_ZGVN1BIiE1aE: + .zero 8 diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/ELF/lto-plugin-ignore.s rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/ELF/lto-plugin-ignore.s --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/ELF/lto-plugin-ignore.s 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/ELF/lto-plugin-ignore.s 2023-01-24 23:06:01.000000000 +0000 @@ -8,7 +8,9 @@ # RUN: ld.lld %t.o -o /dev/null \ # RUN: -plugin path/to/liblto_plugin.so \ # RUN: -plugin-opt=/path/to/lto-wrapper \ +# RUN: -plugin-opt=/path/to/lto-wrapper.exe \ # RUN: -plugin-opt=relative/path/to/lto-wrapper \ +# RUN: -plugin-opt=relative/path/to/lto-wrapper.exe \ # RUN: -plugin-opt=-fresolution=zed \ # RUN: -plugin-opt=-pass-through=-lgcc \ # RUN: -plugin-opt=-pass-through=-lgcc_eh \ diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/ELF/riscv-relax-align-rvc.s rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/ELF/riscv-relax-align-rvc.s --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/ELF/riscv-relax-align-rvc.s 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/ELF/riscv-relax-align-rvc.s 2023-01-24 23:06:01.000000000 +0000 @@ -50,6 +50,12 @@ # CHECK-NEXT: c.addi a0, 8 # CHECK-EMPTY: +# CHECK: <.text2>: +# CHECK-NEXT: addi a0, a1, 1 +# CHECK-NEXT: c.addi a0, 1 +# CHECK-NEXT: c.nop +# CHECK-NEXT: c.addi a0, 2 + .global _start _start: c.addi a0, 1 @@ -73,3 +79,10 @@ c.addi a0, 8 .size d, . - d .size _start, . - _start + +.section .text2,"ax" +.balign 16 + addi a0, a1, 1 + c.addi a0, 1 +.balign 8 + c.addi a0, 2 diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/MachO/compact-unwind-lsda-folding.s rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/MachO/compact-unwind-lsda-folding.s --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/MachO/compact-unwind-lsda-folding.s 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/MachO/compact-unwind-lsda-folding.s 2023-01-24 23:06:01.000000000 +0000 @@ -0,0 +1,151 @@ +## Verify that the compact unwind entries for two functions with identical +## unwind information and LSDA aren't folded together; see the comment in +## UnwindInfoSectionImpl::finalize for why. + +# REQUIRES: x86 +# RUN: rm -rf %t; mkdir %t +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos11.0 -o %t/lsda.o %s +# RUN: %lld -dylib --icf=all -lSystem -lc++ -o %t/liblsda.dylib %t/lsda.o +# RUN: llvm-objdump --macho --syms --unwind-info %t/liblsda.dylib | FileCheck %s + +## Check that f and g have the same unwind encoding and LSDA offset (we need to +## link with ICF above in order to get the LSDA deduplicated), and that their +## compact unwind entries aren't folded. + +# CHECK-LABEL: SYMBOL TABLE: +# CHECK: [[#%x,G_ADDR:]] {{.*}} __Z1gv +# CHECK: [[#%x,H_ADDR:]] {{.*}} __Z1hv + +# CHECK-LABEL: Contents of __unwind_info section: +# CHECK: LSDA descriptors +# CHECK-NEXT: [0]: function offset=[[#%#.8x,G_ADDR]], LSDA offset=[[#%#x,LSDA:]] +# CHECK-NEXT: [1]: function offset=[[#%#.8x,H_ADDR]], LSDA offset=[[#%#.8x,LSDA]] +# CHECK-NEXT: Second level indices: +# CHECK: [1]: function offset=[[#%#.8x,G_ADDR]], encoding[0]=[[#%#x,ENCODING:]] +# CHECK: [2]: function offset=[[#%#.8x,H_ADDR]], encoding[0]=[[#%#.8x,ENCODING]] + +## Generated from the following C++ code built with: +## clang -target x86_64-apple-macosx11.0 -S -Os -fno-inline -fomit-frame-pointer +## void f(int i) { throw i; } +## void g() { try { f(1); } catch (int) {} } +## void h() { try { f(2); } catch (int) {} } + + .section __TEXT,__text,regular,pure_instructions + .globl __Z1fi ## -- Begin function _Z1fi +__Z1fi: ## @_Z1fi + .cfi_startproc + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset %rbx, -16 + movl %edi, %ebx + movl $4, %edi + callq ___cxa_allocate_exception + movl %ebx, (%rax) + movq __ZTIi@GOTPCREL(%rip), %rsi + movq %rax, %rdi + xorl %edx, %edx + callq ___cxa_throw + .cfi_endproc + ## -- End function + .globl __Z1gv ## -- Begin function _Z1gv +__Z1gv: ## @_Z1gv +Lfunc_begin0: + .cfi_startproc + .cfi_personality 155, ___gxx_personality_v0 + .cfi_lsda 16, Lexception0 + pushq %rax + .cfi_def_cfa_offset 16 +Ltmp0: + movl $1, %edi + callq __Z1fi +Ltmp1: + ud2 +LBB1_2: ## %lpad +Ltmp2: + movq %rax, %rdi + callq ___cxa_begin_catch + popq %rax + jmp ___cxa_end_catch ## TAILCALL +Lfunc_end0: + .cfi_endproc + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table1: +Lexception0: + .byte 255 ## @LPStart Encoding = omit + .byte 155 ## @TType Encoding = indirect pcrel sdata4 + .uleb128 Lttbase0-Lttbaseref0 +Lttbaseref0: + .byte 1 ## Call site Encoding = uleb128 + .uleb128 Lcst_end0-Lcst_begin0 +Lcst_begin0: + .uleb128 Ltmp0-Lfunc_begin0 ## >> Call Site 1 << + .uleb128 Ltmp1-Ltmp0 ## Call between Ltmp0 and Ltmp1 + .uleb128 Ltmp2-Lfunc_begin0 ## jumps to Ltmp2 + .byte 1 ## On action: 1 + .uleb128 Ltmp1-Lfunc_begin0 ## >> Call Site 2 << + .uleb128 Lfunc_end0-Ltmp1 ## Call between Ltmp1 and Lfunc_end0 + .byte 0 ## has no landing pad + .byte 0 ## On action: cleanup +Lcst_end0: + .byte 1 ## >> Action Record 1 << + ## Catch TypeInfo 1 + .byte 0 ## No further actions + .p2align 2, 0x0 + ## >> Catch TypeInfos << + .long __ZTIi@GOTPCREL+4 ## TypeInfo 1 +Lttbase0: + .p2align 2, 0x0 + ## -- End function + .section __TEXT,__text,regular,pure_instructions + .globl __Z1hv ## -- Begin function _Z1hv +__Z1hv: ## @_Z1hv +Lfunc_begin1: + .cfi_startproc + .cfi_personality 155, ___gxx_personality_v0 + .cfi_lsda 16, Lexception1 + pushq %rax + .cfi_def_cfa_offset 16 +Ltmp3: + movl $2, %edi + callq __Z1fi +Ltmp4: + ud2 +LBB2_2: ## %lpad +Ltmp5: + movq %rax, %rdi + callq ___cxa_begin_catch + popq %rax + jmp ___cxa_end_catch ## TAILCALL +Lfunc_end1: + .cfi_endproc + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table2: +Lexception1: + .byte 255 ## @LPStart Encoding = omit + .byte 155 ## @TType Encoding = indirect pcrel sdata4 + .uleb128 Lttbase1-Lttbaseref1 +Lttbaseref1: + .byte 1 ## Call site Encoding = uleb128 + .uleb128 Lcst_end1-Lcst_begin1 +Lcst_begin1: + .uleb128 Ltmp3-Lfunc_begin1 ## >> Call Site 1 << + .uleb128 Ltmp4-Ltmp3 ## Call between Ltmp3 and Ltmp4 + .uleb128 Ltmp5-Lfunc_begin1 ## jumps to Ltmp5 + .byte 1 ## On action: 1 + .uleb128 Ltmp4-Lfunc_begin1 ## >> Call Site 2 << + .uleb128 Lfunc_end1-Ltmp4 ## Call between Ltmp4 and Lfunc_end1 + .byte 0 ## has no landing pad + .byte 0 ## On action: cleanup +Lcst_end1: + .byte 1 ## >> Action Record 1 << + ## Catch TypeInfo 1 + .byte 0 ## No further actions + .p2align 2, 0x0 + ## >> Catch TypeInfos << + .long __ZTIi@GOTPCREL+4 ## TypeInfo 1 +Lttbase1: + .p2align 2, 0x0 + ## -- End function +.subsections_via_symbols diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/MachO/eh-frame-dead-strip.s rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/MachO/eh-frame-dead-strip.s --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/MachO/eh-frame-dead-strip.s 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/MachO/eh-frame-dead-strip.s 2023-01-24 23:06:01.000000000 +0000 @@ -0,0 +1,46 @@ +# REQUIRES: x86, aarch64 + +# RUN: rm -rf %t; split-file %s %t +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos11.0 %t/strong.s -o %t/strong_x86_64.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos11.0 %t/weak.s -o %t/weak_x86_64.o +# RUN: %lld -dylib -dead_strip %t/strong_x86_64.o %t/weak_x86_64.o -o %t/libstrongweak_x86_64.dylib +# RUN: llvm-dwarfdump --eh-frame %t/libstrongweak_x86_64.dylib | FileCheck --check-prefixes CHECK,X86_64 %s +# RUN: %lld -dylib -dead_strip %t/weak_x86_64.o %t/strong_x86_64.o -o %t/libweakstrong_x86_64.dylib +# RUN: llvm-dwarfdump --eh-frame %t/libweakstrong_x86_64.dylib | FileCheck --check-prefixes CHECK,X86_64 %s + +# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos11.0 %t/strong.s -o %t/strong_arm64.o +# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos11.0 %t/weak.s -o %t/weak_arm64.o +# RUN: %lld -arch arm64 -dylib -dead_strip %t/strong_arm64.o %t/weak_arm64.o -o %t/libstrongweak_arm64.dylib +# RUN: llvm-dwarfdump --eh-frame %t/libstrongweak_arm64.dylib | FileCheck --check-prefixes CHECK,ARM64 %s +# RUN: %lld -arch arm64 -dylib -dead_strip %t/weak_arm64.o %t/strong_arm64.o -o %t/libweakstrong_arm64.dylib +# RUN: llvm-dwarfdump --eh-frame %t/libweakstrong_arm64.dylib | FileCheck --check-prefixes CHECK,ARM64 %s + +## Verify that unneeded FDEs (and their CIEs) are dead-stripped even if they +## point to a live symbol (e.g. because we had multiple weak definitions). + +# CHECK: .eh_frame contents: +# X86_64: 00000000 00000014 00000000 CIE +# X86_64: 00000018 0000001c 0000001c FDE cie=00000000 +# ARM64: 00000000 00000010 00000000 CIE +# ARM64: 00000014 00000018 00000018 FDE cie=00000000 +# CHECK-NOT: CIE +# CHECK-NOT: FDE + +#--- strong.s +.globl _fun +_fun: + .cfi_startproc + ## cfi_escape cannot be encoded in compact unwind + .cfi_escape 0 + ret + .cfi_endproc + +#--- weak.s +.globl _fun +.weak_definition _fun +_fun: + .cfi_startproc + ## cfi_escape cannot be encoded in compact unwind + .cfi_escape 0 + ret + .cfi_endproc diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/MachO/eh-frame-personality-dedup.s rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/MachO/eh-frame-personality-dedup.s --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/MachO/eh-frame-personality-dedup.s 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/MachO/eh-frame-personality-dedup.s 2023-01-24 23:06:01.000000000 +0000 @@ -0,0 +1,43 @@ +# REQUIRES: x86 +# RUN: rm -rf %t; split-file %s %t +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/eh-frame.s -o %t/eh-frame.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/cu.s -o %t/cu.o +# RUN: %lld -dylib %t/cu.o %t/eh-frame.o -o %t/out + +## Sanity check: we want our input to contain a section (and not symbol) +## relocation for the personality reference. +# RUN: llvm-readobj --relocations %t/cu.o | FileCheck %s --check-prefix=SECT-RELOC +# SECT-RELOC: Section __compact_unwind { +# SECT-RELOC-NEXT: __text +# SECT-RELOC-NEXT: __text +# SECT-RELOC-NEXT: } + +## Verify that the personality referenced via a symbol reloc in eh-frame.s gets +## dedup'ed with the personality referenced via a section reloc in cu.s. +# RUN: llvm-objdump --macho --unwind-info %t/out | FileCheck %s +# CHECK: Personality functions: (count = 1) + +#--- eh-frame.s +_fun: + .cfi_startproc + .cfi_personality 155, _my_personality + ## cfi_escape cannot be encoded in compact unwind + .cfi_escape 0 + ret + .cfi_endproc + +.subsections_via_symbols + +#--- cu.s +.globl _my_personality +_fun: + .cfi_startproc + .cfi_personality 155, _my_personality + .cfi_def_cfa_offset 16 + ret + .cfi_endproc + +_my_personality: + nop + +.subsections_via_symbols diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/wasm/export-all.s rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/wasm/export-all.s --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/wasm/export-all.s 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/wasm/export-all.s 2023-01-24 23:06:01.000000000 +0000 @@ -40,9 +40,12 @@ # CHECK-NEXT: - Name: __heap_base # CHECK-NEXT: Kind: GLOBAL # CHECK-NEXT: Index: 4 -# CHECK-NEXT: - Name: __memory_base +# CHECK-NEXT: - Name: __heap_end # CHECK-NEXT: Kind: GLOBAL # CHECK-NEXT: Index: 5 -# CHECK-NEXT: - Name: __table_base +# CHECK-NEXT: - Name: __memory_base # CHECK-NEXT: Kind: GLOBAL # CHECK-NEXT: Index: 6 +# CHECK-NEXT: - Name: __table_base +# CHECK-NEXT: Kind: GLOBAL +# CHECK-NEXT: Index: 7 diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/wasm/mutable-global-exports.s rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/wasm/mutable-global-exports.s --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/test/wasm/mutable-global-exports.s 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/test/wasm/mutable-global-exports.s 2023-01-24 23:06:01.000000000 +0000 @@ -79,10 +79,13 @@ # CHECK-ALL-NEXT: - Name: __heap_base # CHECK-ALL-NEXT: Kind: GLOBAL # CHECK-ALL-NEXT: Index: 5 -# CHECK-ALL-NEXT: - Name: __memory_base +# CHECK-ALL-NEXT: - Name: __heap_end # CHECK-ALL-NEXT: Kind: GLOBAL # CHECK-ALL-NEXT: Index: 6 -# CHECK-ALL-NEXT: - Name: __table_base +# CHECK-ALL-NEXT: - Name: __memory_base # CHECK-ALL-NEXT: Kind: GLOBAL # CHECK-ALL-NEXT: Index: 7 +# CHECK-ALL-NEXT: - Name: __table_base +# CHECK-ALL-NEXT: Kind: GLOBAL +# CHECK-ALL-NEXT: Index: 8 # CHECK-ALL-NEXT: - Type: CODE diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/wasm/Driver.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/wasm/Driver.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/wasm/Driver.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/wasm/Driver.cpp 2023-01-24 23:06:01.000000000 +0000 @@ -681,6 +681,7 @@ if (!config->isPic) { WasmSym::globalBase = symtab->addOptionalDataSymbol("__global_base"); WasmSym::heapBase = symtab->addOptionalDataSymbol("__heap_base"); + WasmSym::heapEnd = symtab->addOptionalDataSymbol("__heap_end"); WasmSym::definedMemoryBase = symtab->addOptionalDataSymbol("__memory_base"); WasmSym::definedTableBase = symtab->addOptionalDataSymbol("__table_base"); if (config->is64.value_or(false)) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/wasm/Symbols.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/wasm/Symbols.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/wasm/Symbols.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/wasm/Symbols.cpp 2023-01-24 23:06:01.000000000 +0000 @@ -83,6 +83,7 @@ DefinedData *WasmSym::dataEnd; DefinedData *WasmSym::globalBase; DefinedData *WasmSym::heapBase; +DefinedData *WasmSym::heapEnd; DefinedData *WasmSym::initMemoryFlag; GlobalSymbol *WasmSym::stackPointer; GlobalSymbol *WasmSym::tlsBase; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/wasm/Symbols.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/wasm/Symbols.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/wasm/Symbols.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/wasm/Symbols.h 2023-01-24 23:06:01.000000000 +0000 @@ -538,11 +538,14 @@ // Symbol marking the end of the data and bss. static DefinedData *dataEnd; - // __heap_base - // Symbol marking the end of the data, bss and explicit stack. Any linear - // memory following this address is not used by the linked code and can - // therefore be used as a backing store for brk()/malloc() implementations. + // __heap_base/__heap_end + // Symbols marking the beginning and end of the "heap". It starts at the end + // of the data, bss and explicit stack, and extends to the end of the linear + // memory allocated by wasm-ld. This region of memory is not used by the + // linked code, so it may be used as a backing store for `sbrk` or `malloc` + // implementations. static DefinedData *heapBase; + static DefinedData *heapEnd; // __wasm_init_memory_flag // Symbol whose contents are nonzero iff memory has already been initialized. diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/wasm/Writer.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/wasm/Writer.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lld/wasm/Writer.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lld/wasm/Writer.cpp 2023-01-24 23:06:01.000000000 +0000 @@ -340,10 +340,20 @@ Twine(maxMemorySetting)); memoryPtr = config->initialMemory; } - out.memorySec->numMemoryPages = - alignTo(memoryPtr, WasmPageSize) / WasmPageSize; + + memoryPtr = alignTo(memoryPtr, WasmPageSize); + + out.memorySec->numMemoryPages = memoryPtr / WasmPageSize; log("mem: total pages = " + Twine(out.memorySec->numMemoryPages)); + if (WasmSym::heapEnd) { + // Set `__heap_end` to follow the end of the statically allocated linear + // memory. The fact that this comes last means that a malloc/brk + // implementation can grow the heap at runtime. + log("mem: heap end = " + Twine(memoryPtr)); + WasmSym::heapEnd->setVA(memoryPtr); + } + if (config->maxMemory != 0) { if (config->maxMemory != alignTo(config->maxMemory, WasmPageSize)) error("maximum memory must be " + Twine(WasmPageSize) + "-byte aligned"); @@ -363,7 +373,7 @@ if (config->isPic) max = maxMemorySetting; else - max = alignTo(memoryPtr, WasmPageSize); + max = memoryPtr; } out.memorySec->maxMemoryPages = max / WasmPageSize; log("mem: max pages = " + Twine(out.memorySec->maxMemoryPages)); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/bindings/CMakeLists.txt rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/bindings/CMakeLists.txt --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/bindings/CMakeLists.txt 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/bindings/CMakeLists.txt 2023-01-24 23:06:01.000000000 +0000 @@ -26,8 +26,6 @@ -features autodoc -I${LLDB_SOURCE_DIR}/include -I${CMAKE_CURRENT_SOURCE_DIR} - -D__STDC_LIMIT_MACROS - -D__STDC_CONSTANT_MACROS ${DARWIN_EXTRAS} ) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/bindings/interfaces.swig rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/bindings/interfaces.swig --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/bindings/interfaces.swig 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/bindings/interfaces.swig 2023-01-24 23:06:01.000000000 +0000 @@ -1,8 +1,5 @@ /* Various liblldb typedefs that SWIG needs to know about. */ #define __extension__ /* Undefine GCC keyword to make Swig happy when processing glibc's stdint.h. */ -/* The ISO C99 standard specifies that in C++ implementations limit macros such - as INT32_MAX should only be defined if __STDC_LIMIT_MACROS is. */ -#define __STDC_LIMIT_MACROS %include "stdint.i" %include "lldb/lldb-defines.h" diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/bindings/python/python-typemaps.swig rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/bindings/python/python-typemaps.swig --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/bindings/python/python-typemaps.swig 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/bindings/python/python-typemaps.swig 2023-01-24 23:06:01.000000000 +0000 @@ -435,7 +435,7 @@ %typemap(out) lldb::FileSP { $result = nullptr; - lldb::FileSP &sp = $1; + const lldb::FileSP &sp = $1; if (sp) { PythonFile pyfile = unwrapOrSetPythonException(PythonFile::FromFile(*sp)); if (!pyfile.IsValid()) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/include/lldb/API/SBType.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/include/lldb/API/SBType.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/include/lldb/API/SBType.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/include/lldb/API/SBType.h 2023-01-24 23:06:01.000000000 +0000 @@ -182,6 +182,8 @@ lldb::SBType GetTemplateArgumentType(uint32_t idx); + /// Return the TemplateArgumentKind of the template argument at index idx. + /// Variadic argument packs are automatically expanded. lldb::TemplateArgumentKind GetTemplateArgumentKind(uint32_t idx); lldb::SBType GetFunctionReturnType(); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/include/lldb/Symbol/CompilerType.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/include/lldb/Symbol/CompilerType.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/include/lldb/Symbol/CompilerType.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/include/lldb/Symbol/CompilerType.h 2023-01-24 23:06:01.000000000 +0000 @@ -338,14 +338,28 @@ GetIndexOfChildMemberWithName(const char *name, bool omit_empty_base_classes, std::vector &child_indexes) const; - size_t GetNumTemplateArguments() const; + /// Return the number of template arguments the type has. + /// If expand_pack is true, then variadic argument packs are automatically + /// expanded to their supplied arguments. If it is false an argument pack + /// will only count as 1 argument. + size_t GetNumTemplateArguments(bool expand_pack = false) const; - lldb::TemplateArgumentKind GetTemplateArgumentKind(size_t idx) const; - CompilerType GetTypeTemplateArgument(size_t idx) const; + // Return the TemplateArgumentKind of the template argument at index idx. + // If expand_pack is true, then variadic argument packs are automatically + // expanded to their supplied arguments. With expand_pack set to false, an + // arguement pack will count as 1 argument and return a type of Pack. + lldb::TemplateArgumentKind + GetTemplateArgumentKind(size_t idx, bool expand_pack = false) const; + CompilerType GetTypeTemplateArgument(size_t idx, + bool expand_pack = false) const; /// Returns the value of the template argument and its type. + /// If expand_pack is true, then variadic argument packs are automatically + /// expanded to their supplied arguments. With expand_pack set to false, an + /// arguement pack will count as 1 argument and it is invalid to call this + /// method on the pack argument. llvm::Optional - GetIntegralTemplateArgument(size_t idx) const; + GetIntegralTemplateArgument(size_t idx, bool expand_pack = false) const; CompilerType GetTypeForFormatters() const; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/include/lldb/Symbol/TypeSystem.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/include/lldb/Symbol/TypeSystem.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/include/lldb/Symbol/TypeSystem.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/include/lldb/Symbol/TypeSystem.h 2023-01-24 23:06:01.000000000 +0000 @@ -346,14 +346,18 @@ const char *name, bool omit_empty_base_classes, std::vector &child_indexes) = 0; - virtual size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type); + virtual size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type, + bool expand_pack); virtual lldb::TemplateArgumentKind - GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx); - virtual CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type, - size_t idx); + GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx, + bool expand_pack); + virtual CompilerType + GetTypeTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, + bool expand_pack); virtual llvm::Optional - GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx); + GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, + bool expand_pack); // Dumping types diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/source/API/SBType.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/source/API/SBType.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/source/API/SBType.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/source/API/SBType.cpp 2023-01-24 23:06:01.000000000 +0000 @@ -542,7 +542,8 @@ LLDB_INSTRUMENT_VA(this); if (IsValid()) - return m_opaque_sp->GetCompilerType(false).GetNumTemplateArguments(); + return m_opaque_sp->GetCompilerType(false).GetNumTemplateArguments( + /*expand_pack=*/true); return 0; } @@ -553,13 +554,15 @@ return SBType(); CompilerType type; + const bool expand_pack = true; switch(GetTemplateArgumentKind(idx)) { case eTemplateArgumentKindType: - type = m_opaque_sp->GetCompilerType(false).GetTypeTemplateArgument(idx); + type = m_opaque_sp->GetCompilerType(false).GetTypeTemplateArgument( + idx, expand_pack); break; case eTemplateArgumentKindIntegral: type = m_opaque_sp->GetCompilerType(false) - .GetIntegralTemplateArgument(idx) + .GetIntegralTemplateArgument(idx, expand_pack) ->type; break; default: @@ -574,7 +577,8 @@ LLDB_INSTRUMENT_VA(this, idx); if (IsValid()) - return m_opaque_sp->GetCompilerType(false).GetTemplateArgumentKind(idx); + return m_opaque_sp->GetCompilerType(false).GetTemplateArgumentKind( + idx, /*expand_pack=*/true); return eTemplateArgumentKindNull; } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/source/Plugins/Process/Linux/Perf.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/source/Plugins/Process/Linux/Perf.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/source/Plugins/Process/Linux/Perf.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/source/Plugins/Process/Linux/Perf.cpp 2023-01-24 23:06:01.000000000 +0000 @@ -127,6 +127,10 @@ } llvm::Error PerfEvent::MmapAuxBuffer(size_t num_aux_pages) { +#ifndef PERF_ATTR_SIZE_VER5 + return createStringError(inconvertibleErrorCode(), + "Intel PT Linux perf event not supported"); +#else if (num_aux_pages == 0) return Error::success(); @@ -143,6 +147,7 @@ return Error::success(); } else return mmap_aux.takeError(); +#endif } llvm::Error PerfEvent::MmapMetadataAndBuffers(size_t num_data_pages, @@ -172,16 +177,24 @@ } ArrayRef PerfEvent::GetDataBuffer() const { +#ifndef PERF_ATTR_SIZE_VER5 + llvm_unreachable("Intel PT Linux perf event not supported"); +#else perf_event_mmap_page &mmap_metadata = GetMetadataPage(); return {reinterpret_cast(m_metadata_data_base.get()) + mmap_metadata.data_offset, - static_cast(mmap_metadata.data_size)}; + static_cast(mmap_metadata.data_size)}; +#endif } ArrayRef PerfEvent::GetAuxBuffer() const { +#ifndef PERF_ATTR_SIZE_VER5 + llvm_unreachable("Intel PT Linux perf event not supported"); +#else perf_event_mmap_page &mmap_metadata = GetMetadataPage(); return {reinterpret_cast(m_aux_base.get()), - static_cast(mmap_metadata.aux_size)}; + static_cast(mmap_metadata.aux_size)}; +#endif } Expected> PerfEvent::GetReadOnlyDataBuffer() { @@ -190,6 +203,10 @@ // this piece of code updates some pointers. See more about data_tail // in https://man7.org/linux/man-pages/man2/perf_event_open.2.html. +#ifndef PERF_ATTR_SIZE_VER5 + return createStringError(inconvertibleErrorCode(), + "Intel PT Linux perf event not supported"); +#else bool was_enabled = m_enabled; if (Error err = DisableWithIoctl()) return std::move(err); @@ -226,6 +243,7 @@ } return output; +#endif } Expected> PerfEvent::GetReadOnlyAuxBuffer() { @@ -234,6 +252,10 @@ // this piece of code updates some pointers. See more about aux_tail // in https://man7.org/linux/man-pages/man2/perf_event_open.2.html. +#ifndef PERF_ATTR_SIZE_VER5 + return createStringError(inconvertibleErrorCode(), + "Intel PT Linux perf event not supported"); +#else bool was_enabled = m_enabled; if (Error err = DisableWithIoctl()) return std::move(err); @@ -266,6 +288,7 @@ } return output; +#endif } Error PerfEvent::DisableWithIoctl() { @@ -297,11 +320,15 @@ } size_t PerfEvent::GetEffectiveDataBufferSize() const { +#ifndef PERF_ATTR_SIZE_VER5 + llvm_unreachable("Intel PT Linux perf event not supported"); +#else perf_event_mmap_page &mmap_metadata = GetMetadataPage(); if (mmap_metadata.data_head < mmap_metadata.data_size) return mmap_metadata.data_head; else return mmap_metadata.data_size; // The buffer has wrapped. +#endif } Expected diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 2023-01-24 23:06:01.000000000 +0000 @@ -7096,7 +7096,8 @@ } size_t -TypeSystemClang::GetNumTemplateArguments(lldb::opaque_compiler_type_t type) { +TypeSystemClang::GetNumTemplateArguments(lldb::opaque_compiler_type_t type, + bool expand_pack) { if (!type) return 0; @@ -7111,8 +7112,17 @@ const clang::ClassTemplateSpecializationDecl *template_decl = llvm::dyn_cast( cxx_record_decl); - if (template_decl) - return template_decl->getTemplateArgs().size(); + if (template_decl) { + const auto &template_arg_list = template_decl->getTemplateArgs(); + size_t num_args = template_arg_list.size(); + assert(num_args && "template specialization without any args"); + if (expand_pack && num_args) { + const auto &pack = template_arg_list[num_args - 1]; + if (pack.getKind() == clang::TemplateArgument::Pack) + num_args += pack.pack_size() - 1; + } + return num_args; + } } } break; @@ -7149,15 +7159,51 @@ } } +const TemplateArgument * +GetNthTemplateArgument(const clang::ClassTemplateSpecializationDecl *decl, + size_t idx, bool expand_pack) { + const auto &args = decl->getTemplateArgs(); + const size_t args_size = args.size(); + + assert(args_size && "template specialization without any args"); + if (!args_size) + return nullptr; + + const size_t last_idx = args_size - 1; + + // We're asked for a template argument that can't be a parameter pack, so + // return it without worrying about 'expand_pack'. + if (idx < last_idx) + return &args[idx]; + + // We're asked for the last template argument but we don't want/need to + // expand it. + if (!expand_pack || args[last_idx].getKind() != clang::TemplateArgument::Pack) + return idx >= args.size() ? nullptr : &args[idx]; + + // Index into the expanded pack. + // Note that 'idx' counts from the beginning of all template arguments + // (including the ones preceding the parameter pack). + const auto &pack = args[last_idx]; + const size_t pack_idx = idx - last_idx; + const size_t pack_size = pack.pack_size(); + assert(pack_idx < pack_size && "parameter pack index out-of-bounds"); + return &pack.pack_elements()[pack_idx]; +} + lldb::TemplateArgumentKind TypeSystemClang::GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, - size_t arg_idx) { + size_t arg_idx, bool expand_pack) { const clang::ClassTemplateSpecializationDecl *template_decl = GetAsTemplateSpecialization(type); - if (! template_decl || arg_idx >= template_decl->getTemplateArgs().size()) + if (!template_decl) + return eTemplateArgumentKindNull; + + const auto *arg = GetNthTemplateArgument(template_decl, arg_idx, expand_pack); + if (!arg) return eTemplateArgumentKindNull; - switch (template_decl->getTemplateArgs()[arg_idx].getKind()) { + switch (arg->getKind()) { case clang::TemplateArgument::Null: return eTemplateArgumentKindNull; @@ -7190,35 +7236,32 @@ CompilerType TypeSystemClang::GetTypeTemplateArgument(lldb::opaque_compiler_type_t type, - size_t idx) { + size_t idx, bool expand_pack) { const clang::ClassTemplateSpecializationDecl *template_decl = GetAsTemplateSpecialization(type); - if (!template_decl || idx >= template_decl->getTemplateArgs().size()) + if (!template_decl) return CompilerType(); - const clang::TemplateArgument &template_arg = - template_decl->getTemplateArgs()[idx]; - if (template_arg.getKind() != clang::TemplateArgument::Type) + const auto *arg = GetNthTemplateArgument(template_decl, idx, expand_pack); + if (!arg || arg->getKind() != clang::TemplateArgument::Type) return CompilerType(); - return GetType(template_arg.getAsType()); + return GetType(arg->getAsType()); } Optional TypeSystemClang::GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, - size_t idx) { + size_t idx, bool expand_pack) { const clang::ClassTemplateSpecializationDecl *template_decl = GetAsTemplateSpecialization(type); - if (! template_decl || idx >= template_decl->getTemplateArgs().size()) + if (!template_decl) return llvm::None; - const clang::TemplateArgument &template_arg = - template_decl->getTemplateArgs()[idx]; - if (template_arg.getKind() != clang::TemplateArgument::Integral) + const auto *arg = GetNthTemplateArgument(template_decl, idx, expand_pack); + if (!arg || arg->getKind() != clang::TemplateArgument::Integral) return llvm::None; - return { - {template_arg.getAsIntegral(), GetType(template_arg.getIntegralType())}}; + return {{arg->getAsIntegral(), GetType(arg->getIntegralType())}}; } CompilerType TypeSystemClang::GetTypeForFormatters(void *type) { diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 2023-01-24 23:06:01.000000000 +0000 @@ -91,7 +91,7 @@ void SetOwningModule(OptionalClangModuleID id); /// \} }; - + /// A TypeSystem implementation based on Clang. /// /// This class uses a single clang::ASTContext as the backend for storing @@ -334,7 +334,7 @@ llvm::SmallVector names; llvm::SmallVector args; - + const char * pack_name = nullptr; std::unique_ptr packed_args; }; @@ -537,7 +537,7 @@ #ifndef NDEBUG bool Verify(lldb::opaque_compiler_type_t type) override; #endif - + bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, bool *is_incomplete) override; @@ -810,16 +810,17 @@ const char *name, bool omit_empty_base_classes, std::vector &child_indexes) override; - size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) override; + size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type, + bool expand_pack) override; lldb::TemplateArgumentKind - GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, - size_t idx) override; + GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx, + bool expand_pack) override; CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type, - size_t idx) override; + size_t idx, bool expand_pack) override; llvm::Optional - GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, - size_t idx) override; + GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, + bool expand_pack) override; CompilerType GetTypeForFormatters(void *type) override; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/source/Symbol/CompilerType.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/source/Symbol/CompilerType.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/source/Symbol/CompilerType.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/source/Symbol/CompilerType.cpp 2023-01-24 23:06:01.000000000 +0000 @@ -659,30 +659,32 @@ return 0; } -size_t CompilerType::GetNumTemplateArguments() const { +size_t CompilerType::GetNumTemplateArguments(bool expand_pack) const { if (IsValid()) { - return m_type_system->GetNumTemplateArguments(m_type); + return m_type_system->GetNumTemplateArguments(m_type, expand_pack); } return 0; } -TemplateArgumentKind CompilerType::GetTemplateArgumentKind(size_t idx) const { +TemplateArgumentKind +CompilerType::GetTemplateArgumentKind(size_t idx, bool expand_pack) const { if (IsValid()) - return m_type_system->GetTemplateArgumentKind(m_type, idx); + return m_type_system->GetTemplateArgumentKind(m_type, idx, expand_pack); return eTemplateArgumentKindNull; } -CompilerType CompilerType::GetTypeTemplateArgument(size_t idx) const { +CompilerType CompilerType::GetTypeTemplateArgument(size_t idx, + bool expand_pack) const { if (IsValid()) { - return m_type_system->GetTypeTemplateArgument(m_type, idx); + return m_type_system->GetTypeTemplateArgument(m_type, idx, expand_pack); } return CompilerType(); } llvm::Optional -CompilerType::GetIntegralTemplateArgument(size_t idx) const { +CompilerType::GetIntegralTemplateArgument(size_t idx, bool expand_pack) const { if (IsValid()) - return m_type_system->GetIntegralTemplateArgument(m_type, idx); + return m_type_system->GetIntegralTemplateArgument(m_type, idx, expand_pack); return llvm::None; } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/source/Symbol/TypeSystem.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/source/Symbol/TypeSystem.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/source/Symbol/TypeSystem.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/source/Symbol/TypeSystem.cpp 2023-01-24 23:06:01.000000000 +0000 @@ -118,23 +118,25 @@ return CompilerType(this, type); } -size_t TypeSystem::GetNumTemplateArguments(lldb::opaque_compiler_type_t type) { +size_t TypeSystem::GetNumTemplateArguments(lldb::opaque_compiler_type_t type, + bool expand_pack) { return 0; } TemplateArgumentKind -TypeSystem::GetTemplateArgumentKind(opaque_compiler_type_t type, size_t idx) { +TypeSystem::GetTemplateArgumentKind(opaque_compiler_type_t type, size_t idx, + bool expand_pack) { return eTemplateArgumentKindNull; } CompilerType TypeSystem::GetTypeTemplateArgument(opaque_compiler_type_t type, - size_t idx) { + size_t idx, bool expand_pack) { return CompilerType(); } llvm::Optional -TypeSystem::GetIntegralTemplateArgument(opaque_compiler_type_t type, - size_t idx) { +TypeSystem::GetIntegralTemplateArgument(opaque_compiler_type_t type, size_t idx, + bool expand_pack) { return llvm::None; } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/test/API/lang/cpp/class-template-parameter-pack/main.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/test/API/lang/cpp/class-template-parameter-pack/main.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/test/API/lang/cpp/class-template-parameter-pack/main.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/test/API/lang/cpp/class-template-parameter-pack/main.cpp 2023-01-24 23:06:02.000000000 +0000 @@ -26,7 +26,13 @@ bool argsAre_Int_bool() { return true; } }; +template struct OnlyPack {}; +template struct EmptyPack {}; + int main(int argc, char const *argv[]) { + EmptyPack emptyPack; + OnlyPack> onlyPack; + C myC; C myLesserC; myC.member = 64; @@ -34,7 +40,7 @@ (void)C().argsAre_16_32(); (void)(myC.member != 64); D myD; - D myLesserD; + D myLesserD; // breakpoint here myD.member = 64; (void)D().argsAre_Int_bool(); (void)D().argsAre_Int_bool(); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py 2023-01-24 23:06:02.000000000 +0000 @@ -0,0 +1,38 @@ +""" +Test that the type of arguments to C++ template classes that have variadic +parameters can be enumerated. +""" +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TemplatePackArgsTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def test_template_argument_pack(self): + self.build() + (_, _, thread, _) = lldbutil.run_to_source_breakpoint(self, + 'breakpoint here', lldb.SBFileSpec('main.cpp'), exe_name = 'a.out') + frame = thread.GetSelectedFrame() + + empty_pack = frame.FindVariable('emptyPack') + self.assertTrue(empty_pack.IsValid(), + 'make sure we find the emptyPack variable') + + only_pack = frame.FindVariable('onlyPack') + self.assertTrue(only_pack.IsValid(), + 'make sure we find the onlyPack variable') + self.assertEqual(only_pack.GetType().GetNumberOfTemplateArguments(), 4) + self.assertEqual(only_pack.GetType().GetTemplateArgumentType(0).GetName(), 'int') + self.assertEqual(only_pack.GetType().GetTemplateArgumentType(1).GetName(), 'char') + self.assertEqual(only_pack.GetType().GetTemplateArgumentType(2).GetName(), 'double') + # Access the C template parameter. + nested_template = only_pack.GetType().GetTemplateArgumentType(3) + self.assertEqual(nested_template.GetName(), 'D') + self.assertEqual(nested_template.GetNumberOfTemplateArguments(), 3) + self.assertEqual(nested_template.GetTemplateArgumentType(0).GetName(), 'int') + self.assertEqual(nested_template.GetTemplateArgumentType(1).GetName(), 'int') + self.assertEqual(nested_template.GetTemplateArgumentType(2).GetName(), 'bool') diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/tools/debugserver/source/CMakeLists.txt rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/tools/debugserver/source/CMakeLists.txt --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/tools/debugserver/source/CMakeLists.txt 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/tools/debugserver/source/CMakeLists.txt 2023-01-24 23:06:03.000000000 +0000 @@ -95,7 +95,7 @@ #else #error Not building for ARM64 #endif - int main() { return 0; } + int main(void) { return 0; } " BUILDING_FOR_ARM64_OSX ) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/unittests/Symbol/TestTypeSystemClang.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/unittests/Symbol/TestTypeSystemClang.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/lldb/unittests/Symbol/TestTypeSystemClang.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/lldb/unittests/Symbol/TestTypeSystemClang.cpp 2023-01-24 23:06:03.000000000 +0000 @@ -500,18 +500,24 @@ for (CompilerType t : {type, typedef_type, auto_type}) { SCOPED_TRACE(t.GetTypeName().AsCString()); - EXPECT_EQ(m_ast->GetTemplateArgumentKind(t.GetOpaqueQualType(), 0), - eTemplateArgumentKindType); - EXPECT_EQ(m_ast->GetTypeTemplateArgument(t.GetOpaqueQualType(), 0), - int_type); - EXPECT_EQ(llvm::None, - m_ast->GetIntegralTemplateArgument(t.GetOpaqueQualType(), 0)); + const bool expand_pack = false; + EXPECT_EQ( + m_ast->GetTemplateArgumentKind(t.GetOpaqueQualType(), 0, expand_pack), + eTemplateArgumentKindType); + EXPECT_EQ( + m_ast->GetTypeTemplateArgument(t.GetOpaqueQualType(), 0, expand_pack), + int_type); + EXPECT_EQ(llvm::None, m_ast->GetIntegralTemplateArgument( + t.GetOpaqueQualType(), 0, expand_pack)); - EXPECT_EQ(m_ast->GetTemplateArgumentKind(t.GetOpaqueQualType(), 1), - eTemplateArgumentKindIntegral); - EXPECT_EQ(m_ast->GetTypeTemplateArgument(t.GetOpaqueQualType(), 1), - CompilerType()); - auto result = m_ast->GetIntegralTemplateArgument(t.GetOpaqueQualType(), 1); + EXPECT_EQ( + m_ast->GetTemplateArgumentKind(t.GetOpaqueQualType(), 1, expand_pack), + eTemplateArgumentKindIntegral); + EXPECT_EQ( + m_ast->GetTypeTemplateArgument(t.GetOpaqueQualType(), 1, expand_pack), + CompilerType()); + auto result = m_ast->GetIntegralTemplateArgument(t.GetOpaqueQualType(), 1, + expand_pack); ASSERT_NE(llvm::None, result); EXPECT_EQ(arg, result->value); EXPECT_EQ(int_type, result->type); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/config-ix.cmake rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/config-ix.cmake --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/config-ix.cmake 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/config-ix.cmake 2023-01-24 23:06:04.000000000 +0000 @@ -71,7 +71,7 @@ CHECK_C_SOURCE_COMPILES(" static const char *__crashreporter_info__ = 0; asm(\".desc ___crashreporter_info__, 0x10\"); - int main() { return 0; }" + int main(void) { return 0; }" HAVE_CRASHREPORTER_INFO) endif() diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/AddLLVM.cmake rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/AddLLVM.cmake --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/AddLLVM.cmake 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/AddLLVM.cmake 2023-01-24 23:06:04.000000000 +0000 @@ -212,6 +212,7 @@ else() if("${stdout}" MATCHES "^mold") set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "") + set(LLVM_LINKER_IS_MOLD YES CACHE INTERNAL "") message(STATUS "Linker detection: mold") elseif("${stdout}" MATCHES "GNU gold") set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "") diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/CheckAtomic.cmake rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/CheckAtomic.cmake --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/CheckAtomic.cmake 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/CheckAtomic.cmake 2023-01-24 23:06:04.000000000 +0000 @@ -82,6 +82,19 @@ endif() endif() +# Set variable LLVM_ATOMIC_LIB specifying flags for linking against libatomic. +if(HAVE_CXX_ATOMICS_WITH_LIB OR HAVE_CXX_ATOMICS64_WITH_LIB) + # Use options --push-state, --as-needed and --pop-state if linker is known to support them. + # Use single option -Wl of compiler driver to avoid incorrect re-ordering of options by CMake. + if(LLVM_LINKER_IS_GNULD OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD OR LLVM_LINKER_IS_MOLD) + set(LLVM_ATOMIC_LIB "-Wl,--push-state,--as-needed,-latomic,--pop-state") + else() + set(LLVM_ATOMIC_LIB "-latomic") + endif() +else() + set(LLVM_ATOMIC_LIB) +endif() + ## TODO: This define is only used for the legacy atomic operations in ## llvm's Atomic.h, which should be replaced. Other code simply ## assumes C++11 works. diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/FindFFI.cmake rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/FindFFI.cmake --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/FindFFI.cmake 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/FindFFI.cmake 2023-01-24 23:06:04.000000000 +0000 @@ -45,7 +45,7 @@ struct ffi_cif; typedef struct ffi_cif ffi_cif; void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue); - int main() { ffi_call(0, 0, 0, 0); }" + int main(void) { ffi_call(0, 0, 0, 0); }" HAVE_FFI_CALL) cmake_pop_check_state() endif() diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/FindTerminfo.cmake rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/FindTerminfo.cmake --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/FindTerminfo.cmake 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/FindTerminfo.cmake 2023-01-24 23:06:04.000000000 +0000 @@ -20,7 +20,7 @@ list(APPEND CMAKE_REQUIRED_LIBRARIES ${Terminfo_LIBRARIES}) check_c_source_compiles(" int setupterm(char *term, int filedes, int *errret); - int main() { return setupterm(0, 0, 0); }" + int main(void) { return setupterm(0, 0, 0); }" Terminfo_LINKABLE) cmake_pop_check_state() endif() diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/FindZ3.cmake rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/FindZ3.cmake --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/FindZ3.cmake 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/FindZ3.cmake 2023-01-24 23:06:04.000000000 +0000 @@ -18,8 +18,9 @@ # The program that will be executed to print Z3's version. file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testz3.cpp "#include + #include #include - int main() { + int main(void) { unsigned int major, minor, build, rev; Z3_get_version(&major, &minor, &build, &rev); printf(\"%u.%u.%u\", major, minor, build); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/Findzstd.cmake rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/Findzstd.cmake --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/Findzstd.cmake 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/Findzstd.cmake 2023-01-24 23:06:04.000000000 +0000 @@ -0,0 +1,49 @@ +# Try to find the zstd library +# +# If successful, the following variables will be defined: +# zstd_INCLUDE_DIR +# zstd_LIBRARY +# zstd_FOUND +# +# Additionally, one of the following import targets will be defined: +# zstd::libzstd_shared +# zstd::libzstd_static + +if(MSVC) + set(zstd_SHARED_LIBRARY_SUFFIX "\\${CMAKE_LINK_LIBRARY_SUFFIX}$") + set(zstd_STATIC_LIBRARY_SUFFIX "_static\\${CMAKE_STATIC_LIBRARY_SUFFIX}$") +else() + set(zstd_SHARED_LIBRARY_SUFFIX "\\${CMAKE_SHARED_LIBRARY_SUFFIX}$") + set(zstd_STATIC_LIBRARY_SUFFIX "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$") +endif() + +find_path(zstd_INCLUDE_DIR NAMES zstd.h) +find_library(zstd_LIBRARY NAMES zstd zstd_static) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + zstd DEFAULT_MSG + zstd_LIBRARY zstd_INCLUDE_DIR +) + +if(zstd_FOUND) + if(zstd_LIBRARY MATCHES "${zstd_SHARED_LIBRARY_SUFFIX}$" AND + NOT TARGET zstd::libzstd_shared) + add_library(zstd::libzstd_shared SHARED IMPORTED) + set_target_properties(zstd::libzstd_shared PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}" + IMPORTED_LOCATION "${zstd_LIBRARY}") + endif() + if(zstd_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$" AND + NOT TARGET zstd::libzstd_static) + add_library(zstd::libzstd_static STATIC IMPORTED) + set_target_properties(zstd::libzstd_static PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}" + IMPORTED_LOCATION "${zstd_LIBRARY}") + endif() +endif() + +unset(zstd_SHARED_LIBRARY_SUFFIX) +unset(zstd_STATIC_LIBRARY_SUFFIX) + +mark_as_advanced(zstd_INCLUDE_DIR zstd_LIBRARY) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/HandleLLVMOptions.cmake rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/HandleLLVMOptions.cmake --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/HandleLLVMOptions.cmake 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/HandleLLVMOptions.cmake 2023-01-24 23:06:04.000000000 +0000 @@ -779,7 +779,7 @@ # line is also a // comment. set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror -Wcomment") - CHECK_C_SOURCE_COMPILES("// \\\\\\n//\\nint main() {return 0;}" + CHECK_C_SOURCE_COMPILES("// \\\\\\n//\\nint main(void) {return 0;}" C_WCOMMENT_ALLOWS_LINE_WRAP) set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) if (NOT C_WCOMMENT_ALLOWS_LINE_WRAP) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/LLVMConfig.cmake.in rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/LLVMConfig.cmake.in --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/cmake/modules/LLVMConfig.cmake.in 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/cmake/modules/LLVMConfig.cmake.in 2023-01-24 23:06:04.000000000 +0000 @@ -75,7 +75,6 @@ set(LLVM_ENABLE_ZSTD @LLVM_ENABLE_ZSTD@) if(LLVM_ENABLE_ZSTD) - set(zstd_ROOT @zstd_ROOT@) find_package(zstd) endif() diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/CMakeLists.txt rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/CMakeLists.txt --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/CMakeLists.txt 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/CMakeLists.txt 2023-01-24 23:06:03.000000000 +0000 @@ -22,7 +22,7 @@ set(LLVM_VERSION_MINOR 0) endif() if(NOT DEFINED LLVM_VERSION_PATCH) - set(LLVM_VERSION_PATCH 0) + set(LLVM_VERSION_PATCH 7) endif() if(NOT DEFINED LLVM_VERSION_SUFFIX) set(LLVM_VERSION_SUFFIX) @@ -446,6 +446,8 @@ set(LLVM_ENABLE_ZSTD "ON" CACHE STRING "Use zstd for compression/decompression if available. Can be ON, OFF, or FORCE_ON") +set(LLVM_USE_STATIC_ZSTD FALSE CACHE BOOL "Use static version of zstd. Can be TRUE, FALSE") + set(LLVM_ENABLE_CURL "OFF" CACHE STRING "Use libcurl for the HTTP client if available. Can be ON, OFF, or FORCE_ON") set(LLVM_ENABLE_HTTPLIB "OFF" CACHE STRING "Use cpp-httplib HTTP server library if available. Can be ON, OFF, or FORCE_ON") diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/docs/CommandGuide/llvm-symbolizer.rst rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/docs/CommandGuide/llvm-symbolizer.rst --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/docs/CommandGuide/llvm-symbolizer.rst 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/docs/CommandGuide/llvm-symbolizer.rst 2023-01-24 23:06:04.000000000 +0000 @@ -251,13 +251,24 @@ Reads from standard input, converts contained :doc:`Symbolizer Markup ` into human-readable form, - and prints the results to standard output. Presently, only the following - markup elements are supported: + and prints the results to standard output. The following markup elements are + not yet supported: + + * ``{{{hexdict}}}`` + * ``{{{dumpfile}}}`` + + The ``{{{bt}}}`` backtrace element reports frames using the following syntax: + + ``#[.]
:: (+)`` + + ```` provides frame numbers for calls inlined into the caller + coresponding to ````. The inlined call numbers start at 1 and increase + from callee to caller. + + ``
`` is an address inside the call instruction to the function. The + address may not be the start of the instruction. ```` is + the corresponding virtual offset in the ```` loaded at that address. - * ``{{symbol}}`` - * ``{{reset}}`` - * ``{{module}}`` - * ``{{mmap}}`` .. _llvm-symbolizer-opt-f: diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/docs/ReleaseNotes.rst rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/docs/ReleaseNotes.rst --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/docs/ReleaseNotes.rst 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/docs/ReleaseNotes.rst 2023-01-24 23:06:04.000000000 +0000 @@ -5,13 +5,6 @@ .. contents:: :local: -.. only:: PreRelease - - .. warning:: - These are in-progress notes for the upcoming LLVM |version| release. - Release notes for previous releases can be found on - `the Download Page `_. - Introduction ============ @@ -202,13 +195,52 @@ Changes to the RISC-V Backend ----------------------------- -* The Zvfh extension was added. +* A RISCVRedundantCopyElimination pass was added to remove unnecessary zero + copies. +* A RISC-V specific CodeGenPrepare pass was added. +* The machine outliner was enabled by default for RISC-V at ``-Oz``. + Additionally, the newly introduced RISCVMakeCompressible pass will make + modify instructions prior to emission at ``-Oz`` in order to increase + opportunities for the compression with the RISC-V C extension. +* Various bug fixes and improvements to code generation for the RISC-V vector + extensions. +* Various improvements were made to RISC-V specific optimisation passes such + as RISCVSExtWRemoval and RISCVMergeBaseOffset. +* llc now computes the target ABI based on the target architecture using the + same logic as Clang if not explicit ABI is given. +* ``generic`` is now recognized as a valid CPU name and is mapped to + ``generic-rv32`` or ``generic-rv64`` depending on the target triple. +* Support for the experimental Zvfh extension was added, enabling + half-precision floating point in vectors. +* Support for the Zihintpause (Pause Hint) extension. +* Assembler and disassembler support for the Zfinx and Zdinx (float / double + in integer register) extensions. +* Assembler and disassembler support for the Zicbom, Zicboz, and Zicbop cache + management operation extensions. +* Support for the Zmmul extension (a subextension of the M extension, adding + multiplication instructions only). +* Assembler and disassembler support for the hypervisor extension and for the + Sinval supervisor memory-management extension. Changes to the WebAssembly Backend ---------------------------------- * ... +Changes to the SystemZ Backend +------------------------------ + +* Support z16 processor name. +* Machine scheduler description for z16. +* Add support for inline assembly address operands ("p") as well as for SystemZ + specific address operands ("ZQ", "ZR", "ZS" and "ZT"). +* Efficient handling of small memcpy/memset operations up to 32 bytes. +* Tuning of the inliner. +* Fixing emission of library calls so that narrow integer arguments are sign or + zero extended per the SystemZ ABI. +* Support added for libunwind. +* Various minor improvements and bugfixes. + Changes to the X86 Backend -------------------------- diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/docs/SymbolizerMarkupFormat.rst rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/docs/SymbolizerMarkupFormat.rst --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/docs/SymbolizerMarkupFormat.rst 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/docs/SymbolizerMarkupFormat.rst 2023-01-24 23:06:04.000000000 +0000 @@ -184,7 +184,7 @@ {{{symbol:_ZN7Mangled4NameEv}}} {{{symbol:foobar}}} -``{{{pc:%p}}}``, ``{{{pc:%p:ra}}}``, ``{{{pc:%p:pc}}}`` [#not_yet_implemented]_ +``{{{pc:%p}}}``, ``{{{pc:%p:ra}}}``, ``{{{pc:%p:pc}}}`` Here ``%p`` is the memory address of a code location. It might be presented as a function name and source location. The second two forms distinguish the kind of @@ -195,7 +195,7 @@ {{{pc:0x12345678}}} {{{pc:0xffffffff9abcdef0}}} -``{{{data:%p}}}`` [#not_yet_implemented]_ +``{{{data:%p}}}`` Here ``%p`` is the memory address of a data location. It might be presented as the name of a global variable at that location. @@ -205,7 +205,7 @@ {{{data:0x12345678}}} {{{data:0xffffffff9abcdef0}}} -``{{{bt:%u:%p}}}``, ``{{{bt:%u:%p:ra}}}``, ``{{{bt:%u:%p:pc}}}`` [#not_yet_implemented]_ +``{{{bt:%u:%p}}}``, ``{{{bt:%u:%p:ra}}}``, ``{{{bt:%u:%p:pc}}}`` This represents one frame in a backtrace. It usually appears on a line by itself (surrounded only by whitespace), in a sequence of such lines with diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/include/llvm/ADT/GenericCycleImpl.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/include/llvm/ADT/GenericCycleImpl.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/include/llvm/ADT/GenericCycleImpl.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/include/llvm/ADT/GenericCycleImpl.h 2023-01-24 23:06:04.000000000 +0000 @@ -144,8 +144,12 @@ }; template -auto GenericCycleInfo::getTopLevelParentCycle( - const BlockT *Block) const -> CycleT * { +auto GenericCycleInfo::getTopLevelParentCycle(BlockT *Block) + -> CycleT * { + auto Cycle = BlockMapTopLevel.find(Block); + if (Cycle != BlockMapTopLevel.end()) + return Cycle->second; + auto MapIt = BlockMap.find(Block); if (MapIt == BlockMap.end()) return nullptr; @@ -153,12 +157,15 @@ auto *C = MapIt->second; while (C->ParentCycle) C = C->ParentCycle; + BlockMapTopLevel.try_emplace(Block, C); return C; } template -void GenericCycleInfo::moveToNewParent(CycleT *NewParent, - CycleT *Child) { +void GenericCycleInfo::moveTopLevelCycleToNewParent(CycleT *NewParent, + CycleT *Child) { + assert((!Child->ParentCycle && !NewParent->ParentCycle) && + "NewParent and Child must be both top level cycle!\n"); auto &CurrentContainer = Child->ParentCycle ? Child->ParentCycle->Children : TopLevelCycles; auto Pos = llvm::find_if(CurrentContainer, [=](const auto &Ptr) -> bool { @@ -169,6 +176,13 @@ *Pos = std::move(CurrentContainer.back()); CurrentContainer.pop_back(); Child->ParentCycle = NewParent; + + NewParent->Blocks.insert(NewParent->Blocks.end(), Child->block_begin(), + Child->block_end()); + + for (auto &It : BlockMapTopLevel) + if (It.second == Child) + It.second = NewParent; } /// \brief Main function of the cycle info computations. @@ -240,10 +254,7 @@ << "discovered child cycle " << Info.Context.print(BlockParent->getHeader()) << "\n"); // Make BlockParent the child of NewCycle. - Info.moveToNewParent(NewCycle.get(), BlockParent); - NewCycle->Blocks.insert(NewCycle->Blocks.end(), - BlockParent->block_begin(), - BlockParent->block_end()); + Info.moveTopLevelCycleToNewParent(NewCycle.get(), BlockParent); for (auto *ChildEntry : BlockParent->entries()) ProcessPredecessors(ChildEntry); @@ -257,6 +268,7 @@ assert(!is_contained(NewCycle->Blocks, Block)); NewCycle->Blocks.push_back(Block); ProcessPredecessors(Block); + Info.BlockMapTopLevel.try_emplace(Block, NewCycle.get()); } } while (!Worklist.empty()); @@ -336,6 +348,7 @@ template void GenericCycleInfo::clear() { TopLevelCycles.clear(); BlockMap.clear(); + BlockMapTopLevel.clear(); } /// \brief Compute the cycle info for a function. diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/include/llvm/ADT/GenericCycleInfo.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/include/llvm/ADT/GenericCycleInfo.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/include/llvm/ADT/GenericCycleInfo.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/include/llvm/ADT/GenericCycleInfo.h 2023-01-24 23:06:04.000000000 +0000 @@ -232,15 +232,24 @@ private: ContextT Context; - /// Map basic blocks to their inner-most containing loop. + /// Map basic blocks to their inner-most containing cycle. DenseMap BlockMap; + /// Map basic blocks to their top level containing cycle. + DenseMap BlockMapTopLevel; + /// Outermost cycles discovered by any DFS. /// /// Note: The implementation treats the nullptr as the parent of /// every top-level cycle. See \ref contains for an example. std::vector> TopLevelCycles; + /// Move \p Child to \p NewParent by manipulating Children vectors. + /// + /// Note: This is an incomplete operation that does not update the depth of + /// the subtree. + void moveTopLevelCycleToNewParent(CycleT *NewParent, CycleT *Child); + public: GenericCycleInfo() = default; GenericCycleInfo(GenericCycleInfo &&) = default; @@ -254,13 +263,7 @@ CycleT *getCycle(const BlockT *Block) const; unsigned getCycleDepth(const BlockT *Block) const; - CycleT *getTopLevelParentCycle(const BlockT *Block) const; - - /// Move \p Child to \p NewParent by manipulating Children vectors. - /// - /// Note: This is an incomplete operation that does not update the - /// list of blocks in the new parent or the depth of the subtree. - void moveToNewParent(CycleT *NewParent, CycleT *Child); + CycleT *getTopLevelParentCycle(BlockT *Block); /// Methods for debug and self-test. //@{ diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h 2023-01-24 23:06:04.000000000 +0000 @@ -26,11 +26,14 @@ namespace llvm { namespace symbolize { +class LLVMSymbolizer; + /// Filter to convert parsed log symbolizer markup elements into human-readable /// text. class MarkupFilter { public: - MarkupFilter(raw_ostream &OS, Optional ColorsEnabled = llvm::None); + MarkupFilter(raw_ostream &OS, LLVMSymbolizer &Symbolizer, + Optional ColorsEnabled = llvm::None); /// Filters a line containing symbolizer markup and writes the human-readable /// results to the output stream. @@ -57,6 +60,7 @@ uint64_t ModuleRelativeAddr; bool contains(uint64_t Addr) const; + uint64_t getModuleRelativeAddr(uint64_t Addr) const; }; // An informational module line currently being constructed. As many mmap @@ -67,6 +71,15 @@ SmallVector MMaps = {}; }; + // The semantics of a possible program counter value. + enum class PCType { + // The address is a return address and must be adjusted to point to the call + // itself. + ReturnAddress, + // The address is the precise location in the code and needs no adjustment. + PreciseCode, + }; + bool tryContextualElement(const MarkupNode &Node, const SmallVector &DeferredNodes); bool tryMMap(const MarkupNode &Element, @@ -83,6 +96,9 @@ bool tryPresentation(const MarkupNode &Node); bool trySymbol(const MarkupNode &Node); + bool tryPC(const MarkupNode &Node); + bool tryBackTrace(const MarkupNode &Node); + bool tryData(const MarkupNode &Node); bool trySGR(const MarkupNode &Node); @@ -91,6 +107,9 @@ void restoreColor(); void resetColor(); + void printRawElement(const MarkupNode &Element); + void printValue(Twine Value); + Optional parseModule(const MarkupNode &Element) const; Optional parseMMap(const MarkupNode &Element) const; @@ -99,19 +118,26 @@ Optional parseSize(StringRef Str) const; Optional> parseBuildID(StringRef Str) const; Optional parseMode(StringRef Str) const; + Optional parsePCType(StringRef Str) const; + Optional parseFrameNumber(StringRef Str) const; bool checkTag(const MarkupNode &Node) const; bool checkNumFields(const MarkupNode &Element, size_t Size) const; bool checkNumFieldsAtLeast(const MarkupNode &Element, size_t Size) const; + bool checkNumFieldsAtMost(const MarkupNode &Element, size_t Size) const; void reportTypeError(StringRef Str, StringRef TypeName) const; void reportLocation(StringRef::iterator Loc) const; - const MMap *overlappingMMap(const MMap &Map) const; + const MMap *getOverlappingMMap(const MMap &Map) const; + const MMap *getContainingMMap(uint64_t Addr) const; + + uint64_t adjustAddr(uint64_t Addr, PCType Type) const; StringRef lineEnding() const; raw_ostream &OS; + LLVMSymbolizer &Symbolizer; const bool ColorsEnabled; MarkupParser Parser; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/include/llvm/Object/ELF.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/include/llvm/Object/ELF.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/include/llvm/Object/ELF.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/include/llvm/Object/ELF.h 2023-01-24 23:06:04.000000000 +0000 @@ -1028,7 +1028,7 @@ VN.Offset = VerneedBuf - Start; if (Verneed->vn_file < StrTab.size()) - VN.File = std::string(StrTab.drop_front(Verneed->vn_file)); + VN.File = std::string(StrTab.data() + Verneed->vn_file); else VN.File = ("vn_file) + ">").str(); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -5917,8 +5917,13 @@ if (const SCEV *S = createNodeFromSelectLikePHI(PN)) return S; + // If the PHI has a single incoming value, follow that value, unless the + // PHI's incoming blocks are in a different loop, in which case doing so + // risks breaking LCSSA form. Instcombine would normally zap these, but + // it doesn't have DominatorTree information, so it may miss cases. if (Value *V = simplifyInstruction(PN, {getDataLayout(), &TLI, &DT, &AC})) - return getSCEV(V); + if (LI.replacementPreservesLCSSAForm(PN, V)) + return getSCEV(V); // If it's not a loop phi, we can't handle it yet. return getUnknown(PN); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Analysis/ValueTracking.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Analysis/ValueTracking.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Analysis/ValueTracking.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Analysis/ValueTracking.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -3593,13 +3593,22 @@ // Unsigned integers are always nonnegative. case Instruction::UIToFP: return true; - case Instruction::FMul: case Instruction::FDiv: - // X * X is always non-negative or a NaN. // X / X is always exactly 1.0 or a NaN. if (I->getOperand(0) == I->getOperand(1) && (!SignBitOnly || cast(I)->hasNoNaNs())) return true; + + // Set SignBitOnly for RHS, because X / -0.0 is -Inf (or NaN). + return cannotBeOrderedLessThanZeroImpl(I->getOperand(0), TLI, SignBitOnly, + Depth + 1) && + cannotBeOrderedLessThanZeroImpl(I->getOperand(1), TLI, + /*SignBitOnly*/ true, Depth + 1); + case Instruction::FMul: + // X * X is always non-negative or a NaN. + if (I->getOperand(0) == I->getOperand(1) && + (!SignBitOnly || cast(I)->hasNoNaNs())) + return true; LLVM_FALLTHROUGH; case Instruction::FAdd: diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Analysis/VectorUtils.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Analysis/VectorUtils.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Analysis/VectorUtils.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Analysis/VectorUtils.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -1110,6 +1110,12 @@ continue; Type *ElementTy = getLoadStoreType(&I); + // Currently, codegen doesn't support cases where the type size doesn't + // match the alloc size. Skip them for now. + uint64_t Size = DL.getTypeAllocSize(ElementTy); + if (Size * 8 != DL.getTypeSizeInBits(ElementTy)) + continue; + // We don't check wrapping here because we don't know yet if Ptr will be // part of a full group or a group with gaps. Checking wrapping for all // pointers (even those that end up in groups with no gaps) will be overly @@ -1121,7 +1127,6 @@ /*Assume=*/true, /*ShouldCheckWrap=*/false); const SCEV *Scev = replaceSymbolicStrideSCEV(PSE, Strides, Ptr); - uint64_t Size = DL.getTypeAllocSize(ElementTy); AccessStrideInfo[&I] = StrideDescriptor(Stride, Scev, Size, getLoadStoreAlignment(&I)); } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/CodeGen/PrologEpilogInserter.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/CodeGen/PrologEpilogInserter.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/CodeGen/PrologEpilogInserter.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/CodeGen/PrologEpilogInserter.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -1237,7 +1237,13 @@ if (!MO.isReg()) continue; - for (MCPhysReg SReg : TRI.sub_and_superregs_inclusive(MO.getReg())) + MCRegister Reg = MO.getReg(); + + // This picks up sibling registers (e.q. %al -> %ah). + for (MCRegUnitIterator Unit(Reg, &TRI); Unit.isValid(); ++Unit) + RegsToZero.reset(*Unit); + + for (MCPhysReg SReg : TRI.sub_and_superregs_inclusive(Reg)) RegsToZero.reset(SReg); } } @@ -1262,9 +1268,10 @@ } } - // Don't clear registers that are reset before exiting. - for (const CalleeSavedInfo &CSI : MF.getFrameInfo().getCalleeSavedInfo()) - for (MCRegister Reg : TRI.sub_and_superregs_inclusive(CSI.getReg())) + // Don't clear registers that must be preserved. + for (const MCPhysReg *CSRegs = TRI.getCalleeSavedRegs(&MF); + MCPhysReg CSReg = *CSRegs; ++CSRegs) + for (MCRegister Reg : TRI.sub_and_superregs_inclusive(CSReg)) RegsToZero.reset(Reg); const TargetFrameLowering &TFI = *MF.getSubtarget().getFrameLowering(); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/CodeGen/RegAllocFast.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/CodeGen/RegAllocFast.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/CodeGen/RegAllocFast.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/CodeGen/RegAllocFast.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -443,6 +443,9 @@ SpilledOperandsMap[MO->getParent()].push_back(MO); for (auto MISpilledOperands : SpilledOperandsMap) { MachineInstr &DBG = *MISpilledOperands.first; + // We don't have enough support for tracking operands of DBG_VALUE_LISTs. + if (DBG.isDebugValueList()) + continue; MachineInstr *NewDV = buildDbgValueForSpill( *MBB, Before, *MISpilledOperands.first, FI, MISpilledOperands.second); assert(NewDV->getParent() == MBB && "dangling parent pointer"); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -7163,9 +7163,8 @@ SDValue ExtractFrom, SDValue &Mask, const SDLoc &DL) { assert(OppShift && ExtractFrom && "Empty SDValue"); - assert( - (OppShift.getOpcode() == ISD::SHL || OppShift.getOpcode() == ISD::SRL) && - "Existing shift must be valid as a rotate half"); + if (OppShift.getOpcode() != ISD::SHL && OppShift.getOpcode() != ISD::SRL) + return SDValue(); ExtractFrom = stripConstantMask(DAG, ExtractFrom, Mask); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -9693,6 +9693,7 @@ Entry.Alignment = Alignment; CLI.getArgs().insert(CLI.getArgs().begin(), Entry); CLI.NumFixedArgs += 1; + CLI.getArgs()[0].IndirectType = CLI.RetTy; CLI.RetTy = Type::getVoidTy(CLI.RetTy->getContext()); // sret demotion isn't compatible with tail-calls, since the sret argument diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/CodeGen/TypePromotion.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/CodeGen/TypePromotion.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/CodeGen/TypePromotion.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/CodeGen/TypePromotion.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -569,7 +569,7 @@ void IRPromoter::Cleanup() { LLVM_DEBUG(dbgs() << "IR Promotion: Cleanup..\n"); // Some zexts will now have become redundant, along with their trunc - // operands, so remove them + // operands, so remove them. for (auto *V : Visited) { if (!isa(V)) continue; @@ -620,6 +620,8 @@ ConstantInt *Mask = ConstantInt::get(SrcTy, APInt::getMaxValue(NumBits).getZExtValue()); Value *Masked = Builder.CreateAnd(Trunc->getOperand(0), Mask); + if (SrcTy != ExtTy) + Masked = Builder.CreateTrunc(Masked, ExtTy); if (auto *I = dyn_cast(Masked)) NewInsts.insert(I); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -20,11 +20,14 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/Symbolize/Markup.h" +#include "llvm/DebugInfo/Symbolize/Symbolize.h" #include "llvm/Debuginfod/Debuginfod.h" #include "llvm/Demangle/Demangle.h" #include "llvm/Object/ObjectFile.h" #include "llvm/Support/Error.h" +#include "llvm/Support/Format.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/WithColor.h" #include "llvm/Support/raw_ostream.h" @@ -32,9 +35,11 @@ using namespace llvm; using namespace llvm::symbolize; -MarkupFilter::MarkupFilter(raw_ostream &OS, Optional ColorsEnabled) - : OS(OS), ColorsEnabled(ColorsEnabled.value_or( - WithColor::defaultAutoDetectFunction()(OS))) {} +MarkupFilter::MarkupFilter(raw_ostream &OS, LLVMSymbolizer &Symbolizer, + Optional ColorsEnabled) + : OS(OS), Symbolizer(Symbolizer), + ColorsEnabled( + ColorsEnabled.value_or(WithColor::defaultAutoDetectFunction()(OS))) {} void MarkupFilter::filter(StringRef Line) { this->Line = Line; @@ -94,10 +99,10 @@ if (!ParsedMMap) return true; - if (const MMap *M = overlappingMMap(*ParsedMMap)) { + if (const MMap *M = getOverlappingMMap(*ParsedMMap)) { WithColor::error(errs()) - << formatv("overlapping mmap: #{0:x} [{1:x},{2:x})\n", M->Mod->ID, - M->Addr, M->Addr + M->Size); + << formatv("overlapping mmap: #{0:x} [{1:x}-{2:x}]\n", M->Mod->ID, + M->Addr, M->Addr + M->Size - 1); reportLocation(Node.Fields[0].begin()); return true; } @@ -160,18 +165,17 @@ filterNode(Node); beginModuleInfoLine(&Module); OS << "; BuildID="; - highlightValue(); - OS << toHex(Module.BuildID, /*LowerCase=*/true); - highlight(); + printValue(toHex(Module.BuildID, /*LowerCase=*/true)); return true; } void MarkupFilter::beginModuleInfoLine(const Module *M) { highlight(); OS << "[[[ELF module"; - highlightValue(); - OS << formatv(" #{0:x} \"{1}\"", M->ID, M->Name); - highlight(); + printValue(formatv(" #{0:x} ", M->ID)); + OS << '"'; + printValue(M->Name); + OS << '"'; MIL = ModuleInfoLine{M}; } @@ -182,14 +186,13 @@ return A->Addr < B->Addr; }); for (const MMap *M : MIL->MMaps) { - OS << (M == MIL->MMaps.front() ? ' ' : '-'); - highlightValue(); - OS << formatv("{0:x}", M->Addr); - highlight(); - OS << '('; - highlightValue(); - OS << M->Mode; - highlight(); + OS << (M == MIL->MMaps.front() ? ' ' : ','); + OS << '['; + printValue(formatv("{0:x}", M->Addr)); + OS << '-'; + printValue(formatv("{0:x}", M->Addr + M->Size - 1)); + OS << "]("; + printValue(M->Mode); OS << ')'; } OS << "]]]" << lineEnding(); @@ -210,7 +213,13 @@ } bool MarkupFilter::tryPresentation(const MarkupNode &Node) { - return trySymbol(Node); + if (trySymbol(Node)) + return true; + if (tryPC(Node)) + return true; + if (tryBackTrace(Node)) + return true; + return tryData(Node); } bool MarkupFilter::trySymbol(const MarkupNode &Node) { @@ -225,6 +234,172 @@ return true; } +bool MarkupFilter::tryPC(const MarkupNode &Node) { + if (Node.Tag != "pc") + return false; + if (!checkNumFieldsAtLeast(Node, 1)) + return true; + if (!checkNumFieldsAtMost(Node, 2)) + return true; + + Optional Addr = parseAddr(Node.Fields[0]); + if (!Addr) + return true; + + // PC addresses that aren't part of a backtrace are assumed to be precise code + // locations. + PCType Type = PCType::PreciseCode; + if (Node.Fields.size() == 2) { + Optional ParsedType = parsePCType(Node.Fields[1]); + if (!ParsedType) + return true; + Type = *ParsedType; + } + *Addr = adjustAddr(*Addr, Type); + + const MMap *MMap = getContainingMMap(*Addr); + if (!MMap) { + WithColor::error() << "no mmap covers address\n"; + reportLocation(Node.Fields[0].begin()); + printRawElement(Node); + return true; + } + + Expected LI = Symbolizer.symbolizeCode( + MMap->Mod->BuildID, {MMap->getModuleRelativeAddr(*Addr)}); + if (!LI) { + WithColor::defaultErrorHandler(LI.takeError()); + printRawElement(Node); + return true; + } + if (!*LI) { + printRawElement(Node); + return true; + } + + highlight(); + printValue(LI->FunctionName); + OS << '['; + printValue(LI->FileName); + OS << ':'; + printValue(Twine(LI->Line)); + OS << ']'; + restoreColor(); + return true; +} + +bool MarkupFilter::tryBackTrace(const MarkupNode &Node) { + if (Node.Tag != "bt") + return false; + if (!checkNumFieldsAtLeast(Node, 2)) + return true; + if (!checkNumFieldsAtMost(Node, 3)) + return true; + + Optional FrameNumber = parseFrameNumber(Node.Fields[0]); + if (!FrameNumber) + return true; + + Optional Addr = parseAddr(Node.Fields[1]); + if (!Addr) + return true; + + // Backtrace addresses are assumed to be return addresses by default. + PCType Type = PCType::ReturnAddress; + if (Node.Fields.size() == 3) { + Optional ParsedType = parsePCType(Node.Fields[2]); + if (!ParsedType) + return true; + Type = *ParsedType; + } + *Addr = adjustAddr(*Addr, Type); + + const MMap *MMap = getContainingMMap(*Addr); + if (!MMap) { + WithColor::error() << "no mmap covers address\n"; + reportLocation(Node.Fields[0].begin()); + printRawElement(Node); + return true; + } + uint64_t MRA = MMap->getModuleRelativeAddr(*Addr); + + Expected II = + Symbolizer.symbolizeInlinedCode(MMap->Mod->BuildID, {MRA}); + if (!II) { + WithColor::defaultErrorHandler(II.takeError()); + printRawElement(Node); + return true; + } + + highlight(); + for (unsigned I = 0, E = II->getNumberOfFrames(); I != E; ++I) { + auto Header = formatv("{0, +6}", formatv("#{0}", FrameNumber)).sstr<16>(); + // Don't highlight the # sign as a value. + size_t NumberIdx = Header.find("#") + 1; + OS << Header.substr(0, NumberIdx); + printValue(Header.substr(NumberIdx)); + if (I == E - 1) { + OS << " "; + } else { + OS << '.'; + printValue(formatv("{0, -2}", I + 1)); + } + printValue(formatv(" {0:x16} ", *Addr)); + + DILineInfo LI = II->getFrame(I); + if (LI) { + printValue(LI.FunctionName); + OS << ' '; + printValue(LI.FileName); + OS << ':'; + printValue(Twine(LI.Line)); + OS << ':'; + printValue(Twine(LI.Column)); + OS << ' '; + } + OS << '('; + printValue(MMap->Mod->Name); + OS << "+"; + printValue(formatv("{0:x}", MRA)); + OS << ')'; + if (I != E - 1) + OS << lineEnding(); + } + restoreColor(); + return true; +} + +bool MarkupFilter::tryData(const MarkupNode &Node) { + if (Node.Tag != "data") + return false; + if (!checkNumFields(Node, 1)) + return true; + Optional Addr = parseAddr(Node.Fields[0]); + if (!Addr) + return true; + + const MMap *MMap = getContainingMMap(*Addr); + if (!MMap) { + WithColor::error() << "no mmap covers address\n"; + reportLocation(Node.Fields[0].begin()); + printRawElement(Node); + return true; + } + + Expected Symbol = Symbolizer.symbolizeData( + MMap->Mod->BuildID, {MMap->getModuleRelativeAddr(*Addr)}); + if (!Symbol) { + WithColor::defaultErrorHandler(Symbol.takeError()); + printRawElement(Node); + return true; + } + + highlight(); + OS << Symbol->Name; + restoreColor(); + return true; +} + bool MarkupFilter::trySGR(const MarkupNode &Node) { if (Node.Text == "\033[0m") { resetColor(); @@ -297,6 +472,24 @@ OS.resetColor(); } +void MarkupFilter::printRawElement(const MarkupNode &Element) { + highlight(); + OS << "[[["; + printValue(Element.Tag); + for (StringRef Field : Element.Fields) { + OS << ':'; + printValue(Field); + } + OS << "]]]"; + restoreColor(); +} + +void MarkupFilter::printValue(Twine Value) { + highlightValue(); + OS << Value; + highlight(); +} + // This macro helps reduce the amount of indirection done through Optional // below, since the usual case upon returning a None Optional is to return None. #define ASSIGN_OR_RETURN_NONE(TYPE, NAME, EXPR) \ @@ -392,6 +585,16 @@ return ID; } +// Parse a frame number (%i in the spec). +Optional MarkupFilter::parseFrameNumber(StringRef Str) const { + uint64_t ID; + if (Str.getAsInteger(10, ID)) { + reportTypeError(Str, "frame number"); + return None; + } + return ID; +} + // Parse a build ID (%x in the spec). Optional> MarkupFilter::parseBuildID(StringRef Str) const { std::string Bytes; @@ -430,6 +633,17 @@ return Str.lower(); } +Optional MarkupFilter::parsePCType(StringRef Str) const { + Optional Type = + StringSwitch>(Str) + .Case("ra", MarkupFilter::PCType::ReturnAddress) + .Case("pc", MarkupFilter::PCType::PreciseCode) + .Default(None); + if (!Type) + reportTypeError(Str, "PC type"); + return Type; +} + bool MarkupFilter::checkTag(const MarkupNode &Node) const { if (any_of(Node.Tag, [](char C) { return C < 'a' || C > 'z'; })) { WithColor::error(errs()) << "tags must be all lowercase characters\n"; @@ -442,7 +656,7 @@ bool MarkupFilter::checkNumFields(const MarkupNode &Element, size_t Size) const { if (Element.Fields.size() != Size) { - WithColor::error(errs()) << "expected " << Size << " fields; found " + WithColor::error(errs()) << "expected " << Size << " field(s); found " << Element.Fields.size() << "\n"; reportLocation(Element.Tag.end()); return false; @@ -454,7 +668,19 @@ size_t Size) const { if (Element.Fields.size() < Size) { WithColor::error(errs()) - << "expected at least " << Size << " fields; found " + << "expected at least " << Size << " field(s); found " + << Element.Fields.size() << "\n"; + reportLocation(Element.Tag.end()); + return false; + } + return true; +} + +bool MarkupFilter::checkNumFieldsAtMost(const MarkupNode &Element, + size_t Size) const { + if (Element.Fields.size() > Size) { + WithColor::error(errs()) + << "expected at most " << Size << " field(s); found " << Element.Fields.size() << "\n"; reportLocation(Element.Tag.end()); return false; @@ -479,7 +705,8 @@ // Checks for an existing mmap that overlaps the given one and returns a // pointer to one of them. -const MarkupFilter::MMap *MarkupFilter::overlappingMMap(const MMap &Map) const { +const MarkupFilter::MMap * +MarkupFilter::getOverlappingMMap(const MMap &Map) const { // If the given map contains the start of another mmap, they overlap. auto I = MMaps.upper_bound(Map.Addr); if (I != MMaps.end() && Map.contains(I->second.Addr)) @@ -495,6 +722,28 @@ return nullptr; } +// Returns the MMap that contains the given address or nullptr if none. +const MarkupFilter::MMap *MarkupFilter::getContainingMMap(uint64_t Addr) const { + // Find the first mmap starting >= Addr. + auto I = MMaps.lower_bound(Addr); + if (I != MMaps.end() && I->second.contains(Addr)) + return &I->second; + + // The previous mmap is the last one starting < Addr. + if (I == MMaps.begin()) + return nullptr; + --I; + return I->second.contains(Addr) ? &I->second : nullptr; +} + +uint64_t MarkupFilter::adjustAddr(uint64_t Addr, PCType Type) const { + // Decrementing return addresses by one moves them into the call instruction. + // The address doesn't have to be the start of the call instruction, just some + // byte on the inside. Subtracting one avoids needing detailed instruction + // length information here. + return Type == MarkupFilter::PCType::ReturnAddress ? Addr - 1 : Addr; +} + StringRef MarkupFilter::lineEnding() const { return Line.endswith("\r\n") ? "\r\n" : "\n"; } @@ -502,3 +751,8 @@ bool MarkupFilter::MMap::contains(uint64_t Addr) const { return this->Addr <= Addr && Addr < this->Addr + Size; } + +// Returns the module-relative address for a given virtual address. +uint64_t MarkupFilter::MMap::getModuleRelativeAddr(uint64_t Addr) const { + return Addr - this->Addr + ModuleRelativeAddr; +} diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/IR/AutoUpgrade.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/IR/AutoUpgrade.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/IR/AutoUpgrade.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/IR/AutoUpgrade.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -1040,7 +1040,7 @@ Name, F->getParent()); // The new function may also need remangling. - if (auto Result = llvm::Intrinsic::remangleIntrinsicFunction(F)) + if (auto Result = llvm::Intrinsic::remangleIntrinsicFunction(NewFn)) NewFn = *Result; return true; } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Support/CMakeLists.txt rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Support/CMakeLists.txt --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Support/CMakeLists.txt 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Support/CMakeLists.txt 2023-01-24 23:06:04.000000000 +0000 @@ -22,11 +22,19 @@ endif() if(LLVM_ENABLE_ZLIB) - set(imported_libs ZLIB::ZLIB) + list(APPEND imported_libs ZLIB::ZLIB) endif() if(LLVM_ENABLE_ZSTD) - list(APPEND imported_libs zstd::libzstd_shared) + if(TARGET zstd::libzstd_shared AND NOT LLVM_USE_STATIC_ZSTD) + set(zstd_target zstd::libzstd_shared) + else() + set(zstd_target zstd::libzstd_static) + endif() +endif() + +if(LLVM_ENABLE_ZSTD) + list(APPEND imported_libs ${zstd_target}) endif() if( MSVC OR MINGW ) @@ -51,9 +59,7 @@ if( LLVM_ENABLE_TERMINFO ) set(imported_libs ${imported_libs} Terminfo::terminfo) endif() - if( LLVM_ENABLE_THREADS AND (HAVE_LIBATOMIC OR HAVE_CXX_LIBATOMICS64) ) - set(system_libs ${system_libs} atomic) - endif() + set(system_libs ${system_libs} ${LLVM_ATOMIC_LIB}) set(system_libs ${system_libs} ${LLVM_PTHREAD_LIB}) if( UNIX AND NOT (BEOS OR HAIKU) ) set(system_libs ${system_libs} m) @@ -300,11 +306,12 @@ # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. if(CMAKE_BUILD_TYPE) string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) - get_property(zstd_library TARGET zstd::libzstd_shared PROPERTY LOCATION_${build_type}) + get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION_${build_type}) endif() if(NOT zstd_library) - get_property(zstd_library TARGET zstd::libzstd_shared PROPERTY LOCATION) + get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION) endif() + get_library_name(${zstd_library} zstd_library) set(llvm_system_libs ${llvm_system_libs} "${zstd_library}") endif() diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Support/Unix/Signals.inc rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Support/Unix/Signals.inc --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Support/Unix/Signals.inc 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Support/Unix/Signals.inc 2023-01-24 23:06:04.000000000 +0000 @@ -432,10 +432,6 @@ } void llvm::sys::DefaultOneShotPipeSignalHandler() { - // UNIX03 conformance requires a non-zero exit code and an error message - // to stderr when writing to a closed stdout fails. - errs() << "error: write on a pipe with no reader\n"; - // Send a special return code that drivers can check for, from sysexits.h. exit(EX_IOERR); } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Support/X86TargetParser.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Support/X86TargetParser.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Support/X86TargetParser.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Support/X86TargetParser.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -203,10 +203,10 @@ FeatureCLWB | FeatureMOVDIRI | FeatureSHSTK | FeatureKL | FeatureWIDEKL; constexpr FeatureBitset FeaturesSapphireRapids = FeaturesICLServer | FeatureAMX_BF16 | FeatureAMX_INT8 | FeatureAMX_TILE | - FeatureAVX512BF16 | FeatureAVX512FP16 | FeatureAVX512VP2INTERSECT | - FeatureAVXVNNI | FeatureCLDEMOTE | FeatureENQCMD | FeatureMOVDIR64B | - FeatureMOVDIRI | FeaturePTWRITE | FeatureSERIALIZE | FeatureSHSTK | - FeatureTSXLDTRK | FeatureUINTR | FeatureWAITPKG; + FeatureAVX512BF16 | FeatureAVX512FP16 | FeatureAVXVNNI | FeatureCLDEMOTE | + FeatureENQCMD | FeatureMOVDIR64B | FeatureMOVDIRI | FeaturePTWRITE | + FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR | + FeatureWAITPKG; // Intel Atom processors. // Bonnell has feature parity with Core2 and adds MOVBE. @@ -367,7 +367,7 @@ // Tigerlake microarchitecture based processors. { {"tigerlake"}, CK_Tigerlake, FEATURE_AVX512VP2INTERSECT, FeaturesTigerlake }, // Sapphire Rapids microarchitecture based processors. - { {"sapphirerapids"}, CK_SapphireRapids, FEATURE_AVX512VP2INTERSECT, FeaturesSapphireRapids }, + { {"sapphirerapids"}, CK_SapphireRapids, FEATURE_AVX512BF16, FeaturesSapphireRapids }, // Alderlake microarchitecture based processors. { {"alderlake"}, CK_Alderlake, FEATURE_AVX2, FeaturesAlderlake }, // Knights Landing processor. diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -5805,7 +5805,7 @@ assert(!Res && "Call operand has unhandled type"); (void)Res; } - SmallVector ArgValues; + unsigned ExtraArgLocs = 0; for (unsigned i = 0, e = Ins.size(); i != e; ++i) { CCValAssign &VA = ArgLocs[i - ExtraArgLocs]; @@ -6157,17 +6157,10 @@ /// appropriate copies out of appropriate physical registers. SDValue AArch64TargetLowering::LowerCallResult( SDValue Chain, SDValue InFlag, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &DL, + const SmallVectorImpl &RVLocs, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals, bool isThisReturn, SDValue ThisVal) const { - CCAssignFn *RetCC = CCAssignFnForReturn(CallConv); - // Assign locations to each value returned by this call. - SmallVector RVLocs; DenseMap CopiedRegs; - CCState CCInfo(CallConv, isVarArg, DAG.getMachineFunction(), RVLocs, - *DAG.getContext()); - CCInfo.AnalyzeCallResult(Ins, RetCC); - // Copy all of the result registers out of their specified physreg. for (unsigned i = 0; i != RVLocs.size(); ++i) { CCValAssign VA = RVLocs[i]; @@ -6508,17 +6501,39 @@ GuardWithBTI = FuncInfo->branchTargetEnforcement(); } + // Analyze operands of the call, assigning locations to each operand. + SmallVector ArgLocs; + CCState CCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.getContext()); + + if (IsVarArg) { + unsigned NumArgs = Outs.size(); + + for (unsigned i = 0; i != NumArgs; ++i) { + if (!Outs[i].IsFixed && Outs[i].VT.isScalableVector()) + report_fatal_error("Passing SVE types to variadic functions is " + "currently not supported"); + } + } + + analyzeCallOperands(*this, Subtarget, CLI, CCInfo); + + CCAssignFn *RetCC = CCAssignFnForReturn(CallConv); + // Assign locations to each value returned by this call. + SmallVector RVLocs; + CCState RetCCInfo(CallConv, IsVarArg, DAG.getMachineFunction(), RVLocs, + *DAG.getContext()); + RetCCInfo.AnalyzeCallResult(Ins, RetCC); + // Check callee args/returns for SVE registers and set calling convention // accordingly. if (CallConv == CallingConv::C || CallConv == CallingConv::Fast) { - bool CalleeOutSVE = any_of(Outs, [](ISD::OutputArg &Out){ - return Out.VT.isScalableVector(); - }); - bool CalleeInSVE = any_of(Ins, [](ISD::InputArg &In){ - return In.VT.isScalableVector(); - }); - - if (CalleeInSVE || CalleeOutSVE) + auto HasSVERegLoc = [](CCValAssign &Loc) { + if (!Loc.isRegLoc()) + return false; + return AArch64::ZPRRegClass.contains(Loc.getLocReg()) || + AArch64::PPRRegClass.contains(Loc.getLocReg()); + }; + if (any_of(RVLocs, HasSVERegLoc) || any_of(ArgLocs, HasSVERegLoc)) CallConv = CallingConv::AArch64_SVE_VectorCall; } @@ -6540,22 +6555,6 @@ report_fatal_error("failed to perform tail call elimination on a call " "site marked musttail"); - // Analyze operands of the call, assigning locations to each operand. - SmallVector ArgLocs; - CCState CCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.getContext()); - - if (IsVarArg) { - unsigned NumArgs = Outs.size(); - - for (unsigned i = 0; i != NumArgs; ++i) { - if (!Outs[i].IsFixed && Outs[i].VT.isScalableVector()) - report_fatal_error("Passing SVE types to variadic functions is " - "currently not supported"); - } - } - - analyzeCallOperands(*this, Subtarget, CLI, CCInfo); - // Get a count of how many bytes are to be pushed on the stack. unsigned NumBytes = CCInfo.getNextStackOffset(); @@ -6961,7 +6960,7 @@ // Handle result values, copying them out of physregs into vregs that we // return. - return LowerCallResult(Chain, InFlag, CallConv, IsVarArg, Ins, DL, DAG, + return LowerCallResult(Chain, InFlag, CallConv, IsVarArg, RVLocs, DL, DAG, InVals, IsThisReturn, IsThisReturn ? OutVals[0] : SDValue()); } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.h 2023-01-24 23:06:04.000000000 +0000 @@ -894,7 +894,7 @@ SDValue LowerCallResult(SDValue Chain, SDValue InFlag, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + const SmallVectorImpl &RVLocs, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals, bool isThisReturn, SDValue ThisVal) const; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -4600,9 +4600,16 @@ case Intrinsic::amdgcn_mbcnt_hi: { const GCNSubtarget &ST = DAG.getMachineFunction().getSubtarget(); - // These return at most the wavefront size - 1. + // These return at most the (wavefront size - 1) + src1 + // As long as src1 is an immediate we can calc known bits + KnownBits Src1Known = DAG.computeKnownBits(Op.getOperand(2), Depth + 1); + unsigned Src1ValBits = Src1Known.countMaxActiveBits(); + unsigned MaxActiveBits = std::max(Src1ValBits, ST.getWavefrontSizeLog2()); + // Cater for potential carry + MaxActiveBits += Src1ValBits ? 1 : 0; unsigned Size = Op.getValueType().getSizeInBits(); - Known.Zero.setHighBits(Size - ST.getWavefrontSizeLog2()); + if (MaxActiveBits < Size) + Known.Zero.setHighBits(Size - MaxActiveBits); break; } case Intrinsic::amdgcn_workitem_id_x: diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/AMDGPU/SIISelLowering.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/AMDGPU/SIISelLowering.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/AMDGPU/SIISelLowering.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/AMDGPU/SIISelLowering.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -249,6 +249,7 @@ case ISD::STORE: case ISD::BUILD_VECTOR: case ISD::BITCAST: + case ISD::UNDEF: case ISD::EXTRACT_VECTOR_ELT: case ISD::INSERT_VECTOR_ELT: case ISD::EXTRACT_SUBVECTOR: @@ -516,6 +517,7 @@ case ISD::STORE: case ISD::BUILD_VECTOR: case ISD::BITCAST: + case ISD::UNDEF: case ISD::EXTRACT_VECTOR_ELT: case ISD::INSERT_VECTOR_ELT: case ISD::INSERT_SUBVECTOR: diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -1036,7 +1036,7 @@ // split, we may need an expensive shuffle to get two in sync. This has the // effect of making larger than legal compares (v8i32 for example) // expensive. - if (LT.second.getVectorNumElements() > 2) { + if (LT.second.isVector() && LT.second.getVectorNumElements() > 2) { if (LT.first > 1) return LT.first * BaseCost + BaseT::getScalarizationOverhead(VecCondTy, true, false); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp 2023-01-24 23:06:04.000000000 +0000 @@ -149,6 +149,7 @@ Align H) : Inst(I), Addr(A), ValTy(T), HaveAlign(H), NeedAlign(HVC.getTypeAlignment(ValTy)) {} + AddrInfo &operator=(const AddrInfo &) = default; // XXX: add Size member? Instruction *Inst; @@ -185,6 +186,7 @@ Segment(Value *Val, int Begin, int Len) : Val(Val), Start(Begin), Size(Len) {} Segment(const Segment &Seg) = default; + Segment &operator=(const Segment &Seg) = default; Value *Val; // Value representable as a sequence of bytes. int Start; // First byte of the value that belongs to the segment. int Size; // Number of bytes in the segment. @@ -195,6 +197,7 @@ Block(Value *Val, int Off, int Len, int Pos) : Seg(Val, Off, Len), Pos(Pos) {} Block(const Block &Blk) = default; + Block &operator=(const Block &Blk) = default; Segment Seg; // Value segment. int Pos; // Position (offset) of the segment in the Block. }; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/Sparc/SparcCallingConv.td rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/Sparc/SparcCallingConv.td --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/Sparc/SparcCallingConv.td 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/Sparc/SparcCallingConv.td 2023-01-24 23:06:05.000000000 +0000 @@ -125,10 +125,14 @@ def RetCC_Sparc64 : CallingConv<[ // A single f32 return value always goes in %f0. The ABI doesn't specify what // happens to multiple f32 return values outside a struct. - CCIfType<[f32], CCCustom<"CC_Sparc64_Half">>, + CCIfType<[f32], CCCustom<"RetCC_Sparc64_Half">>, - // Otherwise, return values are passed exactly like arguments. - CCDelegateTo + // Otherwise, return values are passed exactly like arguments, except that + // returns that are too big to fit into the registers is passed as an sret + // instead. + CCIfInReg>>, + CCIfType<[i32], CCPromoteToType>, + CCCustom<"RetCC_Sparc64_Full"> ]>; // Callee-saved registers are handled by the register window mechanism. diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/Sparc/SparcISelLowering.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/Sparc/SparcISelLowering.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/Sparc/SparcISelLowering.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/Sparc/SparcISelLowering.cpp 2023-01-24 23:06:05.000000000 +0000 @@ -101,9 +101,9 @@ } // Allocate a full-sized argument for the 64-bit ABI. -static bool CC_Sparc64_Full(unsigned &ValNo, MVT &ValVT, - MVT &LocVT, CCValAssign::LocInfo &LocInfo, - ISD::ArgFlagsTy &ArgFlags, CCState &State) { +static bool Analyze_CC_Sparc64_Full(bool IsReturn, unsigned &ValNo, MVT &ValVT, + MVT &LocVT, CCValAssign::LocInfo &LocInfo, + ISD::ArgFlagsTy &ArgFlags, CCState &State) { assert((LocVT == MVT::f32 || LocVT == MVT::f128 || LocVT.getSizeInBits() == 64) && "Can't handle non-64 bits locations"); @@ -133,6 +133,11 @@ return true; } + // Bail out if this is a return CC and we run out of registers to place + // values into. + if (IsReturn) + return false; + // This argument goes on the stack in an 8-byte slot. // When passing floats, LocVT is smaller than 8 bytes. Adjust the offset to // the right-aligned float. The first 4 bytes of the stack slot are undefined. @@ -146,9 +151,9 @@ // Allocate a half-sized argument for the 64-bit ABI. // // This is used when passing { float, int } structs by value in registers. -static bool CC_Sparc64_Half(unsigned &ValNo, MVT &ValVT, - MVT &LocVT, CCValAssign::LocInfo &LocInfo, - ISD::ArgFlagsTy &ArgFlags, CCState &State) { +static bool Analyze_CC_Sparc64_Half(bool IsReturn, unsigned &ValNo, MVT &ValVT, + MVT &LocVT, CCValAssign::LocInfo &LocInfo, + ISD::ArgFlagsTy &ArgFlags, CCState &State) { assert(LocVT.getSizeInBits() == 32 && "Can't handle non-32 bits locations"); unsigned Offset = State.AllocateStack(4, Align(4)); @@ -174,10 +179,43 @@ return true; } + // Bail out if this is a return CC and we run out of registers to place + // values into. + if (IsReturn) + return false; + State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo)); return true; } +static bool CC_Sparc64_Full(unsigned &ValNo, MVT &ValVT, MVT &LocVT, + CCValAssign::LocInfo &LocInfo, + ISD::ArgFlagsTy &ArgFlags, CCState &State) { + return Analyze_CC_Sparc64_Full(false, ValNo, ValVT, LocVT, LocInfo, ArgFlags, + State); +} + +static bool CC_Sparc64_Half(unsigned &ValNo, MVT &ValVT, MVT &LocVT, + CCValAssign::LocInfo &LocInfo, + ISD::ArgFlagsTy &ArgFlags, CCState &State) { + return Analyze_CC_Sparc64_Half(false, ValNo, ValVT, LocVT, LocInfo, ArgFlags, + State); +} + +static bool RetCC_Sparc64_Full(unsigned &ValNo, MVT &ValVT, MVT &LocVT, + CCValAssign::LocInfo &LocInfo, + ISD::ArgFlagsTy &ArgFlags, CCState &State) { + return Analyze_CC_Sparc64_Full(true, ValNo, ValVT, LocVT, LocInfo, ArgFlags, + State); +} + +static bool RetCC_Sparc64_Half(unsigned &ValNo, MVT &ValVT, MVT &LocVT, + CCValAssign::LocInfo &LocInfo, + ISD::ArgFlagsTy &ArgFlags, CCState &State) { + return Analyze_CC_Sparc64_Half(true, ValNo, ValVT, LocVT, LocInfo, ArgFlags, + State); +} + #include "SparcGenCallingConv.inc" // The calling conventions in SparcCallingConv.td are described in terms of the @@ -191,6 +229,15 @@ return Reg; } +bool SparcTargetLowering::CanLowerReturn( + CallingConv::ID CallConv, MachineFunction &MF, bool isVarArg, + const SmallVectorImpl &Outs, LLVMContext &Context) const { + SmallVector RVLocs; + CCState CCInfo(CallConv, isVarArg, MF, RVLocs, Context); + return CCInfo.CheckReturn(Outs, Subtarget->is64Bit() ? RetCC_Sparc64 + : RetCC_Sparc32); +} + SDValue SparcTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, @@ -1031,6 +1078,7 @@ // Copy all of the result registers out of their specified physreg. for (unsigned i = 0; i != RVLocs.size(); ++i) { + assert(RVLocs[i].isRegLoc() && "Can only return in registers!"); if (RVLocs[i].getLocVT() == MVT::v2i32) { SDValue Vec = DAG.getNode(ISD::UNDEF, dl, MVT::v2i32); SDValue Lo = DAG.getCopyFromReg( @@ -1346,6 +1394,7 @@ // Copy all of the result registers out of their specified physreg. for (unsigned i = 0; i != RVLocs.size(); ++i) { CCValAssign &VA = RVLocs[i]; + assert(VA.isRegLoc() && "Can only return in registers!"); unsigned Reg = toCallerWindow(VA.getLocReg()); // When returning 'inreg {i32, i32 }', two consecutive i32 arguments can diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/Sparc/SparcISelLowering.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/Sparc/SparcISelLowering.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/Sparc/SparcISelLowering.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/Sparc/SparcISelLowering.h 2023-01-24 23:06:05.000000000 +0000 @@ -144,6 +144,11 @@ SDValue LowerCall_64(TargetLowering::CallLoweringInfo &CLI, SmallVectorImpl &InVals) const; + bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, + bool isVarArg, + const SmallVectorImpl &Outs, + LLVMContext &Context) const override; + SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl &Outs, const SmallVectorImpl &OutVals, diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp 2023-01-24 23:06:05.000000000 +0000 @@ -70,6 +70,7 @@ } } +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) if (MMI) { const Module *M = MMI->getModule(); for (auto F = M->begin(), E = M->end(); F != E; ++F) { @@ -92,4 +93,5 @@ } } } +#endif } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/X86/X86.td rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/X86/X86.td --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Target/X86/X86.td 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Target/X86/X86.td 2023-01-24 23:06:05.000000000 +0000 @@ -909,7 +909,6 @@ FeatureTSXLDTRK, FeatureENQCMD, FeatureSHSTK, - FeatureVP2INTERSECT, FeatureMOVDIRI, FeatureMOVDIR64B, FeatureUINTR]; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp 2023-01-24 23:06:05.000000000 +0000 @@ -3289,6 +3289,10 @@ if (CallerPAL.hasParamAttr(i, Attribute::SwiftError)) return false; + if (CallerPAL.hasParamAttr(i, Attribute::ByVal) != + Callee->getAttributes().hasParamAttr(i, Attribute::ByVal)) + return false; // Cannot transform to or from byval. + // If the parameter is passed as a byval argument, then we have to have a // sized type and the sized type has to have the same size as the old type. if (ParamTy != ActTy && CallerPAL.hasParamAttr(i, Attribute::ByVal)) { diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp 2023-01-24 23:06:05.000000000 +0000 @@ -406,7 +406,6 @@ return CHRFunctions.count(F.getName()); } - assert(PSI.hasProfileSummary() && "Empty PSI?"); return PSI.isFunctionEntryHot(&F); } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp 2023-01-24 23:06:05.000000000 +0000 @@ -2003,7 +2003,7 @@ // FIXME: We should also hoist alloca affected by this to the entry // block if possible. if (F.getAttributes().hasAttrSomewhere(Attribute::InAlloca) && - !F.hasAddressTaken() && !hasMustTailCallers(&F)) { + !F.hasAddressTaken() && !hasMustTailCallers(&F) && !F.isVarArg()) { RemoveAttribute(&F, Attribute::InAlloca); Changed = true; } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Scalar/SROA.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Scalar/SROA.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Scalar/SROA.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Scalar/SROA.cpp 2023-01-24 23:06:05.000000000 +0000 @@ -1210,8 +1210,7 @@ BasicBlock *BB = PN.getParent(); Align MaxAlign; uint64_t APWidth = DL.getIndexTypeSizeInBits(PN.getType()); - APInt MaxSize(APWidth, 0); - bool HaveLoad = false; + Type *LoadType = nullptr; for (User *U : PN.users()) { LoadInst *LI = dyn_cast(U); if (!LI || !LI->isSimple()) @@ -1223,21 +1222,27 @@ if (LI->getParent() != BB) return false; + if (LoadType) { + if (LoadType != LI->getType()) + return false; + } else { + LoadType = LI->getType(); + } + // Ensure that there are no instructions between the PHI and the load that // could store. for (BasicBlock::iterator BBI(PN); &*BBI != LI; ++BBI) if (BBI->mayWriteToMemory()) return false; - uint64_t Size = DL.getTypeStoreSize(LI->getType()).getFixedSize(); MaxAlign = std::max(MaxAlign, LI->getAlign()); - MaxSize = MaxSize.ult(Size) ? APInt(APWidth, Size) : MaxSize; - HaveLoad = true; } - if (!HaveLoad) + if (!LoadType) return false; + APInt LoadSize = APInt(APWidth, DL.getTypeStoreSize(LoadType).getFixedSize()); + // We can only transform this if it is safe to push the loads into the // predecessor blocks. The only thing to watch out for is that we can't put // a possibly trapping load in the predecessor if it is a critical edge. @@ -1259,7 +1264,7 @@ // If this pointer is always safe to load, or if we can prove that there // is already a load in the block, then we can move the load to the pred // block. - if (isSafeToLoadUnconditionally(InVal, MaxAlign, MaxSize, DL, TI)) + if (isSafeToLoadUnconditionally(InVal, MaxAlign, LoadSize, DL, TI)) continue; return false; diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Utils/LoopUtils.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Utils/LoopUtils.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Utils/LoopUtils.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Utils/LoopUtils.cpp 2023-01-24 23:06:05.000000000 +0000 @@ -1394,7 +1394,10 @@ // and next SCEV may errneously get smaller cost. // Collect all the candidate PHINodes to be rewritten. - RewritePhiSet.emplace_back(PN, i, ExitValue, Inst, HighCost); + Instruction *InsertPt = + (isa(Inst) || isa(Inst)) ? + &*Inst->getParent()->getFirstInsertionPt() : Inst; + RewritePhiSet.emplace_back(PN, i, ExitValue, InsertPt, HighCost); } } } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Utils/LoopVersioning.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Utils/LoopVersioning.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Utils/LoopVersioning.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Utils/LoopVersioning.cpp 2023-01-24 23:06:05.000000000 +0000 @@ -137,8 +137,10 @@ // See if we have a single-operand PHI with the value defined by the // original loop. for (auto I = PHIBlock->begin(); (PN = dyn_cast(I)); ++I) { - if (PN->getIncomingValue(0) == Inst) + if (PN->getIncomingValue(0) == Inst) { + SE->forgetValue(PN); break; + } } // If not create it. if (!PN) { diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Utils/VNCoercion.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Utils/VNCoercion.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Utils/VNCoercion.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Utils/VNCoercion.cpp 2023-01-24 23:06:05.000000000 +0000 @@ -356,9 +356,9 @@ // If this is memset, we just need to see if the offset is valid in the size // of the memset.. - if (MI->getIntrinsicID() == Intrinsic::memset) { + if (const auto *memset_inst = dyn_cast(MI)) { if (DL.isNonIntegralPointerType(LoadTy->getScalarType())) { - auto *CI = dyn_cast(cast(MI)->getValue()); + auto *CI = dyn_cast(memset_inst->getValue()); if (!CI || !CI->isZero()) return -1; } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 2023-01-24 23:06:05.000000000 +0000 @@ -8149,9 +8149,15 @@ *PSE.getSE(), *OrigLoop, Range); // Check if this is pointer induction. If so, build the recipe for it. - if (auto *II = Legal->getPointerInductionDescriptor(Phi)) - return new VPWidenPointerInductionRecipe(Phi, Operands[0], *II, - *PSE.getSE()); + if (auto *II = Legal->getPointerInductionDescriptor(Phi)) { + return new VPWidenPointerInductionRecipe( + Phi, Operands[0], *II, *PSE.getSE(), + LoopVectorizationPlanner::getDecisionAndClampRange( + [&](ElementCount VF) { + return CM.isScalarAfterVectorization(Phi, VF); + }, + Range)); + } return nullptr; } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Vectorize/VPlan.h rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Vectorize/VPlan.h --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Vectorize/VPlan.h 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Vectorize/VPlan.h 2023-01-24 23:06:05.000000000 +0000 @@ -1187,15 +1187,19 @@ /// explicitly. ScalarEvolution &SE; + bool IsScalarAfterVectorization; + public: /// Create a new VPWidenPointerInductionRecipe for \p Phi with start value \p /// Start. VPWidenPointerInductionRecipe(PHINode *Phi, VPValue *Start, const InductionDescriptor &IndDesc, - ScalarEvolution &SE) + ScalarEvolution &SE, + bool IsScalarAfterVectorization) : VPHeaderPHIRecipe(VPVWidenPointerInductionSC, VPWidenPointerInductionSC, Phi), - IndDesc(IndDesc), SE(SE) { + IndDesc(IndDesc), SE(SE), + IsScalarAfterVectorization(IsScalarAfterVectorization) { addOperand(Start); } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp 2023-01-24 23:06:05.000000000 +0000 @@ -983,10 +983,8 @@ #endif bool VPWidenPointerInductionRecipe::onlyScalarsGenerated(ElementCount VF) { - bool IsUniform = vputils::onlyFirstLaneUsed(this); - return all_of(users(), - [&](const VPUser *U) { return U->usesScalars(this); }) && - (IsUniform || !VF.isScalable()); + return IsScalarAfterVectorization && + (!VF.isScalable() || vputils::onlyFirstLaneUsed(this)); } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/tools/dsymutil/CMakeLists.txt rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/tools/dsymutil/CMakeLists.txt --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/tools/dsymutil/CMakeLists.txt 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/tools/dsymutil/CMakeLists.txt 2023-01-24 23:06:05.000000000 +0000 @@ -40,6 +40,4 @@ target_link_libraries(dsymutil PRIVATE "-framework CoreFoundation") endif(APPLE) -if(HAVE_CXX_ATOMICS_WITH_LIB OR HAVE_CXX_ATOMICS64_WITH_LIB) - target_link_libraries(dsymutil PRIVATE atomic) -endif() +target_link_libraries(dsymutil PRIVATE ${LLVM_ATOMIC_LIB}) diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/tools/llvm-config/CMakeLists.txt rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/tools/llvm-config/CMakeLists.txt --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/tools/llvm-config/CMakeLists.txt 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/tools/llvm-config/CMakeLists.txt 2023-01-24 23:06:05.000000000 +0000 @@ -17,9 +17,14 @@ # Compute the substitution values for various items. get_property(SUPPORT_SYSTEM_LIBS TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS) get_property(WINDOWSMANIFEST_SYSTEM_LIBS TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS) + foreach(l ${SUPPORT_SYSTEM_LIBS} ${WINDOWSMANIFEST_SYSTEM_LIBS}) if(MSVC) - set(SYSTEM_LIBS ${SYSTEM_LIBS} "${l}.lib") + if(IS_ABSOLUTE ${l}) + set(SYSTEM_LIBS ${SYSTEM_LIBS} "${l}") + else() + set(SYSTEM_LIBS ${SYSTEM_LIBS} "${l}.lib") + endif() else() if (l MATCHES "^-") # If it's an option, pass it without changes. @@ -34,6 +39,7 @@ endif() endif() endforeach() + string(REPLACE ";" " " SYSTEM_LIBS "${SYSTEM_LIBS}") # Fetch target specific compile options, e.g. RTTI option diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/tools/llvm-objdump/ELFDump.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/tools/llvm-objdump/ELFDump.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/tools/llvm-objdump/ELFDump.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/tools/llvm-objdump/ELFDump.cpp 2023-01-24 23:06:05.000000000 +0000 @@ -282,27 +282,28 @@ } template -static void printSymbolVersionDependency(ArrayRef Contents, - StringRef StrTab) { +static void printSymbolVersionDependency(StringRef FileName, + const ELFFile &Obj, + const typename ELFT::Shdr &Sec) { outs() << "\nVersion References:\n"; - const uint8_t *Buf = Contents.data(); - while (Buf) { - auto *Verneed = reinterpret_cast(Buf); - outs() << " required from " - << StringRef(StrTab.drop_front(Verneed->vn_file).data()) << ":\n"; + auto WarningHandler = [&](const Twine &Msg) { + reportWarning(Msg, FileName); + return Error::success(); + }; + Expected> V = + Obj.getVersionDependencies(Sec, WarningHandler); + if (!V) { + reportWarning(toString(V.takeError()), FileName); + return; + } - const uint8_t *BufAux = Buf + Verneed->vn_aux; - while (BufAux) { - auto *Vernaux = reinterpret_cast(BufAux); - outs() << " " - << format("0x%08" PRIx32 " ", (uint32_t)Vernaux->vna_hash) - << format("0x%02" PRIx16 " ", (uint16_t)Vernaux->vna_flags) - << format("%02" PRIu16 " ", (uint16_t)Vernaux->vna_other) - << StringRef(StrTab.drop_front(Vernaux->vna_name).data()) << '\n'; - BufAux = Vernaux->vna_next ? BufAux + Vernaux->vna_next : nullptr; - } - Buf = Verneed->vn_next ? Buf + Verneed->vn_next : nullptr; + raw_fd_ostream &OS = outs(); + for (const VerNeed &VN : *V) { + OS << " required from " << VN.File << ":\n"; + for (const VernAux &Aux : VN.AuxV) + OS << format(" 0x%08x 0x%02x %02u %s\n", Aux.Hash, Aux.Flags, + Aux.Other, Aux.Name.c_str()); } } @@ -355,7 +356,7 @@ StringRef StrTab = unwrapOrError(Elf.getStringTable(*StrTabSec), FileName); if (Shdr.sh_type == ELF::SHT_GNU_verneed) - printSymbolVersionDependency(Contents, StrTab); + printSymbolVersionDependency(FileName, Elf, Shdr); else printSymbolVersionDefinition(Shdr, Contents, StrTab); } diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp 2023-01-24 23:06:05.000000000 +0000 @@ -366,8 +366,8 @@ } // Symbolize markup from stdin and write the result to stdout. -static void filterMarkup(const opt::InputArgList &Args) { - MarkupFilter Filter(outs(), parseColorArg(Args)); +static void filterMarkup(const opt::InputArgList &Args, LLVMSymbolizer &Symbolizer) { + MarkupFilter Filter(outs(), Symbolizer, parseColorArg(Args)); std::string InputString; while (std::getline(std::cin, InputString)) { InputString += '\n'; @@ -437,8 +437,19 @@ } } + LLVMSymbolizer Symbolizer(Opts); + + // A debuginfod lookup could succeed if a HTTP client is available and at + // least one backing URL is configured. + bool ShouldUseDebuginfodByDefault = + HTTPClient::isAvailable() && + !ExitOnErr(getDefaultDebuginfodUrls()).empty(); + if (Args.hasFlag(OPT_debuginfod, OPT_no_debuginfod, + ShouldUseDebuginfodByDefault)) + enableDebuginfod(Symbolizer); + if (Args.hasArg(OPT_filter_markup)) { - filterMarkup(Args); + filterMarkup(Args, Symbolizer); return 0; } @@ -458,17 +469,6 @@ } SmallVector BuildID = parseBuildIDArg(Args, OPT_build_id_EQ); - LLVMSymbolizer Symbolizer(Opts); - - // A debuginfod lookup could succeed if a HTTP client is available and at - // least one backing URL is configured. - bool ShouldUseDebuginfodByDefault = - HTTPClient::isAvailable() && - !ExitOnErr(getDefaultDebuginfodUrls()).empty(); - if (Args.hasFlag(OPT_debuginfod, OPT_no_debuginfod, - ShouldUseDebuginfodByDefault)) - enableDebuginfod(Symbolizer); - std::unique_ptr Printer; if (Style == OutputStyle::GNU) Printer = std::make_unique(outs(), errs(), Config); diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/misc/BUILD.gn rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/misc/BUILD.gn --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/misc/BUILD.gn 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/misc/BUILD.gn 2023-01-24 23:06:05.000000000 +0000 @@ -1,7 +1,7 @@ import("//llvm/utils/gn/build/compiled_action.gni") compiled_action("Confusables.inc") { - tool = "ConfusableTable:make-confusable-table" + tool = "ConfusableTable:clang-tidy-confusable-chars-gen" inputs = [ "ConfusableTable/confusables.txt" ] outputs = [ "$target_gen_dir/$target_name" ] args = [ diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/utils/gn/secondary/llvm/version.gni rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/utils/gn/secondary/llvm/version.gni --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/utils/gn/secondary/llvm/version.gni 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/utils/gn/secondary/llvm/version.gni 2023-01-24 23:06:05.000000000 +0000 @@ -1,4 +1,4 @@ llvm_version_major = 15 llvm_version_minor = 0 -llvm_version_patch = 0 +llvm_version_patch = 7 llvm_version = "$llvm_version_major.$llvm_version_minor.$llvm_version_patch" diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/utils/lit/lit/__init__.py rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/utils/lit/lit/__init__.py --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/utils/lit/lit/__init__.py 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/utils/lit/lit/__init__.py 2023-01-24 23:06:05.000000000 +0000 @@ -2,7 +2,7 @@ __author__ = 'Daniel Dunbar' __email__ = 'daniel@minormatter.com' -__versioninfo__ = (15, 0, 0) +__versioninfo__ = (15, 0, 7) __version__ = '.'.join(str(v) for v in __versioninfo__) + 'dev' __all__ = [] diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/utils/lit/lit/llvm/config.py rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/utils/lit/lit/llvm/config.py --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/utils/lit/lit/llvm/config.py 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/utils/lit/lit/llvm/config.py 2023-01-24 23:06:05.000000000 +0000 @@ -609,7 +609,7 @@ self.with_environment('PATH', paths, append_path=True) lib_dir_props = [self.config.name.lower() + '_libs_dir', - 'lld_libs_dir', 'llvm_libs_dir'] + 'lld_libs_dir', 'llvm_shlib_dir', 'llvm_libs_dir'] lib_paths = [getattr(self.config, pp) for pp in lib_dir_props if getattr(self.config, pp, None)] diff -Nru rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/utils/release/build-docs.sh rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/utils/release/build-docs.sh --- rustc-1.65.0+dfsg0ubuntu1~llvm/src/llvm-project/llvm/utils/release/build-docs.sh 2022-09-02 08:17:54.000000000 +0000 +++ rustc-1.65.0+dfsg0ubuntu1~llvm2/src/llvm-project/llvm/utils/release/build-docs.sh 2023-01-24 23:06:05.000000000 +0000 @@ -113,7 +113,7 @@ doxygen-polly cmake -G Ninja $srcdir/../runtimes -B $builddir/runtimes-doc \ - -DLLVM_ENABLE_RUNTIMES="libcxx" \ + -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ -DLLVM_ENABLE_SPHINX=ON \ -DSPHINX_WARNINGS_AS_ERRORS=OFF