[llvm-bugs] [Bug 34708] New: Regression: Referencing labels across asm blocks results in bad asm since 4.0.0

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 22 20:28:24 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=34708

            Bug ID: 34708
           Summary: Regression: Referencing labels across asm blocks
                    results in bad asm since 4.0.0
           Product: clang
           Version: 4.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: llvm at thecybershadow.net
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

///////////// test.cpp ////////////
bool test()
{
  __asm mov byte ptr [magic], 0x90;
  __asm {
    magic:
      nop
  };
}
///////////////////////////////////

$ clang -c -m32 -target i386-pc-windows-msvc18.0.0 test.cpp 
test.cpp:3:3: error: assembler label 'L__MSASMLABEL_.0__magic' can not be
undefined
  __asm mov byte ptr [magic], 0x90;
  ^
<inline asm>:2:2: note: instantiated into assembly here
        mov byte ptr L__MSASMLABEL_.0__magic, 0x90
        ^
1 error generated.

Looking at the emitted assembly, it looks like Clang/LLVM uses the
"L__MSASMLABEL_.0__magic" label when referring to the address of the "magic"
label, but actually defines the label with the name "L__MSASMLABEL_.1__magic".
In 3.9.1 "L__MSASMLABEL_.0__magic" is used throughout.

This pattern is necessary for MSVC compatibility with programs using
self-modifying code.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170923/adef6ab5/attachment.html>


More information about the llvm-bugs mailing list