[LLVMdev] Dominator error inserting instructions into BasicBlock

Devang Patel devang.patel at gmail.com
Wed Aug 5 11:32:37 PDT 2009


Hi Shane,

On Tue, Aug 4, 2009 at 6:11 PM, Shane Clark<ssclark at cs.umass.edu> wrote:
> Hi,
>
> I've been writing some optimization passes for LLVM and had good luck
> with
> the simple stuff, but I am running into all kinds of trouble trying to
> make copies of variables within a BasicBlock as part of a LoopPass
>
> I am trying to make copies of the variables that are in scope in the
> loop body like so:

Why do you want to copy variables ? What transformations are you doing
as a loop pass ?

>
>  //Remove the existing terminator
>  first_block->getTerminator()->eraseFromParent();
>
>  //Get the symbol table so that we know what to store
>  ValueSymbolTable* vst = first_block->getValueSymbolTable();
>
>  IRBuilder <> builder(first_block);
>  for (ValueSymbolTable::iterator vst_it = vst->begin(); vst_it !=
> vst->end(); vst_it++) {
>        AllocaInst* store_var = builder.CreateAlloca(type,
> 0,my_name.c_str());
>        builder.CreateStore(symbol, store_var, true);
>     }
>
> //Put a terminator on the block
> builder.CreateRetVoid();
>
> This builds fine, but I get dominator issues when I try to test it
> with opt.
> I'm sure that I just don't understand all of the constraints on the
> IR, but
> I would appreciate it if anyone can point me in the right direction. The
> output from opt is below.
>
> Instruction does not dominate all uses!
>        %inc = add i32 %tmp1, 1         ; <i32> [#uses=2]       volatile
> store i32 %inc, i32* %_my_inc

Here you're trying to store results of add instruction. But the error
message says the add instruction does not dominate store instruction.

> Instruction does not dominate all uses!
>        %tmp1 = load i32* @i            ; <i32> [#uses=2]       volatile
> store i32 %tmp1, i32* %_my_tmp1
> Broken module found, compilation aborted!
>


-
Devang




More information about the llvm-dev mailing list