3 ms·
If the intermediate representation is no more language-specific than x86, then it isn't really the compiler that's language-specific: it's modern computer archi
by whatshisface 9y ago
If the intermediate representation is no more language-specific than x86, then it isn't really the compiler that's language-specific: it's modern computer architecture.
- FeepingCreature 9y agoLLVM IR is fairly C specific. For instance, you better not be trying to write a language where null pointer access is defined...
- nicwilson 9y agoWe compile D with LLVM. Null pointer access is defined to crash, unlike C/C++ where it is undefined.
- pcwalton 9y agoAre you adding explicit checks (possibly using fault maps to optimize them)? Because if not, you're depending on undefined behavior.
- nicwilson 9y agoThat is only necessary for single objects that are bigger than one page which, we dont currently do (but should). Arrays are no problem since we check the bounds, only raw pointers cause problems.
- pcwalton 9y agoNo, it is necessary in all cases. Look at the InstCombine code I linked in a sibling comment…
- pcwalton 9y agoThis post is correct. Load of a null pointer is undefined behavior in LLVM. If you don't believe me, here is the code that optimizes based on this. https://code.woboq.org/llvm/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp.html#1033 https://code.woboq.org/llvm/llvm/lib/Transforms/InstCombine/... https://code.woboq.org/llvm/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp.html#_ZL24canSimplifyNullLoadOrGEPRN4llvm8LoadInstEPNS_5ValueE https://code.woboq.org/llvm/llvm/lib/Transforms/InstCombine/...
- discoursism 9y agoOr maybe another way to put it would be that the given language is hardware-antagonistic.