[llvm-commits] [RFC] Patch 1/3 for the native code compiler of Erlang
Yiannis Tsiouris
gtsiour at softlab.ntua.gr
Sun May 13 15:31:00 PDT 2012
On 05/13/2012 07:51 PM, Jakob Stoklund Olesen wrote:
> On May 13, 2012, at 8:32 AM, Yiannis Tsiouris wrote:
>> Ping.
>>
>> Is there anything wrong with this patch?
> The patch doesn't apply cleanly, possibly because of the missing newline at the end of your test case.
>
> Here you check for a NULL Function:
>
> const Function *F = MF->getFunction();
> ghcCall = (F ? F->getCallingConv() == CallingConv::GHC : false);
> + hipeCall = (F ? F->getCallingConv() == CallingConv::HiPE : false);
>
> Here you don't:
>
> + if (MF.getFunction()->getCallingConv() == CallingConv::HiPE)
> + return &X86::GR32RegClass;
>
> /jakob
I attatch an updated patch for the Calling Convention.
However, we noticed one thing. In our our patch we define (among others)
a RetCC for HiPE 64 bit like this:
>+// X86-64 HiPE return-value convention.
>+def RetCC_X86_64_HiPE : CallingConv<[
>+ // Promote all types to i64
>+ CCIfType<[i8, i16, i32], CCPromoteToType<i64>>,
>+
>+ // Return: HP, P, VAL1, VAL2
>+ CCIfType<[i64], CCAssignToReg<[R15, RBP, RAX, RDX]>>
>+]>;
When trying to compile the attatched simple test the CCPromoteToType
attribute doesn't seem to work and the compilation fails with:
yiannist at greg [test/CodeGen/X86]>>= llc < test.ll -mtriple=x86_64-linux
.file "<stdin>"
Cannot emit physreg copy instruction
UNREACHABLE executed at X86InstrInfo.cpp:2487!
0 llc 0x0000000001452cb6
1 llc 0x0000000001452ab2
2 libpthread.so.0 0x00007fefd95ae030
3 libc.so.6 0x00007fefd88a7475 gsignal + 53
4 libc.so.6 0x00007fefd88aa6f0 abort + 384
5 llc 0x000000000143d8df
6 llc 0x0000000000cea6f1
llvm::X86InstrInfo::copyPhysReg(llvm::MachineBasicBlock&,
llvm::MachineBasicBlock::bundle_iterator<llvm::MachineInstr,
llvm::ilist_iterator<llvm::MachineInstr> >, llvm::DebugLoc, unsigned
int, unsigned int, bool) const + 1401
7 llc 0x00000000010ae4d1
8 llc 0x00000000010ae895
9 llc 0x0000000000fa1e51
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 95
10 llc 0x00000000013e085e
llvm::FPPassManager::runOnFunction(llvm::Function&) + 388
11 llc 0x00000000013e0a79
llvm::FPPassManager::runOnModule(llvm::Module&) + 107
12 llc 0x00000000013e0db9
llvm::MPPassManager::runOnModule(llvm::Module&) + 453
13 llc 0x00000000013e12b9
llvm::PassManagerImpl::run(llvm::Module&) + 125
14 llc 0x00000000013e146d
llvm::PassManager::run(llvm::Module&) + 39
15 llc 0x0000000000842e47 main + 3132
16 libc.so.6 0x00007fefd8893ead __libc_start_main + 253
17 llc 0x0000000000841b59
Stack dump:
0. Program arguments: llc
1. Running pass 'Function Pass Manager' on module '<stdin>'.
2. Running pass 'Post-RA pseudo instruction expansion pass' on
function '@test_nocall_hipecc'
zsh: abort llc < test.ll
I reproduced the problem by just adding a " CCIfType<[i8, i16, i32],
CCPromoteToType<i64>>," line in RetCC_X86Common in a vanilla LLVM tree
and trying to compile a simple function that uses i32 vregs without a
cc. Is this normal or a bug? I could try to fix it if this is the case.
Changing our RetCC to:
> // X86-64 HiPE return-value convention.
> def RetCC_X86_64_HiPE : CallingConv<[
>- // Promote all types to i64
>- CCIfType<[i8, i16, i32], CCPromoteToType<i64>>,
>+ CCIfType<[i8], CCAssignToReg<[R15B, BPL, AL, DL]>>,
>+ CCIfType<[i16], CCAssignToReg<[R15W, BP, AX, DX]>>,
>+ CCIfType<[i32], CCAssignToReg<[R15D, ESP, EAX, EDX]>>,
>
> // Return: HP, P, VAL1, VAL2
> CCIfType<[i64], CCAssignToReg<[R15, RBP, RAX, RDX]>>
seems to work as expected.
Best,
Yiannis
--
Yiannis Tsiouris
Ph.D. student,
Software Engineering Laboratory,
National Technical University of Athens
WWW: http://www.softlab.ntua.gr/~gtsiour
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.ll
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120514/d4c58882/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hipe-calling-conv.diff
Type: text/x-diff
Size: 12282 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120514/d4c58882/attachment.diff>
More information about the llvm-commits
mailing list