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

    <tr>
        <th>Summary</th>
        <td>
            clang crash on x86_64-linux-gnu: error in backend: Broken module found, compilation aborted!
        </td>
    </tr>

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

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

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

<pre>
    Compiler Explorer: https://godbolt.org/z/zMP936sGe
```console
<source>:55:5: warning: function 'async_mutual_loop2' declared 'noreturn' should not return [-Winvalid-noreturn]
   55 |     return async_leaf1(ctx);
      | ^
<source>:57:5: warning: function 'async_mutual_loop2' declared 'noreturn' should not return [-Winvalid-noreturn]
   57 |     return async_leaf2(ctx);
      |     ^
<source>:59:3: warning: function 'async_mutual_loop2' declared 'noreturn' should not return [-Winvalid-noreturn]
   59 |   return async_mutual_loop1(u - 2, ctx);
 |   ^
<source>:69:22: warning: unknown attribute 'noipa' ignored [-Wunknown-attributes]
   69 | char __attribute__ ((noipa)) c_calling_async(MYBOOL b, unsigned u) {
      | ^~~~~
musttail call must precede a ret with an optional bitcast
  musttail call swifttailcc void @async_mutual_loop2(i32 noundef %sub, ptr noundef swiftasync %7) #2, !dbg !105
fatal error: error in backend: Broken module found, compilation aborted!
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 <source>
1.      <eof> parser at end of file
2.      Optimizer
3.      Running pass "verify" on module "<source>"
 #0 0x0000000003c56df8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c56df8)
 #1 0x0000000003c54b04 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c54b04)
 #2 0x0000000003ba25d6 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ba25d6)
 #3 0x0000000003c4be2e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c4be2e)
 #4 0x0000000000cdf720 LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0
 #5 0x0000000003bad683 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3bad683)
 #6 0x0000000003bad7e8 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3bad7e8)
 #7 0x0000000003636bb8 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3636bb8)
 #8 0x0000000003ef736e llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ef736e)
 #9 0x00000000036018c0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x36018c0)
#10 0x0000000003f0a1ef (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0
#11 0x0000000003f0dd65 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*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f0dd65)
#12 0x00000000045e028e clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45e028e)
#13 0x00000000065ca42c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x65ca42c)
#14 0x00000000045e0668 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45e0668)
#15 0x0000000004899a89 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4899a89)
#16 0x000000000481c48e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x481c48e)
#17 0x00000000049862ce clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49862ce)
#18 0x0000000000ce1c7f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xce1c7f)
#19 0x0000000000cd971a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#20 0x0000000004624ad9 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
#21 0x0000000003ba2514 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ba2514)
#22 0x00000000046250cf 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
#23 0x00000000045ea3dd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45ea3dd)
#24 0x00000000045eb4cd 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+0x45eb4cd)
#25 0x00000000045f2a45 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45f2a45)
#26 0x0000000000cdeac3 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcdeac3)
#27 0x0000000000bac364 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbac364)
#28 0x000071129a429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#29 0x000071129a429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#30 0x0000000000cd91c5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcd91c5)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Compiler returned: 70
```
Code:
```c

#define SWIFTCALL __attribute__((swiftcall))
#define SWIFTASYNCCALL __attribute__((swiftasynccall))
#define ASYNC_CONTEXT __attribute__((swift_async_context))

SWIFTASYNCCALL void async_leaf1(char * ASYNC_CONTEXT ctx) {
  *ctx += 1;
}

SWIFTASYNCCALL void async_leaf2(char * ASYNC_CONTEXT ctx) {
  *ctx += 2;
}

#if __cplusplus
 #define MYBOOL bool
#else
  #define MYBOOL _Bool
#endif

SWIFTASYNCCALL void async_branch(MYBOOL b, char * ASYNC_CONTEXT ctx) {
  if (b) {
 return async_leaf1(ctx);
  } else {
    return async_leaf2(ctx);
 }
}

SWIFTASYNCCALL void async_not_all_tail(char * ASYNC_CONTEXT ctx) {
 async_leaf1(ctx);
  return async_leaf2(ctx);
}

SWIFTASYNCCALL void async_loop(unsigned u, char * ASYNC_CONTEXT ctx) {
  if (u == 0) {
 return async_leaf1(ctx);
  } else if (u == 1) {
    return async_leaf2(ctx);
  }
  return async_loop(u - 2, ctx);
}

SWIFTASYNCCALL void async_mutual_loop2(unsigned u, char * ASYNC_CONTEXT ctx) __attribute__((noreturn));

SWIFTASYNCCALL void async_mutual_loop1(unsigned u, char * ASYNC_CONTEXT ctx) {
  if (u == 0) {
    return async_leaf1(ctx);
  } else if (u == 1) {
    return async_leaf2(ctx);
 }
  return async_mutual_loop2(u - 2, ctx);
}

SWIFTASYNCCALL void async_mutual_loop2(unsigned u, char * ASYNC_CONTEXT ctx) {
  if (u == 0) {
 return async_leaf1(ctx);
  } else if (u == 1) {
    return async_leaf2(ctx);
  }
  return async_mutual_loop1(u - 2, ctx);
}

SWIFTCALL char sync_calling_async(MYBOOL b, unsigned u) {
  char x = 'a';
  async_branch(b, &x);
  async_loop(u, &x);
  return x;
}

char __attribute__ ((noipa)) c_calling_async(MYBOOL b, unsigned u) {
  char x = 'a';
  async_branch(b, &x);
  async_loop(u, &x);
  return x;
}

#if __cplusplus
struct S {
  SWIFTASYNCCALL void (*fptr)(char * ASYNC_CONTEXT);

  SWIFTASYNCCALL void async_leaf_method(char * ASYNC_CONTEXT ctx) {
    *ctx += 1;
  }
  SWIFTASYNCCALL void async_nonleaf_method1(char * ASYNC_CONTEXT ctx) {
    return async_leaf_method(ctx);
  }
  SWIFTASYNCCALL void async_nonleaf_method2(char * ASYNC_CONTEXT ctx) {
    return this->async_leaf_method(ctx);
  }
};

SWIFTASYNCCALL void (S::*async_leaf_method_ptr)(char * ASYNC_CONTEXT) = &S::async_leaf_method;

SWIFTASYNCCALL void async_struct_field_and_methods(int i, S &sref, S *sptr) {
  char x = 'a';
 if (i == 0) {
    return (*sref.fptr)(&x);
  } else if (i == 1) {
 return sref.async_nonleaf_method1(&x);
  } else if (i == 2) {
    return (*(sptr->fptr))(&x);
  } else if (i == 3) {
    return sptr->async_nonleaf_method2(&x);
  } else if (i == 4) {
    return (sref.*async_leaf_method_ptr)(&x);
  }
  return (sptr->*async_leaf_method_ptr)(&x);
}

#endif
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWktz2zgS_jXwBSUXCVIUdfCBlu2ZTDmTVOSZ2TmxQBCUsYEALgD6MYf89i0ApPiwZCtZZVK7m4ptiWx0f_1Ad-OBtWYbQekFmF-C-dUZbsy9VBcFS8hZIcvni5Xc1oxTBa-fai4VVSDK4L0xtQZRBtANQDcbWRaSm3OpNgDd_GV_3n9cRon-iYIgA0ng_xMptOTuUbTSslGEgugaRNl8bn9Zvo9YCSY29mPVCGKYFBCgBdbPguTbxjSY51zKGgG0gCUlHCtaWgohFTWNEva5vpcNL6GQBvqHEMwvZ38w8YA5K2c70vkVCDII4XwOwWIF7b-W3svjFFchQCkxTwAtQXTpySF05GB-vUeTxY_VZHFYE3RQE_d3rzZLEGXRj9Nm2cIb6TKQZp3TwBlEAK3gSDc_bq9SiVUKoYlWjfgs5KOA2BjFisZQD57V2CJnGwuu9Hhb0tmOVO8QJx4xuccK5vmOIM8hQClAactwCdASkpxgzpnY5E4vgNL3f15--HALC6tNI9y0LGFjacHiRex9-fLlCwiybaONwYxDywzab7BWlNCSQmztBh-ZuYdYQFlbp2EOC2YI1sbxG4_Wj6xyXwmBD5KVEMTBPg-nLEJQyEaUtIIAzXXjINdG7Z46Vm6sJVg4HVDk_ARQWBYb-ycM5iDIKmwwh1Qp6TKL-wCZgAUmn6ko7bNLJT9TAbeybDiFlZXhPO4yE3bBiAupDC0BCkGQfby9ztbXUDfFlhmIYdFsoKK1VAYaOc1dzNw3xTmRW4BuOH_o_sxqJf9JiQHohmndUA3QDcSihEwQ3pQUmnsKicL63iE1ChPqrK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