Martin J. O'Riordan via llvm-dev
2017-Sep-15 12:09 UTC
[llvm-dev] Changes to 'ADJCALLSTACK*' and 'callseq_*' between LLVM v4.0 and v5.0
Hi LLVM-Devs,
I have managed to complete updating our sources from LLVM v4.0 to v5.0, but
I am getting selection errors for 'callseq_end'. I am aware that the
'ADJCALLSTACKUP' and 'ADJCALLSTACKDOWN' patterns have changed,
and have
added an additional argument to the TD descriptions for these.
There are interactions with 'ISD::CALL' and 'ISD::RET_FLAG', but
so far as I
can tell I have revised these in the same way as the in-tree targets have
adjusted their sources.
The error I am seeing is:
fatal error: error in backend: Cannot select: 0x15c9bbe00: ch,glue callseq_end
0x15c9bbd98, TargetConstant:i32<0>, TargetGlobalAddress:i32<void
(i8*, i32, i8*, i8*)* @__assert_func> 0, 0x15c9bbd98:1
0x15c9bb920: i32 = TargetConstant<0>
0x15c9bb8b8: i32 = TargetGlobalAddress<void (i8*, i32, i8*, i8*)*
@__assert_func> 0
0x15c9bbd98: ch,glue = MYISD::CALL 0x15c9bbcc8,
TargetGlobalAddress:i32<void (i8*, i32, i8*, i8*)* @__assert_func> 0,
Register:i32 %I18, Register:i32 %I17, Register:i32 %I16, Register:i32 %I15,
RegisterMask:Untyped, 0x15c9bbcc8:1
0x15c9bb8b8: i32 = TargetGlobalAddress<void (i8*, i32, i8*, i8*)*
@__assert_func> 0
0x15c9bb9f0: i32 = Register %I18
0x15c9bbac0: i32 = Register %I17
0x15c9bbb90: i32 = Register %I16
0x15c9bbc60: i32 = Register %I15
0x15c9bbd30: Untyped = RegisterMask
0x15c9bbcc8: ch,glue = CopyToReg 0x15c9bbbf8, Register:i32 %I15,
0x15c9bb718, 0x15c9bbbf8:1
0x15c9bbc60: i32 = Register %I15
0x15c9bb718: i32,ch,glue = CopyFromReg 0x15c9bb648:1, Register:i32
%vreg2, 0x15c9bb648:1
0x15c9bb6b0: i32 = Register %vreg2
0x15c9bbbf8: ch,glue = CopyToReg 0x15c9bbb28, Register:i32 %I16,
Constant:i32<0>, 0x15c9bbb28:1
0x15c9bbb90: i32 = Register %I16
0x15c9bb850: i32 = Constant<0>
0x15c9bbb28: ch,glue = CopyToReg 0x15c9bba58, Register:i32 %I17,
0x15c9bb648, 0x15c9bba58:1
0x15c9bbac0: i32 = Register %I17
0x15c9bb648: i32,ch,glue = CopyFromReg 0x15c9bb578:1,
Register:i32 %vreg1, 0x15c9bb578:1
0x15c9bb5e0: i32 = Register %vreg1
0x15c9bba58: ch,glue = CopyToReg 0x15c9bb988, Register:i32 %I18,
0x15c9bb578
0x15c9bb9f0: i32 = Register %I18
0x15c9bb578: i32,ch,glue = CopyFromReg 0x15c967b38,
Register:i32 %vreg0
0x15c9bb510: i32 = Register %vreg0
My TD for this has:
def SDT_MYCallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>,
SDTCisVT<1,
i32>]>;
def SDT_MYCallSeqEnd : SDCallSeqStart<[SDTCisVT<0, i32>,
SDTCisVT<1,
i32>]>;
def MYCallseqStart : SDNode<"ISD::CALLSEQ_START",
SDT_MYCallSeqStart,
[SDNPHasChain, SDNPOutGlue]>;
def MYCallseqEnd : SDNode<"ISD::CALLSEQ_END",
SDT_MYCallSeqEnd,
[SDNPHasChain, SDNPOptInGlue,
SDNPOutGlue]>;
def SDT_MYCall : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
def SDT_MYRet : SDTypeProfile<0, 0, []>;
def MYcall : SDNode<"MYISD::CALL", SDT_MYCall,
[SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
SDNPVariadic]>;
def MYret : SDNode<"MYISD::RET_FLAG", SDTNone,
[SDNPHasChain, SDNPOptInGlue,
SDNPVariadic]>;
let hasCtrlDep = 1, hasSideEffects = 1 in {
def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
[(MYCallseqStart timm:$amt1,
timm:$amt2)]>;
def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
[(MYCallseqEnd timm:$amt1, timm:$amt2)]>;
}
def: Pat<(MYret), (JMP_Ret (i32 LR))>;
The function that is failing does warn - "warning: function declared
'noreturn' should not return [-Winvalid-noreturn]", and it does
seem to
return. In fact it invokes a custom builtin which does not actually return.
In the past I have just ignored this warning.
Any hints that might help me to make the necessary adaptations to fix this?
Thanks in advance,
MartinO
PS: I won't be able to reply until Monday as I will be away for the weekend
Serge Pavlov via llvm-dev
2017-Sep-15 16:39 UTC
[llvm-dev] Changes to 'ADJCALLSTACK*' and 'callseq_*' between LLVM v4.0 and v5.0
Hi Martin, Pseudo CALLSEQ_START was changed in r302527, commit message contains details on the changes. However CALLSEQ_END was not modified. If your made changes to ADJCALLSTACKUP to add additional argument, that may result in error. Thanks, --Serge 2017-09-15 19:09 GMT+07:00 Martin J. O'Riordan via llvm-dev < llvm-dev at lists.llvm.org>:> Hi LLVM-Devs, > > I have managed to complete updating our sources from LLVM v4.0 to v5.0, but > I am getting selection errors for 'callseq_end'. I am aware that the > 'ADJCALLSTACKUP' and 'ADJCALLSTACKDOWN' patterns have changed, and have > added an additional argument to the TD descriptions for these. > > There are interactions with 'ISD::CALL' and 'ISD::RET_FLAG', but so far as > I > can tell I have revised these in the same way as the in-tree targets have > adjusted their sources. > > The error I am seeing is: > > fatal error: error in backend: Cannot select: 0x15c9bbe00: ch,glue > callseq_end 0x15c9bbd98, TargetConstant:i32<0>, > TargetGlobalAddress:i32<void > (i8*, i32, i8*, i8*)* @__assert_func> 0, 0x15c9bbd98:1 > 0x15c9bb920: i32 = TargetConstant<0> > 0x15c9bb8b8: i32 = TargetGlobalAddress<void (i8*, i32, i8*, i8*)* > @__assert_func> 0 > 0x15c9bbd98: ch,glue = MYISD::CALL 0x15c9bbcc8, > TargetGlobalAddress:i32<void (i8*, i32, i8*, i8*)* @__assert_func> 0, > Register:i32 %I18, Register:i32 %I17, Register:i32 %I16, Register:i32 %I15, > RegisterMask:Untyped, 0x15c9bbcc8:1 > 0x15c9bb8b8: i32 = TargetGlobalAddress<void (i8*, i32, i8*, i8*)* > @__assert_func> 0 > 0x15c9bb9f0: i32 = Register %I18 > 0x15c9bbac0: i32 = Register %I17 > 0x15c9bbb90: i32 = Register %I16 > 0x15c9bbc60: i32 = Register %I15 > 0x15c9bbd30: Untyped = RegisterMask > 0x15c9bbcc8: ch,glue = CopyToReg 0x15c9bbbf8, Register:i32 %I15, > 0x15c9bb718, 0x15c9bbbf8:1 > 0x15c9bbc60: i32 = Register %I15 > 0x15c9bb718: i32,ch,glue = CopyFromReg 0x15c9bb648:1, Register:i32 > %vreg2, 0x15c9bb648:1 > 0x15c9bb6b0: i32 = Register %vreg2 > 0x15c9bbbf8: ch,glue = CopyToReg 0x15c9bbb28, Register:i32 %I16, > Constant:i32<0>, 0x15c9bbb28:1 > 0x15c9bbb90: i32 = Register %I16 > 0x15c9bb850: i32 = Constant<0> > 0x15c9bbb28: ch,glue = CopyToReg 0x15c9bba58, Register:i32 %I17, > 0x15c9bb648, 0x15c9bba58:1 > 0x15c9bbac0: i32 = Register %I17 > 0x15c9bb648: i32,ch,glue = CopyFromReg 0x15c9bb578:1, > Register:i32 %vreg1, 0x15c9bb578:1 > 0x15c9bb5e0: i32 = Register %vreg1 > 0x15c9bba58: ch,glue = CopyToReg 0x15c9bb988, Register:i32 > %I18, > 0x15c9bb578 > 0x15c9bb9f0: i32 = Register %I18 > 0x15c9bb578: i32,ch,glue = CopyFromReg 0x15c967b38, > Register:i32 %vreg0 > 0x15c9bb510: i32 = Register %vreg0 > > My TD for this has: > > def SDT_MYCallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>, SDTCisVT<1, > i32>]>; > def SDT_MYCallSeqEnd : SDCallSeqStart<[SDTCisVT<0, i32>, SDTCisVT<1, > i32>]>; > def MYCallseqStart : SDNode<"ISD::CALLSEQ_START", SDT_MYCallSeqStart, > [SDNPHasChain, SDNPOutGlue]>; > def MYCallseqEnd : SDNode<"ISD::CALLSEQ_END", SDT_MYCallSeqEnd, > [SDNPHasChain, SDNPOptInGlue, > SDNPOutGlue]>; > > def SDT_MYCall : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>; > def SDT_MYRet : SDTypeProfile<0, 0, []>; > def MYcall : SDNode<"MYISD::CALL", SDT_MYCall, > [SDNPHasChain, SDNPOptInGlue, > SDNPOutGlue, > SDNPVariadic]>; > def MYret : SDNode<"MYISD::RET_FLAG", SDTNone, > [SDNPHasChain, SDNPOptInGlue, > SDNPVariadic]>; > > let hasCtrlDep = 1, hasSideEffects = 1 in { > def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2), > [(MYCallseqStart timm:$amt1, > timm:$amt2)]>; > def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2), > [(MYCallseqEnd timm:$amt1, timm:$amt2)]>; > } > > def: Pat<(MYret), (JMP_Ret (i32 LR))>; > > The function that is failing does warn - "warning: function declared > 'noreturn' should not return [-Winvalid-noreturn]", and it does seem to > return. In fact it invokes a custom builtin which does not actually > return. > In the past I have just ignored this warning. > > Any hints that might help me to make the necessary adaptations to fix this? > > Thanks in advance, > > MartinO > > PS: I won't be able to reply until Monday as I will be away for the weekend > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170915/88bef271/attachment.html>
ORiordan, Martin via llvm-dev
2017-Sep-19 12:36 UTC
[llvm-dev] Changes to 'ADJCALLSTACK*' and 'callseq_*' between LLVM v4.0 and v5.0
Hi Serge,
Thanks for your help. I have looked at the change log, and so far as I can
tell, my implementation is pretty much identical to all of the in-tree targets,
but I’m missing something and can’t see what it is. I have simplified my TD
description to just:
def MyCallseqStart : SDNode<"ISD::CALLSEQ_START",
SDCallSeqStart<[SDTCisVT<0, i32>,
SDTCisVT<1, i32>]>,
[SDNPHasChain, SDNPOutGlue]>;
def MyCallseqEnd : SDNode<"ISD::CALLSEQ_END",
SDCallSeqEnd<[SDTCisVT<0, i32>,
SDTCisVT<1, i32>]>,
[SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
def my_call : SDNode<"MyISD::CALL",
SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>,
[SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
SDNPVariadic]>;
def my_ret : SDNode<"MyISD::RET_FLAG",
SDTNone,
[SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
let hasCtrlDep = 1,
hasSideEffects = 1,
isCodeGenOnly = 1,
Defs = [SP],
Uses = [SP] in {
def ADJCALLSTACKDOWN : Pseudo<(outs),
(ins i32imm:$amt1, i32imm:$amt2),
[(MyCallseqStart timm:$amt1, timm:$amt2)]>;
def ADJCALLSTACKUP : Pseudo<(outs),
(ins i32imm:$amt1, i32imm:$amt2),
[(MyCallseqEnd timm:$amt1, timm:$amt2)]>;
}
def Custom_CALL : Pseudo<(outs),
(ins IRF32:$target, variable_ops),
[(my_call IRF32:$target)]> {
let isCall = 1;
let usesCustomInserter = 1;
}
def Custom_RETURN : Pseudo<(outs),
(ins variable_ops),
[(my_ret)]> {
let isReturn = 1;
let usesCustomInserter = 1;
}
but when I compile the following C code:
int foo(int);
int bar() { return foo(42); }
it crashes with the following dump:
fatal error: error in backend: Cannot select: 0x1ede6ae3648: ch,glue =
callseq_end 0x1ede6ae35e0, TargetConstant:i32<0>,
TargetGlobalAddress:i32<i32 (i32)* @foo> 0, 0x1ede6ae35e0:1
0x1ede6ae33d8: i32 = TargetConstant<0>
0x1ede6ae3370: i32 = TargetGlobalAddress<i32 (i32)* @foo> 0
0x1ede6ae35e0: ch,glue = MyISD::CALL 0x1ede6ae3510,
TargetGlobalAddress:i32<i32 (i32)* @foo> 0, Register:i32 %I18,
RegisterMask:Untyped, 0x1ede6ae3510:1
0x1ede6ae3370: i32 = TargetGlobalAddress<i32 (i32)* @foo> 0
0x1ede6ae34a8: i32 = Register %I18
0x1ede6ae3578: Untyped = RegisterMask
0x1ede6ae3510: ch,glue = CopyToReg 0x1ede6ae3440, Register:i32 %I18,
Constant:i32<42>
0x1ede6ae34a8: i32 = Register %I18
0x1ede6ae3308: i32 = Constant<42>
I have tried disabling the custom inserters just in case they were causing the
problem but it crashes in the same way.
Must admit, I’m stumped on this one.
All the best,
MartinO
From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of Serge
Pavlov via llvm-dev
Sent: Friday, September 15, 2017 5:40 PM
To: Martin J. O'Riordan <MartinO at theheart.ie>
Cc: LLVM Developers <llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] Changes to 'ADJCALLSTACK*' and
'callseq_*' between LLVM v4.0 and v5.0
Hi Martin,
Pseudo CALLSEQ_START was changed in r302527, commit message contains details on
the changes.
However CALLSEQ_END was not modified. If your made changes to ADJCALLSTACKUP to
add
additional argument, that may result in error.
Thanks,
--Serge
--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263
This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20170919/7be7fed7/attachment.html>