Also adds the CMake infrastructure to compile and link the D source files.
The build is partially broken:
- A few files in Phobos and druntime do not build
- MSVC build is broken because of unresolved symbols involving reals
Now with *almost* working EH codegen. Does not compile Phobos yet
because we run into the "instruction does not dominate all uses"
issue when an r-value result of toElemDtor is used and we need to
run cleanups in between. Should easily be fixed by promoting those
values to allocas.
Most of the changes outside of ir/irfunction.{h, cpp} are just
because CreateCallOrInvoke moved locations. I took the
opportunity to also make use of the different arg count
overloads where possible.
This is likely an LLVM bug: The code in InlineFunctions.cpp
only updates the source location metadata for the instructions
in the inlined callee when the call site has a source location
set. When the caller has no location metadata, the scope for
the inlined instructions thus still points to the DISubprogram
for the original callee. This then leads to an assertion during
codegen.
GitHub: Fixes#998.
This fixes a crash with debug info for lambdas, where DMD appends
the lambda function declaration to the wrong module.
But the comparison is supposed to be tautological anyway, as we
only ever call it from DtoDefineFunction. Furthermore, it seems as
passing false can never work unless you manually (without going
through llvm::DIBuilder) resolve the Vars node later. Clang does
not try to do this either.
The functions for all arrayops are compiler-generated but the functions
which are also defined in druntime are never emitted. This prevents
inlining of the function body and causes issue #938.
The fix is to emit the arrayops if inlining is enabled and otherwise
use the druntime provided implementations.
An alternative approach could be to always emit the arrayops and
never use the druntime version.
- the debug info is now stored in the IrFunction object
-> saves the lookup from VarDeclaration to IrVar
- uses a llvm::DenseMap instead of std::map
-> no comparison method required
-> hashing should be faster then a tree lookup