mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-06 19:06:02 +03:00
Merge pull request #1737 from JohanEngelen/disablecross
Only enable cross-module inlining when explicitly set on the commandline.
This commit is contained in:
commit
d8249bb2e1
7 changed files with 33 additions and 21 deletions
|
@ -94,6 +94,15 @@ bool defineAsExternallyAvailable(FuncDeclaration &fdecl) {
|
|||
return false;
|
||||
#endif
|
||||
|
||||
// FIXME: For now, disable all cross-module inlining (also of pragma(inline, true)
|
||||
// functions). This check should be removed when cross-module inlining has
|
||||
// become more stable.
|
||||
// There are related `FIXME`s in a few lit-based `codegen/inlining_*.d` tests.
|
||||
if (!willCrossModuleInline()) {
|
||||
IF_LOG Logger::println("Cross-module inlining fully disabled.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Implementation note: try to do cheap checks first.
|
||||
|
||||
if (fdecl.neverInline || fdecl.inlining == PINLINEnever) {
|
||||
|
|
|
@ -92,10 +92,10 @@ static cl::opt<cl::boolOrDefault, false, opts::FlagParser<cl::boolOrDefault>>
|
|||
|
||||
static llvm::cl::opt<llvm::cl::boolOrDefault, false,
|
||||
opts::FlagParser<llvm::cl::boolOrDefault>>
|
||||
enableCrossModuleInlining(
|
||||
enableCrossModuleInlining(
|
||||
"cross-module-inlining",
|
||||
llvm::cl::desc("Enable cross-module function inlining (default enabled "
|
||||
"with inlining) (LLVM >= 3.7)"),
|
||||
llvm::cl::desc("Enable cross-module function inlining (default "
|
||||
"disabled) (LLVM >= 3.7)"),
|
||||
llvm::cl::ZeroOrMore, llvm::cl::Hidden);
|
||||
|
||||
static cl::opt<bool> unitAtATime("unit-at-a-time", cl::desc("Enable basic IPO"),
|
||||
|
@ -141,8 +141,7 @@ bool willInline() {
|
|||
|
||||
bool willCrossModuleInline() {
|
||||
#if LDC_LLVM_VER >= 307
|
||||
return enableCrossModuleInlining == llvm::cl::BOU_TRUE ||
|
||||
(enableCrossModuleInlining == llvm::cl::BOU_UNSET && willInline());
|
||||
return enableCrossModuleInlining == llvm::cl::BOU_TRUE;
|
||||
#else
|
||||
// Cross-module inlining is disabled for <3.7 because we don't emit symbols in
|
||||
// COMDAT any groups pre-LLVM3.7. With cross-module inlining enabled, without
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// REQUIRES: atleast_llvm307
|
||||
|
||||
// RUN: %ldc %s -I%S -c -output-ll -release -O3 -of=%t.O3.ll && FileCheck %s --check-prefix OPT3 < %t.O3.ll
|
||||
// RUN: %ldc %s -I%S -c -output-ll -release -O3 -enable-cross-module-inlining -of=%t.O3.ll && FileCheck %s --check-prefix OPT3 < %t.O3.ll
|
||||
|
||||
import inputs.inlinables;
|
||||
|
||||
|
|
|
@ -2,10 +2,13 @@
|
|||
|
||||
// O0 and O3 should behave the same for these tests with explicit inlining directives by the user.
|
||||
|
||||
// FIXME: Currently cross-module inlining is completely disabled per default, also for pragma(inline,true) functions.
|
||||
// The `-enable-cross-module-inlining` flag is therefore necessary for now, but should be removed in the future.
|
||||
|
||||
// REQUIRES: atleast_llvm307
|
||||
|
||||
// RUN: %ldc %s -I%S -c -output-ll -O0 -of=%t.O0.ll && FileCheck %s --check-prefix OPTNONE < %t.O0.ll
|
||||
// RUN: %ldc %s -I%S -c -output-ll -O3 -of=%t.O3.ll && FileCheck %s --check-prefix OPT3 < %t.O3.ll
|
||||
// RUN: %ldc %s -I%S -c -output-ll -O0 -enable-cross-module-inlining -of=%t.O0.ll && FileCheck %s --check-prefix OPTNONE < %t.O0.ll
|
||||
// RUN: %ldc %s -I%S -c -output-ll -O3 -enable-cross-module-inlining -of=%t.O3.ll && FileCheck %s --check-prefix OPT3 < %t.O3.ll
|
||||
|
||||
import inputs.inlinables;
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
// REQUIRES: atleast_llvm307
|
||||
|
||||
// RUN: %ldc %s -I%S -c -output-ll -release -O3 -of=%t.O3.ll && FileCheck %s --check-prefix OPT3 < %t.O3.ll
|
||||
// RUN: %ldc %s -I%S -c -output-ll -release -enable-inlining -O0 -of=%t.O0.ll && FileCheck %s --check-prefix OPT0 < %t.O0.ll
|
||||
// RUN: %ldc -I%S -enable-inlining %S/inputs/inlinables.d -run %s
|
||||
// RUN: %ldc -I%S -O3 %S/inputs/inlinables.d -run %s
|
||||
// RUN: %ldc %s -I%S -c -output-ll -release -O3 -enable-cross-module-inlining -of=%t.O3.ll && FileCheck %s --check-prefix OPT3 < %t.O3.ll
|
||||
// RUN: %ldc %s -I%S -c -output-ll -release -enable-inlining -O0 -enable-cross-module-inlining -of=%t.O0.ll && FileCheck %s --check-prefix OPT0 < %t.O0.ll
|
||||
// RUN: %ldc -I%S -enable-inlining -enable-cross-module-inlining %S/inputs/inlinables.d -run %s
|
||||
// RUN: %ldc -I%S -O3 -enable-cross-module-inlining %S/inputs/inlinables.d -run %s
|
||||
|
||||
import inputs.inlinables;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// REQUIRES: atleast_llvm307
|
||||
|
||||
// RUN: %ldc %s -c -output-ll -release -O0 -of=%t.O0.ll && FileCheck %s --check-prefix OPT0 < %t.O0.ll
|
||||
// RUN: %ldc %s -c -output-ll -release -O3 -of=%t.O3.ll && FileCheck %s --check-prefix OPT3 < %t.O3.ll
|
||||
// RUN: %ldc %s -c -output-ll -release -O3 -enable-cross-module-inlining -of=%t.O3.ll && FileCheck %s --check-prefix OPT3 < %t.O3.ll
|
||||
|
||||
extern (C): // simplify mangling for easier matching
|
||||
|
||||
|
@ -13,7 +13,8 @@ int foo(size_t i)
|
|||
{
|
||||
// core.bitop.bsf() is force-inlined
|
||||
import core.bitop;
|
||||
// OPT0: call {{.*}} @llvm.cttz
|
||||
// FIXME: The OPT0 check is disabled for now, because cross-module inlining is disabled fully (also for `pragma(inline, true)` functions).
|
||||
// O PT0: call {{.*}} @llvm.cttz
|
||||
// OPT3: call {{.*}} @llvm.cttz
|
||||
return bsf(i);
|
||||
// OPT0: ret
|
||||
|
|
|
@ -3,16 +3,16 @@
|
|||
|
||||
// REQUIRES: atleast_llvm307
|
||||
|
||||
// RUN: %ldc %s -I%S -c -output-ll -release -enable-inlining -O0 -of=%t.O0.ll && FileCheck %s < %t.O0.ll
|
||||
// RUN: %ldc %s -I%S -c -output-ll -release -enable-inlining -enable-cross-module-inlining -O0 -of=%t.O0.ll && FileCheck %s < %t.O0.ll
|
||||
|
||||
// RUN: %ldc -singleobj %S/inputs/inlinables.d %s -I%S -c -output-ll -release -enable-inlining -O0 -of=%t.singleobj.O0.ll && FileCheck %s < %t.singleobj.O0.ll
|
||||
// RUN: %ldc -singleobj %S/inputs/inlinables.d %s -I%S -c -output-ll -release -enable-inlining -enable-cross-module-inlining -O0 -of=%t.singleobj.O0.ll && FileCheck %s < %t.singleobj.O0.ll
|
||||
|
||||
// Test linking too.
|
||||
// Separate compilation
|
||||
// RUN: %ldc -c -enable-inlining %S/inputs/inlinables.d -of=%t.inlinables%obj \
|
||||
// RUN: && %ldc -I%S -enable-inlining %t.inlinables%obj %s -of=%t%exe
|
||||
// RUN: %ldc -c -enable-inlining -enable-cross-module-inlining %S/inputs/inlinables.d -of=%t.inlinables%obj \
|
||||
// RUN: && %ldc -I%S -enable-inlining -enable-cross-module-inlining %t.inlinables%obj %s -of=%t%exe
|
||||
// Singleobj compilation
|
||||
// RUN: %ldc -I%S -enable-inlining -singleobj %S/inputs/inlinables.d %s -of=%t2%exe
|
||||
// RUN: %ldc -I%S -enable-inlining -enable-cross-module-inlining -singleobj %S/inputs/inlinables.d %s -of=%t2%exe
|
||||
|
||||
import inputs.inlinables;
|
||||
import std.stdio;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue