<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/107609>107609</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            `clang++-17` and `clang++-18` segfault when using aliased ARM64 SVE intrinsic types
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          bashimao
      </td>
    </tr>
</table>

<pre>
    The following compiles with clang++-16, clang++-17 and clang++18:
```
#include <arm_sve.h>
#include <iostream>

int main(int,const char*[]) {
  svbool_t pg{svptrue_b8()};
  svint8_t a{svdup_s8(1)};
  svint8_t b{svdup_s8(2)};

  svint8_t c = svadd_s8_x(pg, a, b);

  std::cout << svaddv_s8(pg, c) << '\n';
}
```


But, if you alias the vector type with `using` as in the following:

```
#include <arm_sve.h>
#include <iostream>

using vec_t = svint8_t;

int main(int,const char*[]) {
  svbool_t pg{svptrue_b8()};
  vec_t a{svdup_s8(1)};
  vec_t b{svdup_s8(2)};

  vec_t c = svadd_s8_x(pg, a, b);

  std::cout << svaddv_s8(pg, c) << '\n';
}
```

and compile it:

```
clang++-18 -march=armv9-a main.cpp
clang++-17 -march=armv9-a main.cpp
```

both `clang++-18` and `clang++-17` will just die with segfault.

```
clang++-18 -march=armv9-a main.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: /usr/lib/llvm-18/bin/clang -cc1 -triple aarch64-unknown-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=non-leaf -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -target-feature +v9a -target-feature +crc -target-feature +dotprod -target-feature +complxnum -target-feature +fp-armv8 -target-feature +fullfp16 -target-feature +jsconv -target-feature +lse -target-feature +pauth -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +neon -target-feature +sve -target-feature +sve2 -target-abi aapcs -debugger-tuning=gdb -fdebug-compilation-dir=/monkey-wrench/minimal-sample -fcoverage-compilation-dir=/monkey-wrench/minimal-sample -resource-dir /usr/lib/llvm-18/lib/clang/18 -internal-isystem /usr/bin/../lib/gcc/aarch64-linux-gnu/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/aarch64-linux-gnu/13/../../../../include/aarch64-linux-gnu/c++/13 -internal-isystem /usr/bin/../lib/gcc/aarch64-linux-gnu/13/../../../../include/c++/13/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/include -internal-externc-isystem /usr/include/aarch64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -target-feature +outline-atomics -target-feature -fmv -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/main-ad1a30.o -x c++ main.cpp
1. main.cpp:19:1: current parser token 'int'
2.      main.cpp:6:5: LLVM IR generation of declaration 'main'
3.      main.cpp:6:5: Generating code for declaration 'main'
 #0 0x0000e82423ecd398 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd9d398)
 #1 0x0000e82423ecb5a8 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd9b5a8)
 #2 0x0000e82423ecdafc (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd9dafc)
 #3 0x0000e8242e2009d0 (linux-vdso.so.1+0x9d0)
 #4 0x0000e8242401a3f8 llvm::LLVMContext::shouldDiscardValueNames() const (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xeea3f8)
 #5 0x0000e8242407b854 llvm::Value::setNameImpl(llvm::Twine const&) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xf4b854)
 #6 0x0000e8242407bc10 llvm::Value::setName(llvm::Twine const&) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xf4bc10)
 #7 0x0000e8242c2b6bd4 clang::CodeGen::CGBuilderInserter::InsertHelper(llvm::Instruction*, llvm::Twine const&, llvm::BasicBlock*, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true>, false, false>) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f36bd4)
 #8 0x0000e8242bf8ab58 (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1c0ab58)
 #9 0x0000e8242c13ebe4 clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*, clang::CodeGen::Address, bool, clang::QualType, clang::CodeGen::LValueBaseInfo, clang::CodeGen::TBAAAccessInfo, bool, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1dbebe4)
#10 0x0000e8242c13ee54 clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*, clang::CodeGen::LValue, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1dbee54)
#11 0x0000e8242c12df44 clang::CodeGen::CodeGenFunction::EmitStoreThroughLValue(clang::CodeGen::RValue, clang::CodeGen::LValue, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1dadf44)
#12 0x0000e8242c1145b4 clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1d945b4)
#13 0x0000e8242c1185b0 clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1d985b0)
#14 0x0000e8242c1164f8 clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission const&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1d964f8)
#15 0x0000e8242c112c3c clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1d92c3c)
#16 0x0000e8242c112940 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1d92940)
#17 0x0000e8242c25bc44 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1edbc44)
#18 0x0000e8242c25afe4 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1edafe4)
#19 0x0000e8242c264700 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1ee4700)
#20 0x0000e8242c2b2420 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f32420)
#21 0x0000e8242c2b2e48 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f32e48)
#22 0x0000e8242c2d2ab8 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f52ab8)
#23 0x0000e8242c2cbb28 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f4bb28)
#24 0x0000e8242c2cf72c clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f4f72c)
#25 0x0000e8242c2ca78c clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f4a78c)
#26 0x0000e8242c36bd58 (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1febd58)
#27 0x0000e8242c2a5658 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f25658)
#28 0x0000e8242af0a610 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0xb8a610)
#29 0x0000e8242ccbfa34 clang::FrontendAction::Execute() (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x293fa34)
#30 0x0000e8242cc50590 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x28d0590)
#31 0x0000e8242cd38e4c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x29b8e4c)
#32 0x0000ab1a073521c4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-18/bin/clang+0x121c4)
#33 0x0000ab1a0734fbac (/usr/lib/llvm-18/bin/clang+0xfbac)
#34 0x0000ab1a0734ed00 clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-18/bin/clang+0xed00)
#35 0x0000ab1a0735ae40 main (/usr/lib/llvm-18/bin/clang+0x1ae40)
#36 0x0000e82422d084c4 (/lib/aarch64-linux-gnu/libc.so.6+0x284c4)
#37 0x0000e82422d08598 __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x28598)
#38 0x0000ab1a0734c970 _start (/usr/lib/llvm-18/bin/clang+0xc970)
clang++-18: error: unable to execute command: Segmentation fault (core dumped)
clang++-18: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 18.1.3 (1ubuntu1)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang++-18: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++-18: note: diagnostic msg: /tmp/main-2c0338.cpp
clang++-18: note: diagnostic msg: /tmp/main-2c0338.sh
clang++-18: note: diagnostic msg:

********************
```

This code can be compiled with `clang++-16` though. So, something was somewhat recently changed that broke it.

[main-2c0338.cpp.txt](https://github.com/user-attachments/files/16910995/main-2c0338.cpp.txt)
[main-2c0338.sh.txt](https://github.com/user-attachments/files/16910996/main-2c0338.sh.txt)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUW11z4yiz_jXKDYVLQpI_LnLh2HE2Vdl35kzyzl66ELRsNghUgJzk359C8heKk5lkPXP2TE3ZFjTwPN1N05I61FqxUgCXUX4V5fML2ri1NpcFtWtRUX1RaP5y-bAGVGop9ZNQK8R0VQsJFj0Jt0ZMUrWKyFVErnAyjMgsbBkhqvhxUzKO0mkUz6N4Gg3j7f_ukqRCMdlwQFE6o6Za2g0M1lF6fapfaOsM0OrQ3X4K5VBFhYrIWCgXkRnTyjrE1tREZNqRjMgERaOrbgBCdlNoLZcO1atodGU3tTMNLItxRMYRmUSjeZQeyQrlxkuHaCvKm3ppvWDytmQRSpKe5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