edA-qa mort-ora-y
2013-Nov-09 11:47 UTC
[LLVMdev] Error "Cannot emit physreg copy instruction"
I'm getting an error that I don't know how to fix. I've isolated the input as much as I easily can. I've attached the file that produces the problem. Just calling "llc err.ll -o err.s" generates the error. I'm going to try and isolate even further, but as I'm not sure what I'm looking for I don't know if I'll be successful. Does anybody know what this error means? Cannot emit physreg copy instruction UNREACHABLE executed at X86InstrInfo.cpp:2899! 0 libLLVM-3.3.so 0x00007f9f68ddf642 llvm::sys::PrintStackTrace(_IO_FILE*) + 34 1 libLLVM-3.3.so 0x00007f9f68dde9a9 2 libpthread.so.0 0x00007f9f67a07cb0 3 libc.so.6 0x00007f9f67156425 gsignal + 53 4 libc.so.6 0x00007f9f67159b8b abort + 379 5 libLLVM-3.3.so 0x00007f9f68dc1e7c 6 libLLVM-3.3.so 0x00007f9f68fd1832 llvm::X86InstrInfo::copyPhysReg(llvm::MachineBasicBlock&, llvm::MachineBasicBlock::bundle_iterator<llvm::MachineInstr, llvm::ilist_iterator<llvm::MachineInstr> >, llvm::DebugLoc, unsigned int, unsigned int, bool) const + 1762 7 libLLVM-3.3.so 0x00007f9f683afab1 8 libLLVM-3.3.so 0x00007f9f6864c417 llvm::FPPassManager::runOnFunction(llvm::Function&) + 487 9 libLLVM-3.3.so 0x00007f9f6864c50b llvm::FPPassManager::runOnModule(llvm::Module&) + 43 10 libLLVM-3.3.so 0x00007f9f6864beff llvm::MPPassManager::runOnModule(llvm::Module&) + 559 11 libLLVM-3.3.so 0x00007f9f6864c165 llvm::PassManagerImpl::run(llvm::Module&) + 245 12 llc 0x000000000040d217 13 llc 0x0000000000409a58 main + 360 14 libc.so.6 0x00007f9f6714176d __libc_start_main + 237 15 llc 0x0000000000409ae1 Stack dump: 0. Program arguments: /opt/llvm/install/bin/llc err.ll -o err.s 1. Running pass 'Function Pass Manager' on module 'err.ll'. 2. Running pass 'Post-RA pseudo instruction expansion pass' on function '@junk___init_module_get_args_3' -- edA-qa mort-ora-y -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Sign: Please digitally sign your emails. Encrypt: I'm also happy to receive encrypted mail. -------------- next part -------------- ; ModuleID = 'test' %0 = type { i64, void (i8*)*, i1 (i8*)*, i8*, i8* } %junk__range_iter = type { i1 (i8*)* } @junk__construct_range_iter = global void (i8*)* undef @junk__get_args = internal global i8* ()* undef declare i64 @leaf_exception_personality(i64, i32, i64, i8*, i8*) declare i8* @count_malloc(i64) declare void @_void_destructor(i8*) declare void @leaf_rethrow(i8*) ; Function Attrs: uwtable define internal void @_release_Au32a(i8**) #0 { entry: ret void } ; Function Attrs: uwtable define internal void @_release_C0PpRbrc(%0**) #0 { entry: ret void } ; Function Attrs: uwtable define internal i8* @junk___init_module_get_args_3() #0 { entry: %_return_path = alloca i8 store i8 0, i8* %_return_path %_exception = alloca { i8*, i64 } %_return_val = alloca i8* %junk__a = alloca %junk__range_iter %cond_result = alloca i1 %0 = call i8* @count_malloc(i64 16) %1 = bitcast i8* %0 to i64* store i64 0, i64* %1 store i8* %0, i8** %_return_val br label %defer_error_body_3 func_ret_0: ; preds = %loop_end_6 %2 = load i8** %_return_val ret i8* %2 defer_error_end_1: ; preds = %defer_error_block_2 br label %rethrow_19 defer_error_block_2: ; preds = %defer_cont_10, %defer_error_land_4 %return_path_3 = load i8* %_return_path store i8 0, i8* %_return_path call void @_release_Au32a(i8** %_return_val) store i8 %return_path_3, i8* %_return_path br label %defer_error_end_1 defer_error_body_3: ; preds = %entry %3 = load void (i8*)** @junk__construct_range_iter %4 = bitcast %junk__range_iter* %junk__a to i8* invoke void %3(i8* %4) to label %post_call_5 unwind label %defer_error_land_4 defer_error_land_4: ; preds = %defer_block_11, %loop_cond_7, %defer_error_body_3 %5 = landingpad { i8*, i64 } personality i64 (i64, i32, i64, i8*, i8*)* @leaf_exception_personality cleanup store { i8*, i64 } %5, { i8*, i64 }* %_exception store i8 4, i8* %_return_path br label %defer_error_block_2 post_call_5: ; preds = %defer_error_body_3 br label %loop_cond_7 loop_end_6: ; preds = %defer_end_9 br label %func_ret_0 loop_cond_7: ; preds = %loop_body_16, %post_call_5 %6 = load %junk__range_iter* %junk__a %7 = extractvalue %junk__range_iter %6, 0 %8 = invoke i8* @count_malloc(i64 40) to label %post_call_8 unwind label %defer_error_land_4 post_call_8: ; preds = %loop_cond_7 %9 = bitcast i8* %8 to %0* %ref_count_4 = getelementptr inbounds %0* %9, i32 0, i32 0 store i64 1, i64* %ref_count_4 %func_ptr_5 = getelementptr inbounds %0* %9, i32 0, i32 2 store i1 (i8*)* %7, i1 (i8*)** %func_ptr_5 %10 = bitcast %junk__range_iter* %junk__a to i8* %ctx_data_6 = getelementptr inbounds %0* %9, i32 0, i32 3 store i8* %10, i8** %ctx_data_6 %dtor_7 = getelementptr inbounds %0* %9, i32 0, i32 1 store void (i8*)* @_void_destructor, void (i8*)** %dtor_7 %11 = alloca %0* store %0* %9, %0** %11 br label %defer_body_12 defer_end_9: ; preds = %defer_cont_10, %defer_cont_10 %12 = load i1* %cond_result br i1 %12, label %loop_body_16, label %loop_end_6 defer_cont_10: ; preds = %post_call_14 %return_path_14 = load i8* %_return_path switch i8 %return_path_14, label %defer_end_9 [ i8 0, label %defer_end_9 i8 4, label %defer_error_block_2 ] defer_block_11: ; preds = %post_call_15, %defer_land_13 %return_path_8 = load i8* %_return_path store i8 0, i8* %_return_path invoke void @_release_C0PpRbrc(%0** %11) to label %post_call_14 unwind label %defer_error_land_4 defer_body_12: ; preds = %post_call_8 %13 = getelementptr inbounds %0* %9, i32 0, i32 3 %ctx_gptr_9 = load i8** %13 %14 = getelementptr inbounds %0* %9, i32 0, i32 2 %func_ptr_11 = load i1 (i8*)** %14 %15 = invoke i1 %func_ptr_11(i8* %ctx_gptr_9) to label %post_call_15 unwind label %defer_land_13 defer_land_13: ; preds = %defer_body_12 %16 = landingpad { i8*, i64 } personality i64 (i64, i32, i64, i8*, i8*)* @leaf_exception_personality cleanup store { i8*, i64 } %16, { i8*, i64 }* %_exception store i8 4, i8* %_return_path br label %defer_block_11 post_call_14: ; preds = %defer_block_11 store i8 %return_path_8, i8* %_return_path br label %defer_cont_10 post_call_15: ; preds = %defer_body_12 store i1 %15, i1* %cond_result br label %defer_block_11 loop_body_16: ; preds = %defer_end_9 br label %loop_cond_7 loop_next_17: ; No predecessors! unreachable loop_break_18: ; No predecessors! unreachable rethrow_19: ; preds = %defer_error_end_1 %lpad_result_12 = load { i8*, i64 }* %_exception %except_13 = extractvalue { i8*, i64 } %lpad_result_12, 0 call void @leaf_rethrow(i8* %except_13) unreachable }
edA-qa mort-ora-y
2013-Nov-09 12:53 UTC
[LLVMdev] Error "Cannot emit physreg copy instruction"
I've reduced the example down to a minimum. The error is quite perplexing since the IR appears fine. It is a nonsensical infinite loop now, but that shouldn't be a problem. declare i64 @leaf_exception_personality(i64, i32, i64, i8*, i8*) declare i8* @count_malloc(i64) define internal i8 @junk___init_module_get_args_3() #0 { entry: %_exception = alloca { i8*, i64 } %ignore0 = invoke i8* @count_malloc(i64 10) to label %loop_cond_7 unwind label %defer_error_land_4 defer_error_land_4: %lpres = landingpad { i8*, i64 } personality i64 (i64, i32, i64, i8*, i8*)* @leaf_exception_personality cleanup store { i8*, i64 } %lpres, { i8*, i64 }* %_exception ret i8 0 loop_cond_7: %ignore1 = invoke i8* @count_malloc(i64 40) to label %loop_cond_7 unwind label %defer_error_land_4 } On 09/11/13 12:47, edA-qa mort-ora-y wrote:> I'm getting an error that I don't know how to fix. I've isolated the > input as much as I easily can. I've attached the file that produces the > problem. Just calling "llc err.ll -o err.s" generates the error. > > I'm going to try and isolate even further, but as I'm not sure what I'm > looking for I don't know if I'll be successful. Does anybody know what > this error means? > > Cannot emit physreg copy instruction > UNREACHABLE executed at X86InstrInfo.cpp:2899! > 0 libLLVM-3.3.so 0x00007f9f68ddf642 > llvm::sys::PrintStackTrace(_IO_FILE*) + 34 > 1 libLLVM-3.3.so 0x00007f9f68dde9a9 > 2 libpthread.so.0 0x00007f9f67a07cb0 > 3 libc.so.6 0x00007f9f67156425 gsignal + 53 > 4 libc.so.6 0x00007f9f67159b8b abort + 379 > 5 libLLVM-3.3.so 0x00007f9f68dc1e7c > 6 libLLVM-3.3.so 0x00007f9f68fd1832 > llvm::X86InstrInfo::copyPhysReg(llvm::MachineBasicBlock&, > llvm::MachineBasicBlock::bundle_iterator<llvm::MachineInstr, > llvm::ilist_iterator<llvm::MachineInstr> >, llvm::DebugLoc, unsigned > int, unsigned int, bool) const + 1762 > 7 libLLVM-3.3.so 0x00007f9f683afab1 > 8 libLLVM-3.3.so 0x00007f9f6864c417 > llvm::FPPassManager::runOnFunction(llvm::Function&) + 487 > 9 libLLVM-3.3.so 0x00007f9f6864c50b > llvm::FPPassManager::runOnModule(llvm::Module&) + 43 > 10 libLLVM-3.3.so 0x00007f9f6864beff > llvm::MPPassManager::runOnModule(llvm::Module&) + 559 > 11 libLLVM-3.3.so 0x00007f9f6864c165 > llvm::PassManagerImpl::run(llvm::Module&) + 245 > 12 llc 0x000000000040d217 > 13 llc 0x0000000000409a58 main + 360 > 14 libc.so.6 0x00007f9f6714176d __libc_start_main + 237 > 15 llc 0x0000000000409ae1 > Stack dump: > 0. Program arguments: /opt/llvm/install/bin/llc err.ll -o err.s > 1. Running pass 'Function Pass Manager' on module 'err.ll'. > 2. Running pass 'Post-RA pseudo instruction expansion pass' on function > '@junk___init_module_get_args_3' > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- edA-qa mort-ora-y -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Sign: Please digitally sign your emails. Encrypt: I'm also happy to receive encrypted mail.
edA-qa mort-ora-y
2013-Nov-09 15:45 UTC
[LLVMdev] Error "Cannot emit physreg copy instruction"
I can make the problem go away, but perhaps there is still an issue in LLVM. At least a missing assert somewhere. It's strange that only this very particular structure causes the failure. If I change the personality routine return value to i32 from i64 then it works. On 09/11/13 13:53, edA-qa mort-ora-y wrote:> I've reduced the example down to a minimum. The error is quite > perplexing since the IR appears fine. It is a nonsensical infinite loop > now, but that shouldn't be a problem. > > declare i64 @leaf_exception_personality(i64, i32, i64, i8*, i8*) > > declare i8* @count_malloc(i64) > > define internal i8 @junk___init_module_get_args_3() #0 { > entry: > %_exception = alloca { i8*, i64 } > %ignore0 = invoke i8* @count_malloc(i64 10) > to label %loop_cond_7 unwind label %defer_error_land_4 > > defer_error_land_4: > %lpres = landingpad { i8*, i64 } personality i64 (i64, i32, i64, i8*, > i8*)* @leaf_exception_personality > cleanup > store { i8*, i64 } %lpres, { i8*, i64 }* %_exception > ret i8 0 > > loop_cond_7: > %ignore1 = invoke i8* @count_malloc(i64 40) > to label %loop_cond_7 unwind label %defer_error_land_4 > } > > > On 09/11/13 12:47, edA-qa mort-ora-y wrote: >> I'm getting an error that I don't know how to fix. I've isolated the >> input as much as I easily can. I've attached the file that produces the >> problem. Just calling "llc err.ll -o err.s" generates the error. >> >> I'm going to try and isolate even further, but as I'm not sure what I'm >> looking for I don't know if I'll be successful. Does anybody know what >> this error means? >> >> Cannot emit physreg copy instruction >> UNREACHABLE executed at X86InstrInfo.cpp:2899! >> 0 libLLVM-3.3.so 0x00007f9f68ddf642 >> llvm::sys::PrintStackTrace(_IO_FILE*) + 34 >> 1 libLLVM-3.3.so 0x00007f9f68dde9a9 >> 2 libpthread.so.0 0x00007f9f67a07cb0 >> 3 libc.so.6 0x00007f9f67156425 gsignal + 53 >> 4 libc.so.6 0x00007f9f67159b8b abort + 379 >> 5 libLLVM-3.3.so 0x00007f9f68dc1e7c >> 6 libLLVM-3.3.so 0x00007f9f68fd1832 >> llvm::X86InstrInfo::copyPhysReg(llvm::MachineBasicBlock&, >> llvm::MachineBasicBlock::bundle_iterator<llvm::MachineInstr, >> llvm::ilist_iterator<llvm::MachineInstr> >, llvm::DebugLoc, unsigned >> int, unsigned int, bool) const + 1762 >> 7 libLLVM-3.3.so 0x00007f9f683afab1 >> 8 libLLVM-3.3.so 0x00007f9f6864c417 >> llvm::FPPassManager::runOnFunction(llvm::Function&) + 487 >> 9 libLLVM-3.3.so 0x00007f9f6864c50b >> llvm::FPPassManager::runOnModule(llvm::Module&) + 43 >> 10 libLLVM-3.3.so 0x00007f9f6864beff >> llvm::MPPassManager::runOnModule(llvm::Module&) + 559 >> 11 libLLVM-3.3.so 0x00007f9f6864c165 >> llvm::PassManagerImpl::run(llvm::Module&) + 245 >> 12 llc 0x000000000040d217 >> 13 llc 0x0000000000409a58 main + 360 >> 14 libc.so.6 0x00007f9f6714176d __libc_start_main + 237 >> 15 llc 0x0000000000409ae1 >> Stack dump: >> 0. Program arguments: /opt/llvm/install/bin/llc err.ll -o err.s >> 1. Running pass 'Function Pass Manager' on module 'err.ll'. >> 2. Running pass 'Post-RA pseudo instruction expansion pass' on function >> '@junk___init_module_get_args_3' >> >> >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > >-- edA-qa mort-ora-y -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Sign: Please digitally sign your emails. Encrypt: I'm also happy to receive encrypted mail.
Cameron McInally
2013-Nov-09 15:51 UTC
[LLVMdev] Error "Cannot emit physreg copy instruction"
Hey edA-qa mort-ora-y, On Sat, Nov 9, 2013 at 6:47 AM, edA-qa mort-ora-y <eda-qa at disemia.com> wrote:> I'm getting an error that I don't know how to fix. I've isolated the > input as much as I easily can. I've attached the file that produces the > problem. Just calling "llc err.ll -o err.s" generates the error. > > I'm going to try and isolate even further, but as I'm not sure what I'm > looking for I don't know if I'll be successful. Does anybody know what > this error means? > > Cannot emit physreg copy instruction > UNREACHABLE executed at X86InstrInfo.cpp:2899! > 0 libLLVM-3.3.so 0x00007f9f68ddf642 > llvm::sys::PrintStackTrace(_IO_FILE*) + 34 > 1 libLLVM-3.3.so 0x00007f9f68dde9a9 > 2 libpthread.so.0 0x00007f9f67a07cb0 > 3 libc.so.6 0x00007f9f67156425 gsignal + 53 > 4 libc.so.6 0x00007f9f67159b8b abort + 379 > 5 libLLVM-3.3.so 0x00007f9f68dc1e7c > 6 libLLVM-3.3.so 0x00007f9f68fd1832 > llvm::X86InstrInfo::copyPhysReg(llvm::MachineBasicBlock&, > llvm::MachineBasicBlock::bundle_iterator<llvm::MachineInstr, > llvm::ilist_iterator<llvm::MachineInstr> >, llvm::DebugLoc, unsigned > int, unsigned int, bool) const + 1762 > 7 libLLVM-3.3.so 0x00007f9f683afab1 > 8 libLLVM-3.3.so 0x00007f9f6864c417 > llvm::FPPassManager::runOnFunction(llvm::Function&) + 487 > 9 libLLVM-3.3.so 0x00007f9f6864c50b > llvm::FPPassManager::runOnModule(llvm::Module&) + 43 > 10 libLLVM-3.3.so 0x00007f9f6864beff > llvm::MPPassManager::runOnModule(llvm::Module&) + 559 > 11 libLLVM-3.3.so 0x00007f9f6864c165 > llvm::PassManagerImpl::run(llvm::Module&) + 245 > 12 llc 0x000000000040d217 > 13 llc 0x0000000000409a58 main + 360 > 14 libc.so.6 0x00007f9f6714176d __libc_start_main + 237 > 15 llc 0x0000000000409ae1 > Stack dump: > 0. Program arguments: /opt/llvm/install/bin/llc err.ll -o err.s > 1. Running pass 'Function Pass Manager' on module 'err.ll'. > 2. Running pass 'Post-RA pseudo instruction expansion pass' on function > '@junk___init_module_get_args_3' > > -- > edA-qa mort-ora-yI agree that this is an especially hard issue to diagnose, as I have had issues with it in the recent past. At that time, I was not able to find a good way to trace the COPY pseudo to a particular statement in the IR. But, I digress... The UNREACHABLE you are hitting comes from X86InstrInfo::copyPhysReg(...) in llvm/lib/Target/X86/X86InstrInfo.cpp. You're expanding a pseudo COPY instruction, but the x86 target does not know how to produce a reg-reg move that matches the problematic COPY instruction. To find the COPY instruction that is the problem, try compiling with -debug. You should see a statement, "Cannot copy...", which will give you the details of the failing instruction. I have also tried the test cases that you supplied, but was not able to reproduce the error with ToT. What cpu target are you looking at? -Cameron
edA-qa mort-ora-y
2013-Nov-09 16:00 UTC
[LLVMdev] Error "Cannot emit physreg copy instruction"
On 09/11/13 16:51, Cameron McInally wrote:> I have also tried the test cases that you supplied, but was not able > to reproduce the error with ToT. What cpu target are you looking at?I am targeting Linux x86_64 with LLVM 3.3. I found the problem was the "store" instruction for the landingpad result. I don't understand why it was a problem but I have it "corrected" now (switch i64 to i32 result). -- edA-qa mort-ora-y -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Sign: Please digitally sign your emails. Encrypt: I'm also happy to receive encrypted mail.
Maybe Matching Threads
- [LLVMdev] Error "Cannot emit physreg copy instruction"
- [LLVMdev] post-link Dwarf information appears wrong, works in JIT
- [LLVMdev] object file/linking is missing my exception handlers
- [LLVMdev] post-link Dwarf information appears wrong, works in JIT
- [LLVMdev] object file/linking is missing my exception handlers