Virtual register defs don't dominate all uses

Hi all,
I’m getting this error: “Virtual register defs don’t dominate all uses”. It comes from llvm/lib/CodeGen/MachineVerifier.cpp:2138

I don’t understand what it means. Does anyone know?


Hi Josh,

That means that at least one use of the reporter virtual register happens before its definition.
… = V1 <—— V1 is not defined here
V1 = … <— V1 def does not dominate all its use


Thank you for the response.
What’s the difference between running clang with the -emit-llvm option vs running it with the --target= option.
The error I described happens only if I run: clang --target= .c
However if I do clang -emit-llvm .c -o .bc

and then llc -march= .bc, no error occurs


The target does affect what IR gets generated in some respects
(particularly around function calls), so to reproduce an issue with
llc you often need to use both "-target" and "-emit-llvm" on Clang
(and then you can usually drop "-march" for llc since the triple is in
the IR).

You sometimes also need to add options to llc to make it behave more
like Clang (-O0 to enable FastISel for example, or some -reloc-model).
But that's not especially common. Finally, the full triple can matter
(especially if you're cross-compiling for a different OS), so using
-mtriple when invoking llc is sometimes needed.