[LLVMdev] Dominator error inserting instructions into BasicBlock

Shane Clark ssclark at cs.umass.edu
Tue Aug 4 18:11:07 PDT 2009


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:

  //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
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!

Thanks,
Shane



More information about the llvm-dev mailing list