The title might not be sufficient to give an overview of the question context. So here goes the description:
SWIFT Compilation process The Swift compiler undergoes the following steps to compile a Swift file
As per Apple,
IR generation (implemented in lib/IRGen) lowers SIL to LLVM IR, at which point LLVM can continue to optimize it and generate machine code.
Query Number 1 - We all know that compiler turns our source code to Assembly Language and Assembler(mostly embedded in OS, at least Swift compiler doesn't have an assembler in it) converts that into Machine code. So as per the quoted statement above, the LLVM in compiler changes the LLVM IR to machine code. So if this is the case then the assembler would be having no role to play in a Swift program and execution?
Query Number 2 - LLVM in Swift changes the LLVM IR directly to machine code. So that means my compiled executable binary has machine code, not assembly code. And as per my understanding machine code doesn't need any specific calling convention as an assembly language has, and ABI is all about calling conventions, memory layout representations, etc via which the communication between two binaries is defined. So where does ABI comes in the picture then because the binary executable already has the machine code?
So is there something I am missing or Apple has kept it quite abstract?
There is a nice description of the role of ABI in ABI Stability Manifesto.
In summary, ABI is about the communication layer between compiled application modules during linking and runtime. For example the application and a compiled static library. Or the application and the standard library (Swift runtime).
ABI answers the questions like:
how is a function stored? how is the name stored? how are its parameters stored? How are default parameter values stored? how are attributes (e.g. availability) stored?, how are generics stored? Where do you find the machine instructions for a function?
how to put parameters on the calling stack before starting executing function machine instructions (that is, how to pass parameters and self
to a function?). This is what the calling conventions is.
If you have two versions of a Swift compiler and each uses a different format, they cannot call each other because they don't know how to interpret the information in the files. That's why ABI stability is needed. It stabilizes the way code is stored. Note that machine instructions are the body of functions but all the other metadata has to be stored too.
Assembly has no role in ABI stability. Assembly is just another low level programming language which is not used in Swift.