[llvm-dev] Bug in TailDuplicator?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] Bug in TailDuplicator?

Stefan Pusl via llvm-dev
Hi,

I think there might be a bug in the tail duplicator (called from
MachineBlockPlacement in my case), when duplicating a block that
contains an implicit fall-through.
Suppose you have the following blocks

BB#1:
      Predecessors according to CFG: BB#2
        ...
        conditional_branch <BB#3>
      < implicit fall-through to BB#2 >
      Successors according to CFG: BB#2 BB#3

BB#2:
      Predecessors according to CFG: BB#1 BB#0
        ...
        unconditional_branch <BB#1>
      Successors according to CFG: BB#1

BB#3:
      Predecessors according to CFG: BB#1
        ...

It duplicates BB#1 into BB#2 but misses out the branch that goes back up:

BB#2:
      Predecessors according to CFG: BB#1 BB#0
        <BB#2 instructions>
        <BB#1 instructions>
        conditional_branch <BB#3>
      Successors according to CFG: BB#3

So this is not a loop any more.

Instead, a branch needs to be inserted to replace the implicit
fall-through in BB#1.

I have attached a patch for this.

(Incidentally, I see a duplication of the statement
"TII->removeBranch(*PrevBB);" if run after register allocation. I've
removed this call in the patch as well.)

Unfortunately, I am working on a proprietary target, so cannot provide a
test case. I have, however, attached a "pseudo mir" which should be
easily adaptable for a public target.

Maybe this is not a bug, but my function at this stage is not canonical?
Also, I am not on tip (though I checked the TailDuplicator tip), so it
is possible this is fixed elsewhere.

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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

tailDuplicatorPatch.diff (1K) Download Attachment
tail_duplicator_bug.pseudo_mir (1K) Download Attachment