[llvm-dev] LLVM + MASM (llvm-ml)

Eric Astor via llvm-dev llvm-dev at lists.llvm.org
Fri Jul 2 13:38:23 PDT 2021


I've tracked down the trigger; it's the line
lea rdx, QWORD PTR [rax*8+16]
https://github.com/llvm/llvm-project/blob/d480f968ad8b56d3ee4a6b6df5532d485b0ad01e/openmp/runtime/src/z_Windows_NT-586_asm.asm#L1243

The issue is that LLVM-ML64 generally assumes that (if unspecified) the
base register of a memory reference is RIP. Our attempt to mimic this ends
up with us trying to assemble the instruction
lea rdx, [rip + 8*rax + 16]
... and the X86 code emitter rightly complains that that's not a valid
memory reference.

This was introduced in an attempt to mimic ML64.EXE in
https://reviews.llvm.org/D73227 - and it looks like I got it wrong! (And
didn't test against ML64.EXE nearly enough.) If I've got it right now, this
was only supposed to apply to references to symbols... and irritatingly
enough, only to symbols defined using MASM's syntax for named variables in
memory.

v0 of https://reviews.llvm.org/D105372 restricts it to symbols, at least,
and avoids this misassembly. I'll see about getting another commit up (or
patching that one) to restrict further to named variables specifically, and
not apply to labels.



On Thu, Jul 1, 2021 at 4:26 PM Martin Storsjö <martin at martin.st> wrote:

> On Thu, 1 Jul 2021, Eric Astor wrote:
>
> > Martin,
> > I haven't actually seen the -win64 option for ML(64).EXE documented
> anywhere
> > - have you? If we can find evidence of what it does for those, we'll of
> > course match it.
>
> Oh, sorry about that, it turns out that this was a flag I added myself in
> my CMake configuration. ml(64).exe doesn't support it, but it's a uasm
> flag (which is the tool I use for masm today) - I had forgotten about
> setting that flag... Then it's trivial for me to change that flag into
> -m64, or use tool name based switching like you suggested.
>
> Sorry for the noise about this aspect.
>
> > Back to the 64-bit build issues, though - I'll get back to checking on
> that
> > soon, and see if I can track down the line in the .asm file that triggers
> > that bug. Hopefully it won't be too tricky a fix!
>
> Thanks!
>
> // Martin
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210702/8883b5c7/attachment.html>


More information about the llvm-dev mailing list