r/programming • u/yossarian_flew_away • Jul 19 '21
LLVM internals, part 1: the bitcode format
https://blog.yossarian.net/2021/07/19/LLVM-internals-part-1-bitcode-format0
Jul 20 '21
[deleted]
6
u/yossarian_flew_away Jul 20 '21
Author here: my understanding is that the bitstream can even change within a release, since the bitcode emitter is allowed to make abbreviation decisions based on the IR at hand. But this doesn't make it "unstable" per se, since it's self-describing and the rules for its self description are stable. But it's possible that I'm missing something!
0
Jul 20 '21
[deleted]
2
u/yossarian_flew_away Jul 20 '21
That's good to know! Do you happen to have a link for that policy? I've successfully moved bitcode across a few different releases, but it's good to know that I've been relying on unguaranteed behavior...
2
u/TNorthover Jul 20 '21
It changes, but people are expected to keep it compatible at the API level, so there's a whole AutoUpgrade.cpp that fixes up archaic bitcode records during the read phase. You should still be able to read a .bc file from 3.0 onwards and have it work.
It's the textual format that is changed at will and should probably be avoided for archival.
1
u/pjmlp Jul 20 '21
Depends on the vendor, Apple keeps it stable enough for their own store purposes in watchOS and iOS.
2
u/birdbrainswagtrain Jul 20 '21
I remember trying to do something similar. I don't remember if it was just trying to parse this bizarre format that made me give up, but it was definitely a contributing factor. I wish OP better luck than I had.