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

    <tr>
        <th>Summary</th>
        <td>
            clang-17 fatal error: cannot pop empty stack
        </td>
    </tr>

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

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

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

<pre>
    Testcase is shown below:
```
#define X2(n) X1(n##0) X1(n##1)
#define X4(n) X2(n##0) X2(n##1)
#define X8(n) X4(n##0) X4(n##1)

volatile int ll;

__attribute__((noinline)) void foo(void) {}

__attribute__((noinline)) void f4(void) {
  int mem;
#undef X1
#define X1(n) double fpr##n = 0.0;
  X4(d)
#undef X1
#define X1(n) "+f"(fpr##n),
  asm volatile("" : X4(d) "=m"(mem) : : "memory");
  foo();
#undef X1
}
```

When compile it with `clang-17 -O0`, clang-17 reports a fatal error:
```
fatal error: error in backend: Cannot pop empty stack!
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: /opt/compiler-explorer/clang-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -c --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O0 <source>
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '<source>'.
4.      Running pass 'X86 FP Stackifier' on function '@_Z2f4v'
 #0 0x000055c83bf4605f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x361505f)
 #1 0x000055c83bf4408c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x361308c)
 #2 0x000055c83be93a57 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3562a57)
 #3 0x000055c83bf3bc82 llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x360ac82)
 #4 0x000055c8397c9d76 (/opt/compiler-explorer/clang-trunk/bin/clang+++0xe98d76)
 #5 0x000055c83be9ca4a llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x356ba4a)
 #6 0x000055c83be9cbde (/opt/compiler-explorer/clang-trunk/bin/clang+++0x356bbde)
 #7 0x000055c83abaa3a1 (anonymous namespace)::FPS::popStackAfter(llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>&) X86FloatingPoint.cpp:0:0
 #8 0x000055c83abb0146 (anonymous namespace)::FPS::processBasicBlock(llvm::MachineFunction&, llvm::MachineBasicBlock&) (.isra.0) X86FloatingPoint.cpp:0:0
 #9 0x000055c83abb07cc (anonymous namespace)::FPS::runOnMachineFunction(llvm::MachineFunction&) (.part.0) X86FloatingPoint.cpp:0:0
#10 0x000055c83abb112b (anonymous namespace)::FPS::runOnMachineFunction(llvm::MachineFunction&) X86FloatingPoint.cpp:0:0
#11 0x000055c83b3b97b0 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#12 0x000055c83b8d853a llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2fa753a)
#13 0x000055c83b8d86c9 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2fa76c9)
#14 0x000055c83b8d92b0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2fa82b0)
#15 0x000055c83c1b67d0 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>>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x38857d0)
#16 0x000055c83d0c45cc clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x47935cc)
#17 0x000055c83e4940e9 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5b630e9)
#18 0x000055c83d0c3685 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4792685)
#19 0x000055c83c9a7bf1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4076bf1)
#20 0x000055c83c92b8f3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ffa8f3)
#21 0x000055c83ca86b23 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4155b23)
#22 0x000055c8397cb2fc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xe9a2fc)
#23 0x000055c8397c69ff ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#24 0x000055c83c78831d 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::'lambda'()>(long) Job.cpp:0:0
#25 0x000055c83be93947 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3562947)
#26 0x000055c83c78855c clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#27 0x000055c83c74ff9e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e1ef9e)
#28 0x000055c83c75096d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e1f96d)
#29 0x000055c83c75b03c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e2a03c)
#30 0x000055c8397c8eff clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xe97eff)
#31 0x000055c8396c6245 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd95245)
#32 0x00007fd1a513f083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#33 0x000055c8397c2cde _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xe91cde)
clang++: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Compiler returned: 70
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl1z4yjW_jXKDWWXBPq8yIXjxO_bUzPVqU52d2pvXAgdbLYl0ALKx7_fQpJtoTidzIx7b7aqY2M-Ds95OJxzgKbGiJ0EuA6SmyC5vaKd3St9_SxAWyWvSlW9Xj-CsYwaQMIgs1fPEpVQq-eArILwNghXQRqO_4afmFTAhQT0Ow5wLgNcoN-joUQCTMJ5RRTg4s3Q-DgUz4fiD4bmx6HxfGh8dmj_-aRqakUNSEiL6jogN9PW7ZZaq0XZWdhuA9xPoYSshQQnBxfoSYkKcaUCnLuiqwqymyC7_TNi4pmUfjDqoTXQnLBh0skKuKNzzkJ0YKFSXVkD4q0eFJcoILcoXIZHMWggppqS-bHcAOMA3_D-Kz9J7_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