[llvm-bugs] [Bug 46679] New: [AARCH64] "expected assembly-time absolute expression"

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jul 10 18:22:21 PDT 2020


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

            Bug ID: 46679
           Summary: [AARCH64] "expected assembly-time absolute expression"
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: AArch64
          Assignee: unassignedbugs at nondot.org
          Reporter: caij2003 at gmail.com
                CC: arnaud.degrandmaison at arm.com,
                    llvm-bugs at lists.llvm.org, smithp352 at googlemail.com,
                    Ties.Stuij at arm.com

>From https://github.com/ClangBuiltLinux/linux/issues/1078, IAS fails to
assemble the following code with Clang's integrated assembler for ARM64. The
reproducer was originally reported at
https://github.com/ClangBuiltLinux/linux/issues/1078#issuecomment-656245060.
Here is a slightly changed reproducer

$ cat test.c
void a(void)
{ 
        asm(
        ".arch_extension lse            \n"
        "1:                             \n"
        "nop                            \n"
        "2:                             \n"
        ".subsection 1                  \n"
        "3:                             \n"
        "nop                            \n"
        "4:                             \n"
        ".previous                      \n"
        ".org . - (4b-3b) + (2b-1b)     \n"
        );
}
/* identical to a() */
void b(void)
{
        asm(
        "5:                             \n"
        "nop                            \n"
        "6:                             \n"
        ".subsection 1                  \n"
        "7:                             \n"
        "nop                            \n"
        "8:                             \n"
        ".previous                      \n"
        ".org . - (4b-3b) + (2b-1b)     \n"
        );
}
$ clang --target=aarch64-linux-gnu -c test.c
test.c:28:10: error: expected assembly-time absolute expression
        ".org . - (8b-7b) + (6b-5b)     \n"
         ^
<inline asm>:9:6: note: instantiated into assembly here
.org . - (8b-7b) + (6b-5b)     
     ^
1 error generated.


I did some digging on this issue. So while parsing
(AArch64AsmParser::parseDirectiveArchExtension) .arch_extension, IAS created a
new MCSubtargetInfo object and replaced the one associated with the assembly
parser. Later, however, when creating machine functions
(MachineModuleInfo::getOrCreateMachineFunction), the old one was used. So when
parsing the nop between label 7 and 8, while deciding if it can place the
instruction into the current fragment, IAS finds out the difference on the
MCSubtargetInfo object of the fragment (from the new object associated with the
parser) and the one from the machine function b, therefore creating
(MCObjectStreamer::getOrCreateDataFragment) a new data fragment and causing 7
and 8 be placed into two different fragments. Since IAS can only resolve
(AttemptToFoldSymbolOffsetDifference) differences of labels belong to the same
fragment, it failed to assemble the above code. 


Also if I separate the compilation and assembling process as in
https://github.com/ClangBuiltLinux/linux/issues/1078#issuecomment-656385059,
the same example assembled successfully.

-- 
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/20200711/47dbc7bc/attachment.html>


More information about the llvm-bugs mailing list