mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-04-27 13:40:33 +03:00

I.e., *define* templated symbols in each referencing compilation unit when using discardable linkonce_odr linkage, analogous to C++. This makes each compilation unit self-sufficient wrt. templated symbols, which also means increased opportunity for inlining and less need for LTO. There should be no more undefined symbol issues caused by buggy template culling. The biggest advantage is that the optimizer can discard unused linkonce_odr symbols early instead of optimizing and forwarding to the assembler. So this is especially useful with -O to decrease compilation times and can at least in some scenarios greatly outweigh the (potentially very much) higher number of symbols defined by the glue layer. Libraries compiled with -linkonce-templates can generally not be linked against dependent code compiled without -linkonce-templates; the other way around works.
26 lines
941 B
C++
26 lines
941 B
C++
//===-- gen/function-inlining.h ---------------------------------*- C++ -*-===//
|
||
//
|
||
// LDC – the LLVM D compiler
|
||
//
|
||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||
// file for details.
|
||
//
|
||
//===----------------------------------------------------------------------===//
|
||
//
|
||
// Determines whether a function is fit for inlining or not.
|
||
//
|
||
//===----------------------------------------------------------------------===//
|
||
|
||
#pragma once
|
||
|
||
class FuncDeclaration;
|
||
|
||
/// Check whether the frontend knows that the function is already defined
|
||
/// in some other module (see DMD's `FuncDeclaration_toObjFile()`).
|
||
bool skipCodegen(FuncDeclaration &fdecl);
|
||
|
||
/// Returns whether `fdecl` should be emitted with externally_available
|
||
/// linkage to make it available for inlining.
|
||
///
|
||
/// If true, `semantic3` will have been run on the declaration.
|
||
bool defineAsExternallyAvailable(FuncDeclaration &fdecl);
|