LDC_never_inline is a complementary intrinsic to LDC_allow_inline.
It tells the LLVM optimizer to never inline a function. This can be
useful if inlining creates incorrect code.
A possible application is core.thread.getStackTop().
We can't simply use the C calling convention, as the D(MD)
ABI is callee-pop, and this is hardcoded in naked functions
with stack parameters.
The \1 "trick" is normally used to avoid prefixes added by
LLVM; on the 3.2 release, a patch is needed to make it work
for the @<n> stdcall suffixes as well.
1. Main include corresponding to .cpp file, if any.
2. DMD and LDC includes.
3. LLVM includes.
4. System includes.
Also updated a few include guards to match the default format.
The solution is to replace Attribute with AttrBuilder in IrFuncTyArg.
Then the argument attributes can be easily manipulated and transformed
into the final AttributeSet.
DMD has the obscure functionality to install functions starting with
_STI_ as global ctors and funtions starting with _STD_ as global
dtors. IMHO a pragma is a better way to specify the behaviour.
This commit adds pragma(LDC_global_crt_ctor) and
pragma(LDC_global_crt_dtor). If the pragma is specified on a function
or static method then an entry is made in the corresponding list. E.g.
in monitor_.d:
extern (C) {
#pragma(LDC_global_crt_ctor)
void _STI_monitor_staticctor()
{
// ...
}
}
This works on Linux without problems. On Windows with MS C Runtime
ctors work always but dtors are invoked only if linked against the
static C runtime. Dtors on Windows require at least LLVM 3.2.
I chose to fix the problem this way because it increases uniformity
between 'this' and normal explicit parameters. Another possibility
would be to just change the type determinatin code in
DtoCreateNestedContextType to not expect the value to be already
present, because it doesn't need it when isVthisPtr is true anyway.
GitHub: Fixes#217.
Adding pragma llvm_inline_ir.
Improved the error messages.
Append "ret void" when the return type is void
Improved the error message
in case when the string passed as llvm inline ir isn't valid llvm
assembly language.
LLVM 3.2 fix.
Add attribute AlwaysInline inside DtoInlineIRFunction.
Always generate a body for llvm_inline_ir
Also, always make llvm_inline_ir functions linkonce_odr. Because
the body is always generated when a module uses a llvm_inline_ir
function, the fact that the linker removes the function shouldn't
cause problems.
Previously, set_param_attrs would overwrite any pre-existing
attributes, which is problematic, as per-function attributes are
also stored in a slot in that attribute list. This for example
lead to "noinline" being dropped for functions with inline asm.
NChybrid was the only one that didn't instantly trigger a "not
implemented" assertion on any code using nested function for a long
time, and removing the cruft greatly improves code readability
(maintainability is a moot point anyway given its current state).
Previously, we just had a hack to make ref foreach statements work.
This commit enables them to work in other cases as well, like the
implicit __result variable for functions with out-contracts (which
is such a magic ref variable for ref-returning functions).
Fixes DMD testcase 'testcontracts'.
This is based on Item 2 of "More Effective C++". In general, the C++ cast operators are more expressive and easy to find,
e.g. by grep. Using const_cast also shuts up some compiler warnings.