[LLVMbugs] [Bug 19749] New: Clang integrated assembler doesn't accept asm macro defined in one asm directive and used in another

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed May 14 15:59:59 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19749

            Bug ID: 19749
           Summary: Clang integrated assembler doesn't accept asm macro
                    defined in one asm directive and used in another
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jonathan at codesourcery.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Integrated assembler refuses to accept code where an asm macro is defined
outside a function but the use is in a different asm block. This example also
demonstrates a workaround, on case others stumble across this bug too.

$ cat foobar.c
#if defined(MACRO_OUTSIDE)
asm(
    ".macro  RETURN    cond=\n\t"
    "bx\\cond    lr\n\t"
    ".endm\n\t"
    );
#endif

char* __attribute__((naked))
foo(char* bar)
{
  asm (
#if !defined(MACRO_OUTSIDE)
    ".macro  RETURN    cond=\n\t"
    "bx\\cond    lr\n\t"
    ".endm\n\t"
#endif
    "RETURN\n"
       );
}
$ clang -target arm-none-eabi -march=armv7 -g -O2 -c foobar.c -fintegrated-as
$ clang -target arm-none-eabi -march=armv7 -g -O2 -c foobar.c
-fno-integrated-as
$ clang -target arm-none-eabi -march=armv7 -g -O2 -c foobar.c
-fno-integrated-as -DMACRO_OUTSIDE
$ clang -target arm-none-eabi -march=armv7 -g -O2 -c foobar.c -fintegrated-as
-DMACRO_OUTSIDE
foobar.c:18:5: error: invalid instruction
    "RETURN\n"
    ^
<inline asm>:1:2: note: instantiated into assembly here
        RETURN
        ^~~~~~
1 error generated.
[15:01:37] ✘ jroelofs at build1-lucid-cs arm-none-eabi-lite$

-- 
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/20140514/99cc0399/attachment.html>


More information about the llvm-bugs mailing list