[llvm-dev] About "error: instruction expected to be numbered"
Krzysztof Parzyszek via llvm-dev
llvm-dev at lists.llvm.org
Tue Jan 22 06:39:24 PST 2019
On 1/22/2019 8:19 AM, Peng Yu via llvm-dev wrote:
>
> Must the register number be ordered and be without gaps between
> instructions? Is there a way to allow more flexible register
> numbering?
The things in the IR dump with the % prefix are "values" (see Value in
Value.h). Values may have names, but don't have to. When a value has a
name, it's printed after the %, so a value with a name "foo" will be
printed as %foo. Values with names have no restrictions on ordering
relative to other values.
Values that don't have names will be printed with numbers (e.g. %9), but
these numbers are not related to names, and they will not become names.
The numbers are created pretty much out of thin air by the code that
prints the IR. The flip side is that when the IR is parsed, the numbers
corresponding to the anonymous values must be sequential, so that you
cannot have "%5 = ..." followed by "%7 = ...". As you noticed, this
makes manual editing of the IR somewhat tricky. The easiest thing to do
is to make sure that all values have names, and to do that you can do
"opt -S -instnamer < input.ll > output.ll", and all anonymous values in
input.ll will get names tmp1, tmp2, etc.
-Krzysztof
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
More information about the llvm-dev
mailing list