Hi, all I have a trouble with calling external functions on PowerPC. What I am doing is generating a LLVM IR first like this, - x86 call void @helper_shack_flush(%struct.CPUX86State* %62) noinline, !flags !12 - ppc call void @helper_shack_flush(%struct.CPUX86State* %62) noinline, !flags !10 After lowering above LLVM IR for x86 and ppc, it becomes: - x86 %RAX<def> = MOV64ri <ga:@helper_shack_flush> %RDI<def> = COPY %RBX CALL64r %RAX<kill>, %RDI<kill>, %RAX<imp-def,dead>, %RCX<imp-def,dead>, %RDX<imp-def,dead>, %RSI<imp-def,dead>, %%RDI<imp-def,dead>, %R8<imp-def,dead>, %EFLAGS<imp-def,dead>, %RSP<imp-use>, ... - ppc %X4<def> = LDtoc <ga:@helper_shack_flush>, %X2 The x86 JIT can call the external function correctly, but the ppc JIT give me the error belows, %X4<def> = LDtoc <ga:@helper_shack_flush>, %X2 UNREACHABLE executed! Stack dump: 0. Running pass 'PowerPC Machine Code Emitter' on function '@"8048150"' Aborted Is this a bug in ppc JIT? Or I have to do something else so that ppc JIT can call external functions? Thanks! Regards, chenwj -- Wei-Ren Chen (陳韋任) Parallel Processing Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667
Hi, all I found the example code examples/HowToUseJIT.cpp also shows the same error. Attachment is the LLVM module created by HowToUseJIT. And here is the error, Running foo: %X4<def> = LDtoc <ga:@add1>, %X2 UNREACHABLE executed! Stack dump: 0. Running pass 'PowerPC Machine Code Emitter' on function '@foo' Aborted Currently, I use gdb try to track down where the problem is. Here is the backtrace, (gdb) bt #0 0x00000fffb7b84090 in .raise () from /lib/libc.so.6 #1 0x00000fffb7b85ca4 in .abort () from /lib/libc.so.6 #2 0x0000000010517b9c in ._ZN4llvm25llvm_unreachable_internalEPKcS1_j () #3 0x0000000010047aa0 in ._ZN12_GLOBAL__N_114PPCCodeEmitter17getMachineOpValueERKN4llvm12MachineInstrERKNS1_14MachineOperandE () #4 0x0000000010048ff4 in ._ZN12_GLOBAL__N_114PPCCodeEmitter14emitBasicBlockERN4llvm17MachineBasicBlockE () #5 0x000000001004940c in ._ZN12_GLOBAL__N_114PPCCodeEmitter20runOnMachineFunctionERN4llvm15MachineFunctionE () #6 0x00000000101f26f4 in ._ZN4llvm19MachineFunctionPass13runOnFunctionERNS_8FunctionE () #7 0x00000000104b8634 in ._ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE () #8 0x00000000104b883c in ._ZN4llvm23FunctionPassManagerImpl3runERNS_8FunctionE () #9 0x00000000104b8b1c in ._ZN4llvm19FunctionPassManager3runERNS_8FunctionE () #10 0x0000000010020f64 in ._ZN4llvm3JIT14jitTheFunctionEPNS_8FunctionERKNS_10MutexGuardE () #11 0x0000000010021314 in ._ZN4llvm3JIT24runJITOnFunctionUnlockedEPNS_8FunctionERKNS_10MutexGuardE () #12 0x000000001002155c in ._ZN4llvm3JIT20getPointerToFunctionEPNS_8FunctionE () #13 0x00000000100236e4 in ._ZN4llvm3JIT11runFunctionEPNS_8FunctionERKSt6vectorINS_12GenericValueESaIS4_EE () #14 0x000000001000918c in main () at HowToUseJIT.cpp:116 Any idea how can I further spot where is the bug? Thanks! Regards, chenwj -- Wei-Ren Chen (陳韋任) Parallel Processing Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667
Forgot the attachment, sorry. -- Wei-Ren Chen (陳韋任) Parallel Processing Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667 -------------- next part -------------- ; ModuleID = 'test' define i32 @add1(i32 %AnArg) { EntryBlock: %addresult = add i32 1, %AnArg ret i32 %addresult } define i32 @foo() { EntryBlock: %add1 = tail call i32 @add1(i32 10) ret i32 %add1 } declare void @abort()
Hi, folks I saw the comments at the top of PowerPC/PPCCodeEmitter.cpp, the ppc JIT is for PowerPC32 machine. But I am running a PowerPC64 machine. Could it be the reason why the ppc JIT cannot call external functions? Thanks! Regards, chenwj -- Wei-Ren Chen (陳韋任) Parallel Processing Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667
Hi, all> I found the example code examples/HowToUseJIT.cpp also shows > the same error.At the end of inserting instruction into the Module created in HowToUseJIT.cpp, I call function verifyModule to verify if everything is O.K.. This time, it gave me much readable output, Running foo: HowToUseJIT: /tmp/chenwj/llvm-2.8/lib/Target/PowerPC/PPCCodeEmitter.cpp:156: unsigned int<unnamed>::PPCCodeEmitter::getMachineOpValue(const llvm::MachineInstr&, const llvm::MachineOperand&): Assertion `MovePCtoLROffset && "MovePCtoLR not seen yet?"' failed. Stack dump: 0. Running pass 'PowerPC Machine Code Emitter' on function '@foo' Aborted The assert comes from PPCCodeEmitter.cpp. if (TM.getRelocationModel() == Reloc::PIC_) { assert(MovePCtoLROffset && "MovePCtoLR not seen yet?"); } Which direction I should look into? Thanks! Regards, chenwj -- Wei-Ren Chen (陳韋任) Computer System Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667
Possibly Parallel Threads
- [LLVMdev] Calling external functions failed on PowerPC
- [LLVMdev] PowerPC : Assertion `MovePCtoLROffset && "MovePCtoLR not seen yet?"' failed.
- [LLVMdev] PowerPC : Assertion `MovePCtoLROffset && "MovePCtoLR not seen yet?"' failed.
- [LLVMdev] PowerPC : Assertion `MovePCtoLROffset & & " MovePCtoLR not seen yet?" ' failed.
- [LLVMdev] PowerPC : Assertion `MovePCtoLROffset & & " MovePCtoLR not seen yet?" ' failed.