Skip to content

[LifetimeSafety] Fix use-after-scope from #198784#199455

Merged
thurstond merged 1 commit into
llvm:mainfrom
thurstond:lifetime_safety_safety
May 24, 2026
Merged

[LifetimeSafety] Fix use-after-scope from #198784#199455
thurstond merged 1 commit into
llvm:mainfrom
thurstond:lifetime_safety_safety

Conversation

@thurstond
Copy link
Copy Markdown
Contributor

@thurstond thurstond commented May 24, 2026

This fixes a use-after-scope introduced by #198784 (reported in #198784 (comment)), by manually extending the lifetime.

AFAIK clang is built using C++17 [*], hence C++23 P2718R0's lifetime extension in range-based for loops does not apply.

[*] "Unless otherwise documented, LLVM subprojects are written using standard C++17 code" (https://llvm.org/docs/CodingStandards.html#c-standard-versions)

This fixes a use-after-scope introduced by llvm#198784 (reported in
llvm#198784 (comment)), by manually
extending the lifetime.

Note that clang is built using C++17, hence C++23 P2718R0's lifetime extension in
range-based for loops does not apply.
@thurstond thurstond requested review from Xazax-hun and usx95 May 24, 2026 22:28
@llvmorg-github-actions llvmorg-github-actions Bot added clang Clang issues not falling into any other category clang:analysis clang:temporal-safety Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr) labels May 24, 2026
@thurstond
Copy link
Copy Markdown
Contributor Author

cc @NeKon69

@llvmorg-github-actions
Copy link
Copy Markdown

llvmorg-github-actions Bot commented May 24, 2026

@llvm/pr-subscribers-clang-temporal-safety

@llvm/pr-subscribers-clang

Author: Thurston Dang (thurstond)

Changes

This fixes a use-after-scope introduced by #198784 (reported in #198784 (comment)), by manually extending the lifetime.

Note that clang is built using C++17, hence C++23 P2718R0's lifetime extension in range-based for loops does not apply.


Full diff: https://github.com/llvm/llvm-project/pull/199455.diff

1 Files Affected:

  • (modified) clang/lib/Analysis/LifetimeSafety/Checker.cpp (+5-2)
diff --git a/clang/lib/Analysis/LifetimeSafety/Checker.cpp b/clang/lib/Analysis/LifetimeSafety/Checker.cpp
index 53899251b9643..7eb948373152b 100644
--- a/clang/lib/Analysis/LifetimeSafety/Checker.cpp
+++ b/clang/lib/Analysis/LifetimeSafety/Checker.cpp
@@ -356,8 +356,11 @@ class LifetimeChecker {
 
     // We iterate in reverse order (from most recent to oldest) to find
     // the first declaration in each file.
-    for (const FunctionDecl *Redecl :
-         llvm::reverse(llvm::to_vector(FDef->redecls())))
+
+    // Store in temporary variable to manually extend lifetime
+    auto redecls = llvm::to_vector(FDef->redecls());
+
+    for (const FunctionDecl *Redecl : llvm::reverse(redecls))
       AddCrossTUDecl(Redecl);
 
     return Targets;

@llvmorg-github-actions
Copy link
Copy Markdown

@llvm/pr-subscribers-clang-analysis

Author: Thurston Dang (thurstond)

Changes

This fixes a use-after-scope introduced by #198784 (reported in #198784 (comment)), by manually extending the lifetime.

Note that clang is built using C++17, hence C++23 P2718R0's lifetime extension in range-based for loops does not apply.


Full diff: https://github.com/llvm/llvm-project/pull/199455.diff

1 Files Affected:

  • (modified) clang/lib/Analysis/LifetimeSafety/Checker.cpp (+5-2)
diff --git a/clang/lib/Analysis/LifetimeSafety/Checker.cpp b/clang/lib/Analysis/LifetimeSafety/Checker.cpp
index 53899251b9643..7eb948373152b 100644
--- a/clang/lib/Analysis/LifetimeSafety/Checker.cpp
+++ b/clang/lib/Analysis/LifetimeSafety/Checker.cpp
@@ -356,8 +356,11 @@ class LifetimeChecker {
 
     // We iterate in reverse order (from most recent to oldest) to find
     // the first declaration in each file.
-    for (const FunctionDecl *Redecl :
-         llvm::reverse(llvm::to_vector(FDef->redecls())))
+
+    // Store in temporary variable to manually extend lifetime
+    auto redecls = llvm::to_vector(FDef->redecls());
+
+    for (const FunctionDecl *Redecl : llvm::reverse(redecls))
       AddCrossTUDecl(Redecl);
 
     return Targets;

@thurstond thurstond merged commit 38a8cd7 into llvm:main May 24, 2026
14 checks passed
@llvm-ci
Copy link
Copy Markdown

llvm-ci commented May 24, 2026

LLVM Buildbot has detected a new failure on builder clang-aarch64-sve-vls running on linaro-g3-01 while building clang at step 7 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/143/builds/15407

Here is the relevant piece of the build log for the reference
Step 7 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'MLIR :: Integration/Dialect/Linalg/CPU/ArmSVE/pack-unpack-mmt4d.mlir' FAILED ********************
Exit Code: 2

Command Output (stdout):
--
# RUN: at line 8
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/stage1/bin/mlir-opt /home/tcwg-buildbot/worker/clang-aarch64-sve-vls/llvm/mlir/test/Integration/Dialect/Linalg/CPU/ArmSVE/pack-unpack-mmt4d.mlir -transform-interpreter -test-transform-dialect-erase-schedule -cse -canonicalize -test-lower-to-llvm | mlir-runner -e main -entry-point-result=void --march=aarch64 --mattr="+sve" -shared-libs=/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/stage1/lib/libmlir_runner_utils.so,/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/stage1/lib/libmlir_c_runner_utils.so | /home/tcwg-buildbot/worker/clang-aarch64-sve-vls/stage1/bin/FileCheck /home/tcwg-buildbot/worker/clang-aarch64-sve-vls/llvm/mlir/test/Integration/Dialect/Linalg/CPU/ArmSVE/pack-unpack-mmt4d.mlir
# executed command: /home/tcwg-buildbot/worker/clang-aarch64-sve-vls/stage1/bin/mlir-opt /home/tcwg-buildbot/worker/clang-aarch64-sve-vls/llvm/mlir/test/Integration/Dialect/Linalg/CPU/ArmSVE/pack-unpack-mmt4d.mlir -transform-interpreter -test-transform-dialect-erase-schedule -cse -canonicalize -test-lower-to-llvm
# executed command: mlir-runner -e main -entry-point-result=void --march=aarch64 --mattr=+sve -shared-libs=/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/stage1/lib/libmlir_runner_utils.so,/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/stage1/lib/libmlir_c_runner_utils.so
# .---command stderr------------
# | loc("<stdin>":1821:12): error: Dialect `vector' not found for custom op 'vector.shape_cast' 
# | could not parse the input IR
# `-----------------------------
# error: command failed with exit status: 1
# executed command: /home/tcwg-buildbot/worker/clang-aarch64-sve-vls/stage1/bin/FileCheck /home/tcwg-buildbot/worker/clang-aarch64-sve-vls/llvm/mlir/test/Integration/Dialect/Linalg/CPU/ArmSVE/pack-unpack-mmt4d.mlir
# .---command stderr------------
# | FileCheck error: '<stdin>' is empty.
# | FileCheck command line:  /home/tcwg-buildbot/worker/clang-aarch64-sve-vls/stage1/bin/FileCheck /home/tcwg-buildbot/worker/clang-aarch64-sve-vls/llvm/mlir/test/Integration/Dialect/Linalg/CPU/ArmSVE/pack-unpack-mmt4d.mlir
# `-----------------------------
# error: command failed with exit status: 2

--

********************


@llvm-ci
Copy link
Copy Markdown

llvm-ci commented May 24, 2026

LLVM Buildbot has detected a new failure on builder clang-with-thin-lto-ubuntu running on as-worker-92 while building clang at step 12 "build-stage2-compiler".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/127/builds/7379

Here is the relevant piece of the build log for the reference
Step 12 (build-stage2-compiler) failure: build (failure)
...
296.498 [2517/72/4469] Building CXX object lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIFrameLowering.cpp.o
296.502 [2516/72/4470] Building C object tools/clang/tools/clang-fuzzer/dictionary/CMakeFiles/clang-fuzzer-dictionary.dir/dictionary.c.o
296.571 [2515/72/4471] Building CXX object lib/Target/AMDGPU/MCTargetDesc/CMakeFiles/LLVMAMDGPUDesc.dir/AMDGPUMCExpr.cpp.o
296.597 [2514/72/4472] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexer.cpp.o
296.622 [2513/72/4473] Building CXX object lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIPreAllocateWWMRegs.cpp.o
296.741 [2512/72/4474] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ModulesDriver.cpp.o
296.894 [2511/72/4475] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXLoadedDiagnostic.cpp.o
296.926 [2510/72/4476] Building CXX object lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SILowerControlFlow.cpp.o
296.930 [2509/72/4477] Linking CXX executable bin/llvm-profdata
297.166 [2508/72/4478] Building CXX object lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o
FAILED: lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o 
/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang++ -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/build/stage2/lib/Target/AMDGPU -I/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/llvm-project/llvm/lib/Target/AMDGPU -I/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/build/stage2/include -I/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Xclang -fno-pch-timestamp -O3 -DNDEBUG -fvisibility=hidden -UNDEBUG -fno-exceptions -funwind-tables -fno-rtti -std=c++17 -Winvalid-pch -Xclang -include-pch -Xclang /home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/build/stage2/lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/build/stage2/lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/cmake_pch.hxx -MD -MT lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o -MF lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o.d -o lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o -c /home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/llvm-project/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang++ -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/build/stage2/lib/Target/AMDGPU -I/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/llvm-project/llvm/lib/Target/AMDGPU -I/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/build/stage2/include -I/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Xclang -fno-pch-timestamp -O3 -DNDEBUG -fvisibility=hidden -UNDEBUG -fno-exceptions -funwind-tables -fno-rtti -std=c++17 -Winvalid-pch -Xclang -include-pch -Xclang /home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/build/stage2/lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/build/stage2/lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/cmake_pch.hxx -MD -MT lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o -MF lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o.d -o lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o -c /home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/llvm-project/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp
1.	<eof> parser at end of file
2.	Optimizer
3.	Running pass "function<eager-inv>(drop-unnecessary-assumes,float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto;check-exit-count>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,drop-unnecessary-assumes,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-arithmetic;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,mergeicmps,expand-memcmp,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;switch-to-arithmetic;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)" on module "/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/llvm-project/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp"
4.	Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "_ZN4llvm22SIScheduleBlockCreator25regroupNoUserInstructionsEv"
 #0 0x00005645c65f0a00 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x40d5a00)
 #1 0x00005645c65ee594 llvm::sys::CleanupOnSignal(unsigned long) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x40d3594)
 #2 0x00005645c6528698 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007ffa8120c520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007ffa8136a88d (/lib/x86_64-linux-gnu/libc.so.6+0x1a088d)
 #5 0x00005645c658f118 llvm::Twine::str[abi:cxx11]() const (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x4074118)
 #6 0x00005645c68cddb1 llvm::VPInstruction::VPInstruction(unsigned int, llvm::ArrayRef<llvm::VPValue*>, llvm::VPIRFlags const&, llvm::VPIRMetadata const&, llvm::DebugLoc, llvm::Twine const&) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x43b2db1)
 #7 0x00005645c68553e1 std::_Function_handler<void (llvm::VPSingleDefRecipe*), llvm::LoopVectorizationPlanner::addReductionResultComputation(std::unique_ptr<llvm::VPlan, std::default_delete<llvm::VPlan>>&, llvm::VPRecipeBuilder&, llvm::ElementCount)::'lambda0'(llvm::VPSingleDefRecipe*)>::_M_invoke(std::_Any_data const&, llvm::VPSingleDefRecipe*&&) LoopVectorize.cpp:0:0
 #8 0x00005645c685d39d llvm::LoopVectorizationPlanner::addReductionResultComputation(std::unique_ptr<llvm::VPlan, std::default_delete<llvm::VPlan>>&, llvm::VPRecipeBuilder&, llvm::ElementCount) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x434239d)
 #9 0x00005645c685e7b5 llvm::LoopVectorizationPlanner::tryToBuildVPlan(std::unique_ptr<llvm::VPlan, std::default_delete<llvm::VPlan>>, llvm::VFRange&) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x43437b5)
#10 0x00005645c685f504 llvm::LoopVectorizationPlanner::buildVPlans(llvm::ElementCount, llvm::ElementCount) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x4344504)
#11 0x00005645c6870009 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x4355009)
#12 0x00005645c687931c llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x435e31c)
#13 0x00005645c687af80 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x435ff80)
#14 0x00005645c687b32b llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x436032b)
#15 0x00005645c7765c06 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x524ac06)
#16 0x00005645c5f52c10 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x3a37c10)
#17 0x00005645c38d8df6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x13bddf6)
#18 0x00005645c5f53748 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x3a38748)
#19 0x00005645c38d94e6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x13be4e6)
#20 0x00005645c5f556f0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x3a3a6f0)
#21 0x00005645c69c19a6 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0
#22 0x00005645c69c58bd clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x44aa8bd)
#23 0x00005645c7008388 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x4aed388)
#24 0x00005645c8a18c7c clang::ParseAST(clang::Sema&, bool, bool) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x64fdc7c)
#25 0x00005645c737379e clang::FrontendAction::Execute() (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x4e5879e)
#26 0x00005645c72df405 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x4dc4405)
#27 0x00005645c745d58c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0x4f4258c)
#28 0x00005645c3477269 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/install/stage1/bin/clang+++0xf5c269)
#29 0x00005645c346eedb ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0

@llvm-ci
Copy link
Copy Markdown

llvm-ci commented May 25, 2026

LLVM Buildbot has detected a new failure on builder clang-aarch64-sve-vls-2stage running on linaro-g3-03 while building clang at step 11 "build stage 2".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/4/builds/12240

Here is the relevant piece of the build log for the reference
Step 11 (build stage 2) failure: 'ninja' (failure)
...
[3341/9808] Building CXX object lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIFrameLowering.cpp.o
[3342/9808] Building CXX object lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86TargetObjectFile.cpp.o
[3343/9808] Building CXX object lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86CompressEVEX.cpp.o
[3344/9808] Building CXX object lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SILowerControlFlow.cpp.o
[3345/9808] Building CXX object lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIPreAllocateWWMRegs.cpp.o
[3346/9808] Building CXX object lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86SelectionDAGInfo.cpp.o
[3347/9808] Building CXX object lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86ReturnThunks.cpp.o
[3348/9808] Building CXX object lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86MachineFunctionInfo.cpp.o
[3349/9808] Building CXX object lib/Target/AMDGPU/MCTargetDesc/CMakeFiles/LLVMAMDGPUDesc.dir/AMDGPUInstPrinter.cpp.o
[3350/9808] Building CXX object lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o
FAILED: lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang++ -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/lib/Target/AMDGPU -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/lib/Target/AMDGPU -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/include -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/include -mcpu=neoverse-512tvb -msve-vector-bits=256 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Xclang -fno-pch-timestamp -O3 -DNDEBUG -std=c++17 -fvisibility=hidden -UNDEBUG -fno-exceptions -funwind-tables -fno-rtti -Winvalid-pch -Xclang -include-pch -Xclang /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/cmake_pch.hxx -MD -MT lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o -MF lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o.d -o lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o -c /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp
clang++: /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/include/llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From *) [To = llvm::VPInstruction, From = llvm::VPSingleDefRecipe]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang++ -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/lib/Target/AMDGPU -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/lib/Target/AMDGPU -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/include -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/include -mcpu=neoverse-512tvb -msve-vector-bits=256 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Xclang -fno-pch-timestamp -O3 -DNDEBUG -std=c++17 -fvisibility=hidden -UNDEBUG -fno-exceptions -funwind-tables -fno-rtti -Winvalid-pch -Xclang -include-pch -Xclang /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/cmake_pch.hxx -MD -MT lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o -MF lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o.d -o lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/SIMachineScheduler.cpp.o -c /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp
1.	<eof> parser at end of file
2.	Optimizer
3.	Running pass "function<eager-inv>(drop-unnecessary-assumes,float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto;check-exit-count>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,drop-unnecessary-assumes,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-arithmetic;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,mergeicmps,expand-memcmp,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;switch-to-arithmetic;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)" on module "/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp"
4.	Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "_ZN4llvm22SIScheduleBlockCreator25regroupNoUserInstructionsEv"
 #0 0x0000bbd985cfe390 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0x962e390)
 #1 0x0000bbd985cfb8e8 llvm::sys::RunSignalHandlers() (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0x962b8e8)
 #2 0x0000bbd985cfd1e0 llvm::sys::CleanupOnSignal(unsigned long) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0x962d1e0)
 #3 0x0000bbd985c59bb4 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x0000e74613a01a60 (linux-vdso.so.1+0xa60)
 #5 0x0000e74613572008 __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x0000e7461352a83c gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #7 0x0000e74613517134 abort ./stdlib/abort.c:81:7
 #8 0x0000e74613524114 __assert_fail_base ./assert/assert.c:91:7
 #9 0x0000e7461352418c (/lib/aarch64-linux-gnu/libc.so.6+0x3418c)
#10 0x0000bbd985f3d8b0 std::_Function_handler<void (llvm::VPSingleDefRecipe*), llvm::LoopVectorizationPlanner::addReductionResultComputation(std::unique_ptr<llvm::VPlan, std::default_delete<llvm::VPlan>>&, llvm::VPRecipeBuilder&, llvm::ElementCount)::$_1>::_M_invoke(std::_Any_data const&, llvm::VPSingleDefRecipe*&&) LoopVectorize.cpp:0:0
#11 0x0000bbd985f3d5e4 std::_Function_handler<void (llvm::VPSingleDefRecipe*), llvm::LoopVectorizationPlanner::addReductionResultComputation(std::unique_ptr<llvm::VPlan, std::default_delete<llvm::VPlan>>&, llvm::VPRecipeBuilder&, llvm::ElementCount)::$_1>::_M_invoke(std::_Any_data const&, llvm::VPSingleDefRecipe*&&) LoopVectorize.cpp:0:0
#12 0x0000bbd985f09598 llvm::LoopVectorizationPlanner::addReductionResultComputation(std::unique_ptr<llvm::VPlan, std::default_delete<llvm::VPlan>>&, llvm::VPRecipeBuilder&, llvm::ElementCount) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0x9839598)
#13 0x0000bbd985f07ca8 llvm::LoopVectorizationPlanner::tryToBuildVPlan(std::unique_ptr<llvm::VPlan, std::default_delete<llvm::VPlan>>, llvm::VFRange&) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0x9837ca8)
#14 0x0000bbd985efe9c4 llvm::LoopVectorizationPlanner::buildVPlans(llvm::ElementCount, llvm::ElementCount) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0x982e9c4)
#15 0x0000bbd985efe348 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0x982e348)
#16 0x0000bbd985f0b964 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0x983b964)
#17 0x0000bbd985f14ef8 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0x9844ef8)
#18 0x0000bbd985f1578c llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0x984578c)
#19 0x0000bbd9856b1050 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0x8fe1050)
#20 0x0000bbd9856b51b0 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0x8fe51b0)
#21 0x0000bbd9856b0140 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0x8fe0140)
#22 0x0000bbd9865f5a88 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0
#23 0x0000bbd9865ed688 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0x9f1d688)
#24 0x0000bbd986601194 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0x9f31194)
#25 0x0000bbd987f25d9c clang::ParseAST(clang::Sema&, bool, bool) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0xb855d9c)
#26 0x0000bbd986afde50 clang::FrontendAction::Execute() (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0xa42de50)
#27 0x0000bbd986a70d44 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0xa3a0d44)
#28 0x0000bbd986bf0edc clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang+++0xa520edc)

@NeKon69
Copy link
Copy Markdown
Contributor

NeKon69 commented May 25, 2026

Thanks you so much! Sorry I couldn't fix this myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:analysis clang:temporal-safety Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr) clang Clang issues not falling into any other category

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants