[llvm-dev] Resend: assertion in MachineCopyPropagation::isNopCopy

Matthias Braun via llvm-dev llvm-dev at lists.llvm.org
Mon Sep 18 11:44:31 PDT 2017


> On Sep 18, 2017, at 4:10 AM, Verena Beckham via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hi, anyone know anything about copy propagation? Matthias, I see this was your code originally? Was there some assumptions you made?
> 
> I'm hitting an assertion in MachineCopyPropagation::isNopCopy:
> 
> if (Src == PreviousSrc) {
>  assert(Def == PreviousDef);
>  return true;
> }
> 
> This code compares two COPY instruction to see whether they are effectively "the same". The assert assumes that, if the sources are the same register then the destinations must be as well.
> My instructions look like this, however:
> 
>  %V2<def> = COPY %V6
>  %V6<def> = COPY %V2_LO
> 
> (isNopCopy is called with src and dest of the first instruction switched.)
> So dst2 == src1 but src2 is a subregister of dst1.
> Is there some assumption that size(src) == size(dst)?
Yes COPY can only be used for registers of the same size; it won't automatically select a matching subregister but must be constructed with the correct subregister upfront (V2 instead of V2_LO in your case I assume?). Unfortunately the machine verifier currently has no way to catch/assert on this sort of error so it may stay undetected throughout large parts of the pipeline.

> This second COPY, with size(src) != size(dst) was generated in InstrEmitter::EmitSubregNode at
I would suspect the problem here. But would need to know more to say for sure (like how your register hierarchies look like, how the SelectionDAG node and the generated MI instruction looks).

- Matthias

> 
> // Create the extract_subreg machine instruction.
> 
> So it's not out-of-tree code.
> Am I missing something or should the assert condition be part of the "if" condition instead?
> Thanks,
> 
> -- 
> Verena Beckham
> 
> Senior Principal Software Engineer, Compilers
> 
> Codeplay Software Ltd
> Level C, Argyle House, 3 Lady Lawson Street, Edinburgh, EH3 9DR
> Tel: 0131 466 0503
> Fax: 0131 557 6600
> Website: http://www.codeplay.com
> 
> This email and any attachments may contain confidential and /or privileged information and  is for use  by the addressee only. If you are not the intended recipient, please notify Codeplay Software Ltd immediately and delete the message from your computer. You may not copy or forward it,or use or disclose its contents to any other person. Any views or other information in this message which do not relate to our business are not authorized by Codeplay software Ltd, nor does this message form part of any contract unless so stated.
> As internet communications are capable of data corruption Codeplay Software Ltd does not accept any responsibility for any changes made to this message after it was sent. Please note that Codeplay Software Ltd does not accept any liability or responsibility for viruses and it is your responsibility to scan any attachments.
> Company registered in England and Wales, number: 04567874
> Registered office: Regent house, 316 Beulah Hill, London, United Kingdom, SE19 3HF
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list