This reduces the size of a statically linked Phobos-based
Hello World by 11 kB on Linux x86_64.
Also creates a header file for gen/module.cpp, which has been
renamed to "modules" such as not to conflict with the frontend
header file.
gen/module{.h, .cpp} currently is a big kitchen sink for various things
related to emitting modules. This hopefully makes the distinction between
generating the ModuleInfo data and the code to register it with druntime
clearer.
This was hit when compiling ddmd/lexer.d:1189, where a const(T)* is
implicitly cast to a const(T*).
The DLValue ctor makes sure the LL pointer and the D type are compatible.
Single intended functional change/fix: check ALL active catch blocks in
`isCatchingNonExceptions()`, not just the ones from the innermost
try-catch scope.
The catch bodies of a try-catch scope are now emitted in lexical order
(used to be reversed, last catch block first).
Invoke nothrow callees only in try-blocks with at least 1 catch-block,
otherwise call them directly.
Errors thrown by nothrow callees can thus still be caught inside a
try-catch-statement (and this is apparently required for release builds
too).
Most calls will be direct calls though, and this small change will lead
to substantially less IR as we then skip the clean-ups after an Error.
Proper clean-up when unwinding after an Error seems not to be guaranteed
anyway. There are apparent RAII front-end optimizations for structs with
nothrow dtor - see PR #1656.
Instead, put the mapping into the function-local codegen state,
where it belongs. As a side-effect of the refactoring, avoids
generating trivial "forwarding" BBs (see `nbb` in old code).
Avoids the issue from GitHub #1638 and similar altogether.
Previously, the transitory state only needed and valid during
generation of the LLVM IR for the function body was conflated
with the general codegen metadata for the function declaration
in IrFunction.
There is further potential for cleanup regarding the use of
gIR->func() and so on all over the code base, but this is out
of scope of this commit, which is only concerned with those
IrFunction members moved to FuncGenState.
GitHub: Fixes#1661.
They were only ever used in ToIRVisitor[SwitchStatement] anyway,
so just use a local vector.
The code for emitting the string switch tables was moved and slightly
refactored, but should functionally still be the same.
Really looking forward to easily being able to zip together
two containers for iteration in C++.
We should not store codegen state into the AST and the variables touched in this commit should be moved out of the AST. Added a TODO item for it.
Resolves#1638
Declare debuginfo directly on the GEP instead of on the frame alloca+offset, . An explicit DW_OP_deref is necessary (tested in LLDB).
Resolves an ICE introduced by PR #1598.