"Instruction does not dominate all uses"

BB:

%4= load i32* @“FB”
%5 = icmp ne i32 %4, 0
br i1 %5, label %BB1, label %BB2

The error after

$clang -pthread MyNew.ll -o MyNew

Instruction does not dominate all uses!

Could you help for this ?

Hi Rasha,

Instruction does not dominate all uses!

There should be two instructions printed after that message. The first
defines a value used by the second, but the message means there's some
path through your function that can reach the second inst (the use)
without the value being defined by the first instruction.

At its simplest you probably want to decide what that value should be
if the defining instruction isn't reached (maybe an initial loop
value?), insert a phi node describing this and use that instead of the
instruction that may not be executed.

Could you help for this ?

Not without more information, I'm afraid. The fragment you posted has no issues.

Cheers.

Tim.

Hi Tim,

Instruction does not dominate all uses!
%5 = icmp ne i32 %4, 0
br i1 %5, label %BB1, label %BB2
Broken module found, compilation aborted!

Instruction does not dominate all uses!
%5 = icmp ne i32 %4, 0
br i1 %5, label %BB1, label %BB2
Broken module found, compilation aborted!

And from your first message, I assume you think that the icmp defining
%5 is right before the br that's using it. Have you checked that
assumption by calling dump() on the Module?

If putting the module produced by dump() into a .ll file and compiling
it manually works, then there's not much else I can suggest except
tracing values through a debugger. If only you can reproduce the
problem then it's likely only you can solve it.

Cheers.

Tim.