Skip to content

clang Assertion `StackTop == (unsigned)llvm::popcount(Mask) && "Live count mismatch"' failed. #149371

@bi6c

Description

@bi6c

Compiler Explorer: https://godbolt.org/z/oYcY9fdqj

  • generated by fuzzer
error: example.c:22:3: fixed input regs must be last on the x87 stack
error: example.c:22:3: implicitly popped regs must be last on the x87 stack
error: example.c:22:3: fixed input regs must be last on the x87 stack
error: example.c:22:3: implicitly popped regs must be last on the x87 stack
error: example.c:22:3: fixed input regs must be last on the x87 stack
error: example.c:22:3: implicitly popped regs must be last on the x87 stack
clang: /root/llvm-project/llvm/lib/Target/X86/X86FloatingPoint.cpp:992: void {anonymous}::FPS::adjustLiveRegs(unsigned int, llvm::MachineBasicBlock::iterator): Assertion `StackTop == (unsigned)llvm::popcount(Mask) && "Live count mismatch"' 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: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -fno-verbose-asm -c --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O2 <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 '@main'
 #0 0x0000000003fbcfa8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fbcfa8)
 #1 0x0000000003fba3d4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fba3d4)
 #2 0x0000000003efeba8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007ff36c442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007ff36c4969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007ff36c442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007ff36c4287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007ff36c42871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007ff36c439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00000000029c1d5e (anonymous namespace)::FPS::adjustLiveRegs(unsigned int, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>) X86FloatingPoint.cpp:0:0
#10 0x00000000029c28c6 (anonymous namespace)::FPS::handleSpecialFP(llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>&) X86FloatingPoint.cpp:0:0
#11 0x00000000029c4d47 (anonymous namespace)::FPS::processBasicBlock(llvm::MachineFunction&, llvm::MachineBasicBlock&) (.isra.0) X86FloatingPoint.cpp:0:0
#12 0x00000000029c7457 (anonymous namespace)::FPS::runOnMachineFunction(llvm::MachineFunction&) (.part.0) X86FloatingPoint.cpp:0:0
#13 0x00000000032c2873 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#14 0x00000000038eb15f llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x38eb15f)
#15 0x00000000038eb511 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x38eb511)
#16 0x00000000038ebd81 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x38ebd81)
#17 0x0000000004271c91 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*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4271c91)
#18 0x000000000496df03 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x496df03)
#19 0x00000000066638dc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x66638dc)
#20 0x000000000496e308 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x496e308)
#21 0x0000000004c61c75 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c61c75)
#22 0x0000000004bde97e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bde97e)
#23 0x0000000004d55741 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4d55741)
#24 0x0000000000d9e07f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd9e07f)
#25 0x0000000000d94c5a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#26 0x00000000049d59c9 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
#27 0x0000000003eff044 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3eff044)
#28 0x00000000049d5fdf 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
#29 0x0000000004997eed clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4997eed)
#30 0x0000000004998f7e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4998f7e)
#31 0x00000000049a1bc5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49a1bc5)
#32 0x0000000000d9a52f clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd9a52f)
#33 0x0000000000c4ea64 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc4ea64)
#34 0x00007ff36c429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#35 0x00007ff36c429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#36 0x0000000000d94705 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd94705)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

Code:

static __inline double mypow(double __x, double __y) {
  register double __value, __exponent;
  long __p = (long)__y;
  if (__y == (double)__p) {
    double __r = 1.0;
    if (__p == 0)
      return 1.0;
    if (__p < 0) {
      __p = -__p;
      __x = 1.0 / __x;
    }
    while (1) {
      if (__p & 1)
        __r *= __x;
      __p >>= 1;
      if (__p == 0)
        return __r;
      __x *= __x;
    }
  }
  __asm __volatile__("fmul      %%st(1),%%st\n\t" /* y * log2(x) */
                     "fst       %%st(1)\n\t"
                     "frndint\n\t" /* int(y * log2(x)) */
                     "fxch  %%st(1)\n\t"
                     "fsub      %%st(1),%%st\n\t" /* fract(y * log2(x)) */
                     "f2xm1\n\t" /* 2^(fract(y * log2(x))) - 1 */
                     : "=t"(__value), "=u"(__exponent)
                     : "R0"(__x), "1"(__y));
  __value += 1.0;
  __asm __volatile__("fscale" : "=t"(__value) : "0"(__value), "u"(__exponent));
  return __value;
}

const double E1 = 2.71828182845904523536028747135;

double fact(double x) {
  double corr;
  corr = 1.0;
  return corr * mypow(x / E1, x);
}

int main() {
  double y, z;

  y = fact(46.2);
  z = mypow(46.2 / E1, 46.2);

  return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions