Closed Bug 1477929 Opened 6 years ago Closed 6 years ago

[LTO] [arm] <inline asm>:2:9: error: operand must be a register in range [r0, r7]

Categories

(NSS :: Libraries, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: glandium, Assigned: glandium)

References

Details

Attachments

(1 file, 1 obsolete file)

libfreebl3.so fails to build on arm with LTO enabled with the following error:

[task 2018-07-19T08:57:57.985Z] 08:57:57     INFO -  <inline asm>:2:9: error: operand must be a register in range [r0, r7]
[task 2018-07-19T08:57:57.985Z] 08:57:57     INFO -  cbz     r10, 2f
[task 2018-07-19T08:57:57.985Z] 08:57:57     INFO -          ^
[task 2018-07-19T08:57:57.985Z] 08:57:57     INFO -  LLVM ERROR: Error parsing inline asm

It's not clear from the ARM documentation for CBZ whether that's a problem with llvm or a limitation of the CBZ instruction, but at least the version of LLVM we use insists that CBZ is used with a core register (between r0 and r7, included).

That instruction comes from inline asm blocks, and in normal builds, it just happens to work because the variable that is passed to CBZ is a function argument, one of the four first arguments, such that it is register allocated. The compiler just decides to use that register directly.

With LTO, the function actually ends up inlined in its caller, and the register allocated to the variable can end up outside the core register range.

The GCC documentation for machine-constraints indicates the `l` constraint exists to limit the possible registers:
"In Thumb State the core registers r0-r7. In ARM state this is an alias for the r constraint."

(CBZ being only used on thumb)
I tried putting this in phabricator, but it's stuck on "Wait Until Bugzilla Updates Revision."
Attachment #8994439 - Flags: review?(franziskuskiefer)
Comment on attachment 8994439 [details] [diff] [review]
Use a stricter constraint for the register passed to cbz

Review of attachment 8994439 [details] [diff] [review]:
-----------------------------------------------------------------

lgtm but shouldn't the same issue occur then in s_mpv_mul_d_add_prop?
We don't have arm machines on CI (only aarch64) so I can't test the fix. Do you have a link to the failing build?
Attachment #8994439 - Flags: review?(franziskuskiefer)
s_mpv_mul_d_add_prop is harcoding the register. So is s_mpv_sqr_add_prop.
Comment on attachment 8994439 [details] [diff] [review]
Use a stricter constraint for the register passed to cbz

Review of attachment 8994439 [details] [diff] [review]:
-----------------------------------------------------------------

> s_mpv_mul_d_add_prop is harcoding the register. So is s_mpv_sqr_add_prop.

Ah right.

Thanks!
Attachment #8994439 - Flags: review+
libfreebl3.so fails to build on arm with LTO enabled with the following
error:

     INFO -  <inline asm>:2:9: error: operand must be a register in range [r0, r7]
     INFO -  cbz     r10, 2f
     INFO -          ^
     INFO -  LLVM ERROR: Error parsing inline asm

It's not clear from the ARM documentation for CBZ whether that's a
problem with llvm or a limitation of the CBZ instruction, but at least
the version of LLVM we use insists that CBZ is used with a core register
(between r0 and r7, included).

That instruction comes from inline asm blocks, and in normal builds, it
just happens to work because the variable that is passed to CBZ is a
function argument, one of the four first arguments, such that it is
register allocated. The compiler just decides to use that register
directly.

With LTO, the function actually ends up inlined in its caller, and the
register allocated to the variable can end up outside the core register
range.

The GCC documentation for machine-constraints indicates the `l`
constraint exists to limit the possible registers:
 "In Thumb State the core registers r0-r7. In ARM state this is an alias
for the r constraint."

(CBZ being only used on thumb)
Attachment #8994500 - Attachment is obsolete: true
https://hg.mozilla.org/projects/nss/rev/64d443c8fcc7897ee7a3317d258330649c59dbdb
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Blocks: android-lto
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: