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

    <tr>
        <th>Summary</th>
        <td>
            [18 regression] Assertion `!NodePtr->isKnownSentinel()' failed at -O3 with aarch64 targets
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    Building the attached test case (extracted from mesa 24.0.0-rc3) with clang 18-rc1 at `-O3` for aarch64 targets fails.
Non-aarch64 targets are ok, aarch64 targets are ok at -O2 and lower.

```
$ clang -target aarch64-linux-gnu -O3 -c testcase.c
testcase.c:23:9: warning: comparison between pointer and integer ('int' and 'struct (unnamed struct at testcase.c:6:1) *') [-Wpointer-integer-compare]
   23 |   if (l == &j)
      |       ~ ^ ~~
testcase.c:31:4: warning: passing arguments to 'f' without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
   31 |   f(k, aq);
      |    ^
clang: /builddir/build/BUILD/llvm-project-release-18.x/llvm/include/llvm/ADT/ilist_iterator.h:138: reference llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::MachineInstr, true, true, void, false>, false, false>::operator*() const [OptionsT = llvm::ilist_detail::node_options<llvm::MachineInstr, true, true, void, false>, IsReverse = false, IsConst = false]: Assertion `!NodePtr->isKnownSentinel()' 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: clang -target aarch64-linux-gnu -O3 -c testcase.c
1. <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'testcase.c'.
4.      Running pass 'AArch64 load / store optimization pass' on function '@o'
 #0 0x00007f341c779806 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib64/libLLVM-18.so+0x4579806)
 #1 0x00007f341c77847a llvm::sys::RunSignalHandlers() (/usr/lib64/libLLVM-18.so+0x457847a)
 #2 0x00007f341c69106e (/usr/lib64/libLLVM-18.so+0x449106e)
 #3 0x00007f3417c55700 (/usr/lib64/libc.so.6+0x3d700)
 #4 0x00007f3417ca49cc (/usr/lib64/libc.so.6+0x8c9cc)
 #5 0x00007f3417c55652 gsignal (/usr/lib64/libc.so.6+0x3d652)
 #6 0x00007f3417c3e4ad abort (/usr/lib64/libc.so.6+0x264ad)
 #7 0x00007f3417c3e3d5 (/usr/lib64/libc.so.6+0x263d5)
 #8 0x00007f3417c4e042 (/usr/lib64/libc.so.6+0x36042)
 #9 0x00007f341cb8c7c3 (/usr/lib64/libLLVM-18.so+0x498c7c3)
#10 0x00007f341f48b01a (/usr/lib64/libLLVM-18.so+0x728b01a)
#11 0x00007f341f4879b3 (/usr/lib64/libLLVM-18.so+0x72879b3)
#12 0x00007f341cdd4dc1 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/lib64/libLLVM-18.so+0x4bd4dc1)
#13 0x00007f341ca1efe3 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib64/libLLVM-18.so+0x481efe3)
#14 0x00007f341ca2b1c4 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/lib64/libLLVM-18.so+0x482b1c4)
#15 0x00007f341ca23db3 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib64/libLLVM-18.so+0x4823db3)
#16 0x00007f3424baf21b 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*) (/usr/lib64/libclang-cpp.so.18+0x2daf21b)
#17 0x00007f34250466c7 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/lib64/libclang-cpp.so.18+0x32466c7)
#18 0x00007f34236428c6 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib64/libclang-cpp.so.18+0x18428c6)
#19 0x00007f3425bb2f5b clang::FrontendAction::Execute() (/usr/lib64/libclang-cpp.so.18+0x3db2f5b)
#20 0x00007f3425b149e9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib64/libclang-cpp.so.18+0x3d149e9)
#21 0x00007f3425c33328 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib64/libclang-cpp.so.18+0x3e33328)
#22 0x00005574a76a9fa0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-18+0x16fa0)
#23 0x00005574a76a5df0 (/usr/bin/clang-18+0x12df0)
#24 0x00007f34256fa74b (/usr/lib64/libclang-cpp.so.18+0x38fa74b)
#25 0x00007f341c6912e3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib64/libLLVM-18.so+0x44912e3)
#26 0x00007f34256fa633 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/lib64/libclang-cpp.so.18+0x38fa633)
#27 0x00007f34256b3cac clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/lib64/libclang-cpp.so.18+0x38b3cac)
#28 0x00007f34256b41ae clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/lib64/libclang-cpp.so.18+0x38b41ae)
#29 0x00007f34256f5ccf clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/lib64/libclang-cpp.so.18+0x38f5ccf)
#30 0x00005574a76a5366 clang_main(int, char**, llvm::ToolContext const&) (/usr/bin/clang-18+0x12366)
#31 0x00005574a76b5186 main (/usr/bin/clang-18+0x22186)
#32 0x00007f3417c3fc0a (/usr/lib64/libc.so.6+0x27c0a)
#33 0x00007f3417c3fcc5 __libc_start_main (/usr/lib64/libc.so.6+0x27cc5)
#34 0x00005574a76a1f01 _start (/usr/bin/clang-18+0xef01)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
```

[testcase.c](https://github.com/llvm/llvm-project/files/14076619/testcase.c.txt)

```c
$ cat testcase.c
enum { a };
struct c {
  char d[0];
};
enum { e = 8 };
struct {
  int b[16385];
  char ah[4];
  struct c ak;
} f(), j;
typedef union {
  struct {
    int g;
  };
  int h;
} i;
i k;
int l, m;
unsigned n();
void o() {
  unsigned aq = n();
  k.h = 0;
  if (l == &j)
    aq = j.ak.d[aq];
  else {
    if (m == a)
      aq = j.ah[aq];
    if (m)
      k.g = e;
  }
  f(k, aq);
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8WVtz46jW_TXkhbJLAt38kAfHib_p-bqnU53MnEcXQls2HRncgHI5D_PbT4EkWyhJJ5k5c7q6IpnLYu3NZrEFzBixlQDnKL1A6eUZa-1O6fMStGqEbB_PSlU9nV-0oqmE3GK7A8ysZXwHFbZgLObMAEakgEerGbdQ4VqrPd6DYZgk82gezTSniCzwg7A7zBsmtzguZprHmFmMsmj2laIswrXSmDHNd1mCLdNbsAbXTDRmjqJLFC1_U3I2rWcasLpDZPWsZ1fjRph9JZjJCjfqAXSP1f_Nov5_95MkPb1ZhzKAzrwnZlvZ4tlXimfcW-4Mn_Ou6-g3XRKK6HKB6BI_MC2F3LpXrvYHpoVREpdgHwAkPighLWhPzr1tQTtHIpILaRHJfQUiubG65dZVtVKyPVS4L2EWBwNniC5j52lElojk_i29mP2rH2jWDzLruABKLzv2GGNCMcpXGGNRu4EajOglopcYkew7IotjO4z7du7fnxilV_jPP1_wAY0RXSYTHxxcsMktZnrb7kFag61yBtbOWB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