AetX
AetX

Reputation: 213

Instruction does not dominate all uses when delete and replace new IR code

I'm trying to replace foo(%10) with foo(%5). I use following code to do so

i.replaceAllUsesWith(dyn_cast<Value>(newfunc_instrct));
i.eraseFromParent();

The pass works fine with some code, but when compile with a more complicated program, I encountered the following error. I don't quite understand the meaning. Really appreciate any help! Thanks.

Instruction does not dominate all uses!
%81 = bitcast i32* %80 to i8*
%137 = call i32 @foo(i8* %81)
LLVM ERROR: Broken function found, compilation aborted!

Upvotes: 1

Views: 793

Answers (1)

arnt
arnt

Reputation: 9685

"Instruction does not dominate all use" means that there is a way in which the result of an instruction can be needed but the instruction hasn't been executed yet.

I hate typing IR by hand, so here's a C example:

int a;
if(random())
    a = 42;
printf("%d\n", a);

The printf needs a, which may not have been initialised yet.

In your case I suppose there's something that uses %5 between %5 and %10.

Domination analysis is the process by which LLVM spots the problem. It's used for many things in LLVM. The wording of the error message isn't ideal.

Upvotes: 1

Related Questions