The raison d'etre for Apple's LLVM-based compiler was avoiding GPL3 restrictions of having to publish source code, it seems. They are frequently laggards in publishing parts of LLVM they care about and think of as competitive advantage (e.g. ARM64[1]), and they seem to not contribute much to parts of LLVM that they don't use themselves[2] (not that I find anything wrong with it, but portraying them as innate altruists is just not gonna fly.)
I would not be surprised if they get worse and worse over time in giving back to LLVM.
In short, Apple publishes free software, generally because they either (1) have to, due to GPL, or (2) feel the gain from the project is bigger than the cost of having to maintain a separate branch, so it makes perfect business sense.
(I am not criticizing that Apple has published free software and that is a good thing in general, regardless of the intent, but to say that they don't have their business interests in mind at all times and they fundamentally care about free software more than Microsoft is simply not true.)
[2]: In our own experience developing techniques to uncover more than a hundred bugs in production GCC and LLVM (http://mehrdadafshari.com/emi/paper.pdf), we found GCC folks much more responsive to bug reports than Clang/LLVM folks, of which I draw the conclusion that the project is relatively under-resourced, at least in parts that are less relevant to Apple Darwin x86/64/arm backend.
>In short, Apple publishes free software, generally because they either (1) have to, due to GPL, or (2) feel the gain from the project is bigger than the cost of having to maintain a separate branch, so it makes perfect business sense.
How is that different from any other company? Don't companies release free software when a) they are forced to, or b) they feel they have something to gain?