Mercurial > projects > ldc
view gen/linkage.h @ 1275:bedf0bfb8fdb
Implement first D-specific optimization pass: -simplify-drtcalls.
It uses the machinery of the standard -simplify-libcalls pass, but optimizes
calls to the D runtime instead of calls to C libraries.
At the moment, these optimizations are implemented by this pass:
- Avoid the runtime call for `arr.length = newlen` if it can determine that
the new length isn't longer than the old one.
- Ditto for `cast(T[]) arr` if it will clearly always succeed.
(e.g. if the length of the original array is zero, or if the old element
size is a multiple of the new element size)
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Tue, 28 Apr 2009 21:58:06 +0200 |
parents | 123812e02bc8 |
children | 3647bef175d7 |
line wrap: on
line source
#ifndef LDC_GEN_LINKAGE_H #define LDC_GEN_LINKAGE_H #include "gen/llvm-version.h" // Make it easier to test new linkage types // Also used to adapt to some changes in LLVM between 2.5 and 2.6 // LLVM r66339 introduces LinkOnceODRLinkage, which is just what we want here. // (It also renamed LinkOnceLinkage, so this #if is needed for LDC to compile // with both 2.5 and trunk) #if LLVM_REV >= 66339 # define TEMPLATE_LINKAGE_TYPE llvm::GlobalValue::LinkOnceODRLinkage # define TYPEINFO_LINKAGE_TYPE llvm::GlobalValue::LinkOnceODRLinkage // The One-Definition-Rule shouldn't matter for debug info, right? # define DEBUGINFO_LINKONCE_LINKAGE_TYPE \ llvm::GlobalValue::LinkOnceAnyLinkage // For 2.5 and any LLVM revision before 66339 we want to use LinkOnceLinkage // It's equivalent to LinkOnceAnyLinkage in trunk except that the inliner had a // hack (removed in r66339) to allow inlining of templated functions even though // LinkOnce doesn't technically allow that. #else # define TEMPLATE_LINKAGE_TYPE llvm::GlobalValue::LinkOnceLinkage # define TYPEINFO_LINKAGE_TYPE llvm::GlobalValue::LinkOnceLinkage # define DEBUGINFO_LINKONCE_LINKAGE_TYPE \ llvm::GlobalValue::LinkOnceLinkage #endif #endif