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

    <tr>
        <th>Summary</th>
        <td>
            error in backend: Cannot select X86ISD::CALL for function pointer with __ptr32
        </td>
    </tr>

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

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

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

<pre>
    LLVM crashes in back-end for a function pointer with __ptr32 MS qualifier, cannot select CALL instruction.
Below is the C++ example:
```
int func1(const char* __ptr32 chp)

    return 0;
}

typedef int (* __ptr32 PF)(const char* __ptr32);
PF call = func1;

int main()
{  
  call("Hello, there!");

  return 0;
}
```
Run **X86-64 clang (trunk)** with the following command:
`clang example.cpp -S -fms-extensions`

```
fatal error: error in backend: Cannot select: 0x555f9f3a01d0: ch,glue = X86ISD::CALL 0x555f9f3a0100, 0x555f9f39fe28, Register:i64 $rdi, RegisterMask:Untyped, 0x555f9f3a0100:1, example.cpp:12:3
  0x555f9f39fe28: i32,ch = CopyFromReg 0x555f9f216278, Register:i32 %1, example.cpp:12:3
    0x555f9f39fdc0: i32 = Register %1
  0x555f9f3a0098: i64 = Register $rdi
  0x555f9f3a0168: Untyped = RegisterMask
  0x555f9f3a0100: ch,glue = CopyToReg 0x555f9f39ffc8, Register:i64 $rdi, 0x555f9f3a0440, example.cpp:12:3
    0x555f9f3a0098: i64 = Register $rdi
    0x555f9f3a0440: i64 = and 0x555f9f3a03d8, Constant:i64<4294967295>, example.cpp:12:3
      0x555f9f3a03d8: i64 = X86ISD::WrapperRIP TargetGlobalAddress:i64<ptr @.str> 0, example.cpp:12:3
        0x555f9f39fef8: i64 = TargetGlobalAddress<ptr @.str> 0, example.cpp:12:3
      0x555f9f39fe90: i64 = Constant<4294967295>
In function: main
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 -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -fms-extensions <source>
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '<source>'.
4.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@main'
 #0 0x0000555f9790342f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000555f97901224 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3701224)
 #2 0x0000555f97843602 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3643602)
 #3 0x0000555f978f9f5e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x36f9f5e)
 #4 0x0000555f95443616 (/opt/compiler-explorer/clang-trunk/bin/clang+++0x1243616)
 #5 0x0000555f9784ae2f llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x364ae2f)
 #6 0x0000555f987fa306 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45fa306)
 #7 0x0000555f987fd2f2 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45fd2f2)
 #8 0x0000555f96554dc7 (anonymous namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) X86ISelDAGToDAG.cpp:0:0
 #9 0x0000555f987f8e64 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45f8e64)
#10 0x0000555f98800ac6 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4600ac6)
#11 0x0000555f98803f12 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4603f12)
#12 0x0000555f9880635f llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.944) SelectionDAGISel.cpp:0:0
#13 0x0000555f9655cf20 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#14 0x0000555f96c2b548 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2a2b548)
#15 0x0000555f970aa0c9 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2eaa0c9)
#16 0x0000555f970aa361 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2eaa361)
#17 0x0000555f970aae07 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2eaae07)
#18 0x0000555f97c64032 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a64032)
#19 0x0000555f9891edef clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x471edef)
#20 0x0000555f9986c2a9 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x566c2a9)
#21 0x0000555f9891f88d clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x471f88d)
#22 0x0000555f982f8561 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x40f8561)
#23 0x0000555f98290c02 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4090c02)
#24 0x0000555f983c7003 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x41c7003)
#25 0x0000555f95445154 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x1245154)
#26 0x0000555f9543de9d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#27 0x0000555f98121915 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#28 0x0000555f97843493 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3643493)
#29 0x0000555f981239e8 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3f239e8)
#30 0x0000555f980f2013 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ef2013)
#31 0x0000555f980f2b53 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+++0x3ef2b53)
#32 0x0000555f980fbacf clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3efbacf)
#33 0x0000555f95442d4e clang_main(int, char**) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x1242d4e)
#34 0x00007fe14d0180b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b3)
#35 0x0000555f9543daaa _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0x123daaa)
clang-15: error: clang frontend command failed with exit code 70 (use -v to see invocation)
ASM generation compiler returned: 70

```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlWktz47gR_jXyBSUXCT5EHnyQZXvWKTvjsryb5KSCQFBihiK4IOnHv99ugJQISn7shJscMuWxJTy6v_7Q6G6AXMvk7eLu7rd7whWrtqIiWUHWjP-YiiIhqVSEkbQpeJ3JgpQyK2qhyEtWb8lqVdbKo-R-SX5vWJ6lmVATuiCcFYWsSSVywWuymN_dgciqVo2WcT5xribO_FLk8oVkFam3giwm9BJ-iHhluzIXE29uBk1Cp_3RX0G3huJOaMQliCR8y0DlfA-Fb8sJjdvJs0tiPhH4p0TdqII4E--y675qP-jf9VspEpES1AHi-0IfblDmOyqxqxP5cAO25zmZeFctzr2yPf4dywotv4dyDxNn6076i8hziWQCPUpMKJhsqepmfGCWzd1jU4Bdc_j5ZxROQ5_wnBUbNBUWpvihLcRes7S4KKkECC8ZDOJyt2NF0l8WM7tdr3NelmS6JNN0V03Fay2KCha62us-CShlNcuJUEoqEGw-dK4ntDKy6DsSNjivQRCkceoxx00cbOFbIGmTN0KTDqbdLq8QpzfXftef4DjI574lTgUyvSCPYpNV4NQwJwNeJtRXSdbvuGfVD-j8tdA-YgkxYr25i609NrCJwi-vW6eBWkCeoe8s-FYDX8jy7UbJHajcD6VuSGdHCMEfJzT4VJ-lMeFOq1Er68QZQUOAzHFiAxDJsIdrZo4nuKGe0BJkTdLcnZjhnFg9JOFJ9ikA7Cn_eJF6Qn3f-RO0fNVOMlTRmwKbot_rJRrrAuMEK2qDdeItfBr7cTijcTDxrj-HSIYyexr7Hv4PxcpSqMfbB_LE1EbU33K5Zvk8SZSoqr12C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