Comments (3)
Wow, okay, we (I) gloriously misinterpreted the semantics of TargetInstrInfo::getInstSizeInBytes()
. We summarily return 3
, since that's the max instruction size on our supported targets. But "instruction" in this case includes things like the INLINEASM
"instruction", and all of the other targets include a call to TII.getInlineAsmLength()
to handle that case.
Should be straightforward to fix, but I'll need to write a test case and scan the other targets' implementations to see if there's anything else we missed.
from llvm-mos.
Built latest llvm-mos from git source to see if the issue persists with latest compiler, which it seems to:
C:\code\EDIT\recvprg>mos-c64-clang++ br.cpp -Oz -o br.prg
ld.lld: error: lto.tmp:(function main: .text.main+0x84): relocation R_MOS_PCREL_8 out of range: -130 is not in [-128, 127]; references section '.text.main'
>>> referenced by ld-temp.o
ld.lld: error: lto.tmp:(function main: .text.main+0x88): relocation R_MOS_PCREL_8 out of range: -134 is not in [-128, 127]; references section '.text.main'
>>> referenced by ld-temp.o
mos-clang++: error: ld.lld command failed with exit code 1 (use -v to see invocation)
C:\code\EDIT\recvprg>mos-c64-clang++ --version
clang version 18.0.0 (https://github.com/llvm-mos/llvm-mos.git bc9be3b91539473a3fc566a58b6a8236793b7dfc)
Target: mos
Thread model: posix
InstalledDir: C:\code\llvm-mos\build\bin
Configuration file: C:\code\llvm-mos\build\bin\mos-c64.cfg
from llvm-mos.
I'll be debugging this one "out loud" on this bug, I'm trying something new :)
Running the linker with -Wl,--save-temps
produces the LTO temporary object file that the linker is failing to relocate.
Examining that with llvm-readelf --all
yields the following relocations for .text.main
:
Relocation section '.rela.text.main' at offset 0x2364 contains 4 entries:
Offset Info Type Sym. Value Symbol's Name + Addend
00000001 00000203 R_MOS_ADDR16 00000000 .text.main + 79
00000084 00000206 R_MOS_PCREL_8 00000000 .text.main + 3
00000088 00000206 R_MOS_PCREL_8 00000000 .text.main + 3
0000008a 00000203 R_MOS_ADDR16 00000000 .text.main + 53
Accordingly, at offset 0x84, there's a branch to offset 0x3, which is definitely out of range.
Using llvm-objdump -d
reveals that the branch is the one at the end of the following asm:
00000079 <end2>:
79: ae 09 de ldx $de09 ; 0xde09 <end2+0xdd90>
7c: ac 08 de ldy $de08 ; 0xde08 <end2+0xdd8f>
7f: a9 01 lda #$1
81: e0 00 cpx #$0
83: d0 00 bne $85 <end2+0xc>
Getting a symbolic assembly dump using -Wl,--lto-emit-asm
yields:
end2:
;NO_APP
.LBB0_3: ; =>This Inner Loop Header: Depth=1
ldx 56841
ldy 56840
lda #1
cpx #0
bne .LBB0_1
Notably, this code is outside of the inline assembly, so it seems likely that it is mis-sizing the inline assembly somehow, since the far branch to .LBB0_1
doesn't get replaced with an inverse branch that skips an absolute JMP
.
from llvm-mos.
Related Issues (20)
- Support assembler sources in ca65 format
- Lower mem intrinsics to loops
- G_OR prevents selection of addressing mode HOT 1
- Don't copy single-use strings to the zero page
- rustc crash HOT 2
- Compilation failure on MacOS w. Apple silicon HOT 11
- Builder for Apple Silicon
- mos-sim crash HOT 1
- Triple selection doesn't accommodate mos-<platform>-<type>-<subtype> syntax
- [65C816, 65CE02] Long branch instructions not supported HOT 2
- ld.lld: error: undefined symbol: __rc4 to __rc24 HOT 3
- Missing G_SBC commutation for equality checks HOT 1
- [Assembler] Improved ergonomics for 65816 (and other) subtargets HOT 14
- [Assembler] .byte/.short don't support MOS expression parsing
- [Interrupts] Current interrupt C generation inadequate for CBM machines HOT 2
- Redundant copy and spilling HOT 1
- Compiler crashes when try to access a member variable of a class through inline assembly HOT 5
- Declaration order of member variables has a big impact on code optimization HOT 1
- Surface error messages for inline assembly
- LLD verbose mode should print the command lines of invoked `ld65` steps
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from llvm-mos.