4 ms·
I'm pretty sure the SO answer is (partially) wrong. As far as I understand, Bitcode is not architecture agnostic, you can't just take bitcode from a 32bit compi
by newaccount74 4y ago
I'm pretty sure the SO answer is (partially) wrong. As far as I understand, Bitcode is not architecture agnostic, you can't just take bitcode from a 32bit compilation and turn it into a 64bit executable since there still are a ton of architecture dependent things (like memory alignment) in the bitcode.
- lilyball 4y agoThat's true. However it is microarchitecture agnostic.
- throw10920 4y agoIsn't machine code also microarchitecture agnostic? I thought that the definition of a microarchitecture was a particular implementation of an ISA that externally conformed to the ISA in the same way as any other microarchitecture.
- valleyer 4y agoMostly, yeah. But microarchitectures do sometimes add new instruction set extensions, like how Intel's Skylake added AVX-512. Bitcode can be re-lowered to the new extended ISA to use these instructions (assuming you don't need to target earlier uarchs). Machine code, not as easily (and I don't think anyone really tries, though I'd be interested to learn if someone does).
- legulere 4y agoLatency of instructions, number of ALUs and FPUs and available special functions differ from micro architecture to micro architecture. This makes the compiler behave differently in instruction selection when you select different micro architectures. With llvm-mca you can check how each micro architecture will behave differently for the same machine code: https://llvm.org/docs/CommandGuide/llvm-mca.html https://llvm.org/docs/CommandGuide/llvm-mca.html
- throw10920 4y agoOf course, implementation details are different between microarchitectures - that's the definition, after all. However, "agnostic" usually means that behavior doesn't vary. Performance is orthogonal to behavior in this case. I definitely don't expect code optimized for Haswell to be as fast on a Broadwell as code optimized for Broadwell, but I do at least expect it to run.
- pjmlp 4y agoThis is told a lot, because people keep missing the point that Apple has their own form of it, they don't use raw LLVM bitcode. See WWDC talk about watchOS migration to 64 bits.
- astrange 4y agoYes, this answer is wrong. LLVM IR is not generic; not only can you not recompile to new architectures, it's not always true that it doesn't care what the original language was. (Since it needs to know the aliasing/memory model rules of the original language, sometimes you need new versions of bitcode to handle new languages.) It's generic for a little while as long as things don't change too much, but eventually they do.
- bc-lee 4y agoI am one of the answerers to the SO question mentioned in this thread. With the end of support for the Apple Watch Series 3 (armv7k abi), I guess it was discontinued by Apple as they no longer needed Bitcode. Is there something I misunderstood?
- newaccount74 4y agoThis part is definitely wrong: > I may compile a C code to Bitcode and have LLVM generate a running binary for x86 CPUs in the end. If I save the Bitcode, however, I can later on tell LLVM to also create a running binary for an ARM CPU from that Bitcode, without having to compile anything and without access to the original C code. And the generated ARM code will be as good as if I had compiled to ARM from the very start. There is some other stuff in the answer that is interesting (eg. that Apple apparently never actually used Bitcode for iOS, despite what they implied) My guess is that they planned to use Bitcode to do minor optimisations for new generations of their chips, but it turned out to not work in practice, and so they scrapped it.
- bc-lee 4y agoThanks. Paragraphs you quoted are not a part of my answer.