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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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@build1-lucid-cs arm-none-eabi-lite$

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to