Skip to content

aarch64 codegen emits add x28,xzr,#1 not accepted by gnu assembler #34022

@kraj

Description

@kraj
Bugzilla Link 34674
Resolution FIXED
Resolved on Sep 25, 2017 06:53
Version 5.0
OS All
Blocks #34043
CC @rovka,@efriedma-quic,@kbeyls,@MatzeB,@rengolin,@TNorthover

Extended Description

I have a testcase https://uclibc.org/~kraj/a.cpp

Which fails to compile/assemble when using -no-integrated-as on aarch64, but it works
ok when using -integrated-as

clang -target aarch64-linux-gnu a.cpp -O2 -c -std=gnu++11
works

but

clang -target aarch64-linux-gnu a.cpp  -O2 -c -std=gnu++11 -no-integrated-as throws

/tmp/tmp.ZfaD5q6lwY/a-8fa1ba.s:25688: Error: integer register expected in the extended/shifted operand register at operand 3 -- `add x28,xzr,#1'
/tmp/tmp.ZfaD5q6lwY/a-8fa1ba.s:25717: Error: integer register expected in the extended/shifted operand register at operand 3 -- `add x1,xzr,#1'
/tmp/tmp.ZfaD5q6lwY/a-8fa1ba.s:25718: Error: integer register expected in the extended/shifted operand register at operand 3 -- `add x2,xzr,#1'

I then created .s file output with and without integrated-as and in both cases I do see above instructions in assmebly file.

I thought it might be a problem only with GNU as so I created a small test case like this

int foo() {
asm("add x28,xzr,#1") ;
return 0;
}

and now when I compile it, I get errors with both GNU and internal asm

So it does seem that instruction is not accepted by both assemblers but when using internal assembler and not generating .s files these instructions might be getting optimized out ?

I think some aarch64 expertise help is needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:codegenIR generation bugs: mangling, exceptions, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions