[LLVMdev] Merge 2 BasicBlocks

Michael Ilseman michael at lunarg.com
Mon Jul 16 08:41:23 PDT 2012


'Instruction does not dominate all uses!' is from the Verifier pass
and usually signifies bad IR instead of a stale dominator tree. If you
dump the IR before and after, you may see what the problem is: usually
one instruction uses another that hasn't yet been defined.

The Verifier pass requests a dominator tree, so if you think it really
is just a stale dominator tree you can make sure that your pass
doesn't claim to preserve that analysis.

On Mon, Jul 16, 2012 at 7:33 AM, Rinaldini Julien
<julien.rinaldini at heig-vd.ch> wrote:
> Hi!
>
> I'm trying to merge 2 basicblocks. I look in BasicBlockUtils.h but the merge function does not what I want.
>
> I'm trying to merge basicblock from a switch where the 'case' have no break, from that:
>
> int a;
> switch(c) {
>     case 3:
>         a=1;
>     case 2;
>         b=1;
>     case 1:
>         c=1;
> }
>
> to that:
>
> int a;
> switch(c) {
>     case 3:
>         a=1;
>         b=1;
>         c=1;
>         break;
>     case 2;
>         b=1;
>         c=1;
>         break;
>     case 1:
>         c=1;
>         break;
> }
>
> I use clone() on instruction and insert each cloned instruction onto the right basicblock.
> In that simple case, it works great, but when I have some code with pointers like:
>
> int a;
> int b[5] = {1,2,3,4,5};
> switch(c) {
>     case 3:
>         a=1;
>         b[c] = 1;
>     case 2;
>         b=1;
>         b[c] = 1;
>     case 1:
>         c=1;
>         b[c] = 1;
> }
>
> I have a lot of 'Instruction does not dominate all uses!' because the clone() method don't recalculate the dominator tree.
>
> Is there a way to fix that?
>
> Thx,
> Cheers
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the llvm-dev mailing list