Merge pull request #1737 from JohanEngelen/disablecross

Only enable cross-module inlining when explicitly set on the commandline.
This commit is contained in:
David Nadlinger 2016-09-08 22:18:42 +01:00 committed by GitHub
commit d8249bb2e1
7 changed files with 33 additions and 21 deletions

View file

@ -94,6 +94,15 @@ bool defineAsExternallyAvailable(FuncDeclaration &fdecl) {
return false; return false;
#endif #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. // Implementation note: try to do cheap checks first.
if (fdecl.neverInline || fdecl.inlining == PINLINEnever) { if (fdecl.neverInline || fdecl.inlining == PINLINEnever) {

View file

@ -92,10 +92,10 @@ static cl::opt<cl::boolOrDefault, false, opts::FlagParser<cl::boolOrDefault>>
static llvm::cl::opt<llvm::cl::boolOrDefault, false, static llvm::cl::opt<llvm::cl::boolOrDefault, false,
opts::FlagParser<llvm::cl::boolOrDefault>> opts::FlagParser<llvm::cl::boolOrDefault>>
enableCrossModuleInlining( enableCrossModuleInlining(
"cross-module-inlining", "cross-module-inlining",
llvm::cl::desc("Enable cross-module function inlining (default enabled " llvm::cl::desc("Enable cross-module function inlining (default "
"with inlining) (LLVM >= 3.7)"), "disabled) (LLVM >= 3.7)"),
llvm::cl::ZeroOrMore, llvm::cl::Hidden); llvm::cl::ZeroOrMore, llvm::cl::Hidden);
static cl::opt<bool> unitAtATime("unit-at-a-time", cl::desc("Enable basic IPO"), static cl::opt<bool> unitAtATime("unit-at-a-time", cl::desc("Enable basic IPO"),
@ -141,8 +141,7 @@ bool willInline() {
bool willCrossModuleInline() { bool willCrossModuleInline() {
#if LDC_LLVM_VER >= 307 #if LDC_LLVM_VER >= 307
return enableCrossModuleInlining == llvm::cl::BOU_TRUE || return enableCrossModuleInlining == llvm::cl::BOU_TRUE;
(enableCrossModuleInlining == llvm::cl::BOU_UNSET && willInline());
#else #else
// Cross-module inlining is disabled for <3.7 because we don't emit symbols in // 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 // COMDAT any groups pre-LLVM3.7. With cross-module inlining enabled, without

View file

@ -2,7 +2,7 @@
// REQUIRES: atleast_llvm307 // 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; import inputs.inlinables;

View file

@ -2,10 +2,13 @@
// O0 and O3 should behave the same for these tests with explicit inlining directives by the user. // 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 // 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 -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 -of=%t.O3.ll && FileCheck %s --check-prefix OPT3 < %t.O3.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; import inputs.inlinables;

View file

@ -3,10 +3,10 @@
// REQUIRES: atleast_llvm307 // 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
// 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 %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 %S/inputs/inlinables.d -run %s // RUN: %ldc -I%S -enable-inlining -enable-cross-module-inlining %S/inputs/inlinables.d -run %s
// RUN: %ldc -I%S -O3 %S/inputs/inlinables.d -run %s // RUN: %ldc -I%S -O3 -enable-cross-module-inlining %S/inputs/inlinables.d -run %s
import inputs.inlinables; import inputs.inlinables;

View file

@ -3,7 +3,7 @@
// REQUIRES: atleast_llvm307 // 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 -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 extern (C): // simplify mangling for easier matching
@ -13,7 +13,8 @@ int foo(size_t i)
{ {
// core.bitop.bsf() is force-inlined // core.bitop.bsf() is force-inlined
import core.bitop; 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 // OPT3: call {{.*}} @llvm.cttz
return bsf(i); return bsf(i);
// OPT0: ret // OPT0: ret

View file

@ -3,16 +3,16 @@
// REQUIRES: atleast_llvm307 // 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. // Test linking too.
// Separate compilation // Separate compilation
// RUN: %ldc -c -enable-inlining %S/inputs/inlinables.d -of=%t.inlinables%obj \ // RUN: %ldc -c -enable-inlining -enable-cross-module-inlining %S/inputs/inlinables.d -of=%t.inlinables%obj \
// RUN: && %ldc -I%S -enable-inlining %t.inlinables%obj %s -of=%t%exe // RUN: && %ldc -I%S -enable-inlining -enable-cross-module-inlining %t.inlinables%obj %s -of=%t%exe
// Singleobj compilation // 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 inputs.inlinables;
import std.stdio; import std.stdio;