[llvm-dev] Changes to 'ADJCALLSTACK*' and 'callseq_*' between LLVM v4.0 and v5.0

Martin J. O'Riordan via llvm-dev llvm-dev at lists.llvm.org
Wed Sep 20 03:07:15 PDT 2017


Found it.  An idiot mistake in my ‘LowerCall’ implementation where I had a cut’n’paste argument error to ‘getCALLSEQ_END’ that has been wrong for a very long time, but this change has exposed it.

 

Thanks,

 

            MartinO

 

From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of ORiordan, Martin via llvm-dev
Sent: 19 September 2017 13:37
To: Serge Pavlov <sepavloff at gmail.com>; llvm-dev <llvm-dev at lists.llvm.org>
Subject: Re: [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 <mailto:MartinO at theheart.ie> >
Cc: LLVM Developers <llvm-dev at lists.llvm.org <mailto: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/20170920/46bb9cee/attachment-0001.html>


More information about the llvm-dev mailing list