Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARM MC assembler allows backward branching on CBNZ instruction. #20733

Open
llvmbot opened this issue Jul 18, 2014 · 1 comment
Open

ARM MC assembler allows backward branching on CBNZ instruction. #20733

llvmbot opened this issue Jul 18, 2014 · 1 comment
Labels
backend:ARM bugzilla Issues migrated from bugzilla

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 18, 2014

Bugzilla Link 20359
Version trunk
OS Linux
Blocks #19300
Attachments Test case to demonstrate the issue
Reporter LLVM Bugzilla Contributor
CC @rengolin,@TNorthover

Extended Description

I have attached an arm assembly file which can demonstrate the issue.
(The test case is an excerpt from compiler-rt ARM builtins library)

$ clang -mcpu=cortex-a9 -c /tmp/temp.s -no-integrated-as -o /tmp/temp.o
/tmp/temp.s: Assembler messages:
/tmp/temp.s:13: Error: branch out of range
clang-3.5: error: assembler command failed with exit code 1 (use -v to see invocation)

$ clang -mcpu=cortex-a9 -c /tmp/temp.s -integrated-as -o /tmp/temp.o
The integrated-as compiles the file with out an issue and generates bad assembly

$ arm-none-linux-gnueabi-objdump -S /tmp/temp.o
/tmp/temp.o: file format elf32-littlearm
Disassembly of section .text:
00000000 <__sync_fetch_and_add_8>:
0: b570 push {r4, r5, r6, lr}
2: f3bf 8f5f dmb sy
6: 4684 mov ip, r0
8: e8dc 017f ldrexd r0, r1, [ip]
c: 1884 adds r4, r0, r2
e: eb41 0503 adc.w r5, r1, r3
12: e8cc 4576 strexd r6, r4, r5, [ip]
16: bbbe cbnz r6, 88 <__sync_fetch_and_add_8+0x88>
18: f3bf 8f5f dmb sy
1c: bd70 pop {r4, r5, r6, pc}

There is no address corresponding to 88 <__sync_fetch_and_add_8+0x88>.

The ARM manual on CBNZ says backward branching is not possible.
Refer to http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489c/Cjaghefc.html

@rengolin
Copy link
Member

Test case

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:ARM bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

2 participants