<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/95109>95109</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AArch64] Assertion with SME and -mspeculative-load-hardening
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:AArch64,
crash-on-valid
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ostannard
</td>
</tr>
</table>
<pre>
This code causes an assertion failure in the speculative load hardening pass:
```c
void foo(void);
void bar(void) __arm_in("za") { foo(); }
```
```
$ /work/llvm/install/bin/clang --target=aarch64--none-elf -march=armv9.5-a+sme -c file000054.c -O1 -mspeculative-load-hardening
clang: /work/llvm/llvm-project/llvm/lib/Target/AArch64/AArch64SpeculationHardening.cpp:212: bool (anonymous namespace)::AArch64SpeculationHardening::endsWithCondControlFlow(llvm::MachineBasicBlock &, llvm::MachineBasicBlock *&, llvm::MachineBasicBlock *&, AArch64CC::CondCode &) const: Assertion `analyzeBranchCondCode.size() == 1 && "unknown Cond array format"' 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: /work/llvm/install/bin/clang --target=aarch64--none-elf -march=armv9.5-a+sme -c file000054.c -O1 -mspeculative-load-hardening
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'file000054.c'.
4. Running pass 'AArch64 speculation hardening pass' on function '@bar'
#0 0x00005653c6ef5087 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work/llvm/install/bin/clang+0x4dea087)
#1 0x00005653c6ef2c3e llvm::sys::RunSignalHandlers() (/work/llvm/install/bin/clang+0x4de7c3e)
#2 0x00005653c6e67408 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007fac3cc42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007fac3cc969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007fac3cc969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x00007fac3cc969fc pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x00007fac3cc42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007fac3cc287f3 abort ./stdlib/abort.c:81:7
#9 0x00007fac3cc2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007fac3cc39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00005653c5f265d3 (/work/llvm/install/bin/clang+0x3e1b5d3)
#12 0x00005653c6402870 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/work/llvm/install/bin/clang+0x42f7870)
#13 0x00005653c69db4e9 llvm::FPPassManager::runOnFunction(llvm::Function&) (/work/llvm/install/bin/clang+0x48d04e9)
#14 0x00005653c69e3861 llvm::FPPassManager::runOnModule(llvm::Module&) (/work/llvm/install/bin/clang+0x48d8861)
#15 0x00005653c69dbf9c llvm::legacy::PassManagerImpl::run(llvm::Module&) (/work/llvm/install/bin/clang+0x48d0f9c)
#16 0x00005653c76f0c2d clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, 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*) (/work/llvm/install/bin/clang+0x55e5c2d)
#17 0x00005653c771709c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/work/llvm/install/bin/clang+0x560c09c)
#18 0x00005653c9607597 clang::ParseAST(clang::Sema&, bool, bool) (/work/llvm/install/bin/clang+0x74fc597)
#19 0x00005653c7b985d0 clang::FrontendAction::Execute() (/work/llvm/install/bin/clang+0x5a8d5d0)
#20 0x00005653c7b0189f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/work/llvm/install/bin/clang+0x59f689f)
#21 0x00005653c7c86577 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/work/llvm/install/bin/clang+0x5b7b577)
#22 0x00005653c56e16ea cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/work/llvm/install/bin/clang+0x35d66ea)
#23 0x00005653c56de061 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#24 0x00005653c7940329 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_1>(long) Job.cpp:0:0
#25 0x00005653c6e6714b llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/work/llvm/install/bin/clang+0x4d5c14b)
#26 0x00005653c793f890 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/work/llvm/install/bin/clang+0x5834890)
#27 0x00005653c78f9f28 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/work/llvm/install/bin/clang+0x57eef28)
#28 0x00005653c78fa1e7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/work/llvm/install/bin/clang+0x57ef1e7)
#29 0x00005653c791b367 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/work/llvm/install/bin/clang+0x5810367)
#30 0x00005653c56dd76e clang_main(int, char**, llvm::ToolContext const&) (/work/llvm/install/bin/clang+0x35d276e)
#31 0x00005653c56ee447 main (/work/llvm/install/bin/clang+0x35e3447)
#32 0x00007fac3cc29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#33 0x00007fac3cc29e40 call_init ./csu/../csu/libc-start.c:128:20
#34 0x00007fac3cc29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#35 0x00005653c56db8a5 _start (/work/llvm/install/bin/clang+0x35d08a5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 19.0.0git (git@github.com:llvm/llvm-project.git 79ce70b8033815b6abd3a9a5cc2335de70f1aaab)
Target: aarch64-unknown-none-elf
Thread model: posix
InstalledDir: /work/llvm/install/bin
Build config: +assertions
clang: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/file000054-374357.c
clang: note: diagnostic msg: /tmp/file000054-374357.sh
clang: note: diagnostic msg:
********************
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl9z2yoW_zTkhbFHAv19yIPixLe9024yTe7eRw9CRzYbCbyA0uR--h2QbEuOk9bZ7u7DdtKJDYfDj_MfTpgxYi0BLlF8heLrC9bZjdKXylgmJdPVRamql8uHjTCYqwowZ50Bg5nEzBjQViiJayaaTgMWEtsNYLMF3jXMiifAjWIV3jBdgRRyjbfMGEQLFFyjoEBJ0P_w_vuTEhWulUIkcx8RyRG9Gk2VTB-m8GrFdLsSEpEMEfIXQ4S4YZReDTz69Ril10fbDV9PDpIII7L8rvQjIsumeWoRWQppLGsaRJal227JGybXeDazTK_BInrNmOabJJrNpJIwg6bGs9YNuSndPuXzeMYQuTIt4BnHtWggCIIgjuYcz25DPGtHEps5ic32Euth-R0RLV5jc79mW63-AdyORkWJyPKhx0eWReHxHT7d7_ZT8tNupznfbhEtSEjcRqVSDUYkY1LJl1Z1BkvWgtkyDl6uBaLFO8x6ApCV-VPYzULJaqGk1apZNuo7IpnH6Wm-Mr4REq6YEfyqUfwRI5IgssDvkxRnUQ1IF4uetMdTQb9VjrmSxrpTF3uTRknAJGte_oI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