<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - 32-bit pointer address space crashes without addrspacecast"
   href="https://bugs.llvm.org/show_bug.cgi?id=45857">45857</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>32-bit pointer address space crashes without addrspacecast
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>dave@znu.io
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following C++ generated code crashes in the back end:

define hidden i32 @_Z7no_cast4Test(i32 addrspace(271)* nocapture readonly
%t.coerce) local_unnamed_addr #0 {
entry:
  %0 = load i32, i32 addrspace(271)* %t.coerce, align 4, !tbaa !2
  ret i32 %0
}

The workaround:

define hidden i32 @_Z4cast4Test(i32 addrspace(271)* nocapture readonly
%t.coerce) local_unnamed_addr #0 {
entry:
  %0 = addrspacecast i32 addrspace(271)* %t.coerce to i32*
  %1 = load i32, i32* %0, align 4, !tbaa !2
  ret i32 %1
}

Here is the crash:

fatal error: error in backend: Cannot emit physreg copy instruction
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /home/dave/b/l/d/bin/clang -fvisibility=hidden -O3
-fms-extensions -S -o - ptrt.cpp
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'ptrt.cpp'.
4.      Running pass 'Post-RA pseudo instruction expansion pass' on function
'@_Z7no_cast4Test'
 #0 0x00007fffefc92037 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/dave/s/l/llvm/lib/Support/Unix/Signals.inc:564:11
 #1 0x00007fffefc921d9 PrintStackTraceSignalHandler(void*)
/home/dave/s/l/llvm/lib/Support/Unix/Signals.inc:625:1
 #2 0x00007fffefc90a7b llvm::sys::RunSignalHandlers()
/home/dave/s/l/llvm/lib/Support/Signals.cpp:67:5
 #3 0x00007fffefc9195e llvm::sys::CleanupOnSignal(unsigned long)
/home/dave/s/l/llvm/lib/Support/Unix/Signals.inc:362:1
 #4 0x00007fffefae6b48 (anonymous
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long)
/home/dave/s/l/llvm/lib/Support/CrashRecoveryContext.cpp:77:20
 #5 0x00007fffefae6a68 llvm::CrashRecoveryContext::HandleExit(int)
/home/dave/s/l/llvm/lib/Support/CrashRecoveryContext.cpp:436:3
 #6 0x00007fffefc8b2ab llvm::sys::Process::Exit(int)
/home/dave/s/l/llvm/lib/Support/Process.cpp:96:10
 #7 0x000000000023709e (/home/dave/b/l/d/bin/clang+0x23709e)
 #8 0x00007fffefb0b7d4 llvm::report_fatal_error(llvm::Twine const&, bool)
/home/dave/s/l/llvm/lib/Support/ErrorHandling.cpp:108:5
 #9 0x00007fffefb0b722 /home/dave/s/l/llvm/lib/Support/ErrorHandling.cpp:83:3
#10 0x00007ffff7ee260d
(/home/dave/b/l/d/bin/../lib64/libLLVMX86CodeGen.so.11git+0x6a060d)
#11 0x00007ffff4c14091 (anonymous
namespace)::ExpandPostRA::LowerCopy(llvm::MachineInstr*)
/home/dave/s/l/llvm/lib/CodeGen/ExpandPostRAPseudos.cpp:169:7
#12 0x00007ffff4c134f6 (anonymous
namespace)::ExpandPostRA::runOnMachineFunction(llvm::MachineFunction&)
/home/dave/s/l/llvm/lib/CodeGen/ExpandPostRAPseudos.cpp:215:23
#13 0x00007ffff4e2a4f7
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
/home/dave/s/l/llvm/lib/CodeGen/MachineFunctionPass.cpp:73:8
#14 0x00007ffff059a38c llvm::FPPassManager::runOnFunction(llvm::Function&)
/home/dave/s/l/llvm/lib/IR/LegacyPassManager.cpp:1482:23
#15 0x00007ffff059a7b5 llvm::FPPassManager::runOnModule(llvm::Module&)
/home/dave/s/l/llvm/lib/IR/LegacyPassManager.cpp:1518:16
#16 0x00007ffff059af34 (anonymous
namespace)::MPPassManager::runOnModule(llvm::Module&)
/home/dave/s/l/llvm/lib/IR/LegacyPassManager.cpp:1583:23
#17 0x00007ffff059aa58 llvm::legacy::PassManagerImpl::run(llvm::Module&)
/home/dave/s/l/llvm/lib/IR/LegacyPassManager.cpp:1695:16
#18 0x00007ffff059b4d1 llvm::legacy::PassManager::run(llvm::Module&)
/home/dave/s/l/llvm/lib/IR/LegacyPassManager.cpp:1726:3
#19 0x00007ffff583ae1b (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::__1::unique_ptr<llvm::raw_pwrite_stream,
std::__1::default_delete<llvm::raw_pwrite_stream> >)
/home/dave/s/l/clang/lib/CodeGen/BackendUtil.cpp:950:3
#20 0x00007ffff5836e5b clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::__1::unique_ptr<llvm::raw_pwrite_stream,
std::__1::default_delete<llvm::raw_pwrite_stream> >)
/home/dave/s/l/clang/lib/CodeGen/BackendUtil.cpp:1655:5
#21 0x00007ffff5e29411
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
/home/dave/s/l/clang/lib/CodeGen/CodeGenAction.cpp:335:7
#22 0x00007fffeaf7991e clang::ParseAST(clang::Sema&, bool, bool)
/home/dave/s/l/clang/lib/Parse/ParseAST.cpp:178:12
#23 0x00007ffff2c3ebe2 clang::ASTFrontendAction::ExecuteAction()
/home/dave/s/l/clang/lib/Frontend/FrontendAction.cpp:1062:1
#24 0x00007ffff5e23eb9 clang::CodeGenAction::ExecuteAction()
/home/dave/s/l/clang/lib/CodeGen/CodeGenAction.cpp:1185:1
#25 0x00007ffff2c3e5b8 clang::FrontendAction::Execute()
/home/dave/s/l/clang/lib/Frontend/FrontendAction.cpp:957:7
#26 0x00007ffff2bb549f
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/dave/s/l/clang/lib/Frontend/CompilerInstance.cpp:973:23
#27 0x00007ffff63dc73e
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/dave/s/l/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:282:8
#28 0x0000000000236ae8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) /home/dave/s/l/clang/tools/driver/cc1_main.cpp:240:13
#29 0x0000000000229b32 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
/home/dave/s/l/clang/tools/driver/driver.cpp:330:5
#30 0x00007ffff26edc28
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__1::basic_string<char, std::__1::char_traits<char>,</span >
std::__1::allocator<char> >*, bool*) const::$_1::operator()() const
/home/dave/s/l/clang/lib/Driver/Job.cpp:417:34
#31 0x00007ffff26edbf5 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__1::basic_string<char, std::__1::char_traits<char>,</span >
std::__1::allocator<char> >*, bool*) const::$_1>(long)
/home/dave/s/l/llvm/include/llvm/ADT/STLExtras.h:185:5
#32 0x00007fffefad1d09 llvm::function_ref<void ()>::operator()() const
/home/dave/s/l/llvm/include/llvm/ADT/STLExtras.h:203:5
#33 0x00007fffefae6934
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
/home/dave/s/l/llvm/lib/Support/CrashRecoveryContext.cpp:419:3
#34 0x00007ffff26ed3d6
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__1::basic_string<char, std::__1::char_traits<char>,</span >
std::__1::allocator<char> >*, bool*) const
/home/dave/s/l/clang/lib/Driver/Job.cpp:417:7
#35 0x00007ffff268e1d2
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
/home/dave/s/l/clang/lib/Driver/Compilation.cpp:195:7
#36 0x00007ffff268e3bb
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&)
const /home/dave/s/l/clang/lib/Driver/Compilation.cpp:246:13
#37 0x00007ffff26ad55e
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&)
/home/dave/s/l/clang/lib/Driver/Driver.cpp:1483:7
#38 0x00000000002294d2 main /home/dave/s/l/clang/tools/driver/driver.cpp:502:9
#39 0x00007fffef4ba042 __libc_start_main (/lib64/libc.so.6+0x27042)
#40 0x00000000002284fe _start (/home/dave/b/l/d/bin/clang+0x2284fe)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>