mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 00:20:40 +03:00
Give error when selecting unsupported passmanager. (#4250)
This commit is contained in:
parent
bfa802d6c8
commit
fed90e8993
4 changed files with 29 additions and 8 deletions
|
@ -530,6 +530,17 @@ cl::opt<bool> noPLT(
|
||||||
"fno-plt", cl::ZeroOrMore,
|
"fno-plt", cl::ZeroOrMore,
|
||||||
cl::desc("Do not use the PLT to make function calls"));
|
cl::desc("Do not use the PLT to make function calls"));
|
||||||
|
|
||||||
|
cl::opt<signed char> passmanager("passmanager",
|
||||||
|
cl::desc("Setting the passmanager (new,legacy):"), cl::ZeroOrMore,
|
||||||
|
#if LDC_LLVM_VER < 1500
|
||||||
|
cl::init(0),
|
||||||
|
#else
|
||||||
|
cl::init(1),
|
||||||
|
#endif
|
||||||
|
cl::values(
|
||||||
|
clEnumValN(0, "legacy", "Use the legacy passmanager (available for LLVM14 and below) "),
|
||||||
|
clEnumValN(1, "new", "Use the new passmanager (available for LLVM14 and above)")));
|
||||||
|
|
||||||
// Math options
|
// Math options
|
||||||
bool fFastMath; // Storage for the dynamically created ffast-math option.
|
bool fFastMath; // Storage for the dynamically created ffast-math option.
|
||||||
llvm::FastMathFlags defaultFMF;
|
llvm::FastMathFlags defaultFMF;
|
||||||
|
|
|
@ -90,6 +90,8 @@ extern cl::opt<bool> noPLT;
|
||||||
extern cl::opt<bool> useDIP25;
|
extern cl::opt<bool> useDIP25;
|
||||||
extern cl::opt<bool> useDIP1000;
|
extern cl::opt<bool> useDIP1000;
|
||||||
|
|
||||||
|
extern cl::opt<signed char> passmanager;
|
||||||
|
|
||||||
// Math options
|
// Math options
|
||||||
extern bool fFastMath;
|
extern bool fFastMath;
|
||||||
extern llvm::FastMathFlags defaultFMF;
|
extern llvm::FastMathFlags defaultFMF;
|
||||||
|
|
|
@ -546,6 +546,20 @@ void parseCommandLine(Strings &sourceFiles) {
|
||||||
|
|
||||||
global.params.hdrStripPlainFunctions = !opts::hdrKeepAllBodies;
|
global.params.hdrStripPlainFunctions = !opts::hdrKeepAllBodies;
|
||||||
global.params.disableRedZone = opts::disableRedZone();
|
global.params.disableRedZone = opts::disableRedZone();
|
||||||
|
|
||||||
|
// Passmanager selection options depend on LLVM version
|
||||||
|
#if LDC_LLVM_VER < 1400
|
||||||
|
// LLVM < 14 only supports the legacy passmanager
|
||||||
|
if (opts::passmanager != 0) {
|
||||||
|
error(Loc(), "LLVM version 13 or below only supports --passmanager=legacy");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if LDC_LLVM_VER >= 1500
|
||||||
|
// LLVM >= 15 only supports the new passmanager
|
||||||
|
if (opts::passmanager != 1) {
|
||||||
|
error(Loc(), "LLVM version 15 or above only supports --passmanager=new");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void initializePasses() {
|
void initializePasses() {
|
||||||
|
|
|
@ -123,12 +123,6 @@ static cl::opt<int> fSanitizeMemoryTrackOrigins(
|
||||||
cl::desc(
|
cl::desc(
|
||||||
"Enable origins tracking in MemorySanitizer (0=disabled, default)"));
|
"Enable origins tracking in MemorySanitizer (0=disabled, default)"));
|
||||||
|
|
||||||
static cl::opt<signed char> passmanager("passmanager",
|
|
||||||
cl::desc("Setting the passmanager (new,legacy):"), cl::ZeroOrMore, cl::init(0),
|
|
||||||
cl::values(
|
|
||||||
clEnumValN(0, "legacy", "Use the legacy passmanager (available for LLVM14 and below) "),
|
|
||||||
clEnumValN(1, "new", "Use the new passmanager (available for LLVM14 and above)")));
|
|
||||||
|
|
||||||
unsigned optLevel() {
|
unsigned optLevel() {
|
||||||
// Use -O2 as a base for the size-optimization levels.
|
// Use -O2 as a base for the size-optimization levels.
|
||||||
return optimizeLevel >= 0 ? optimizeLevel : 2;
|
return optimizeLevel >= 0 ? optimizeLevel : 2;
|
||||||
|
@ -839,7 +833,7 @@ bool ldc_optimize_module(llvm::Module *M) {
|
||||||
#if LDC_LLVM_VER < 1400
|
#if LDC_LLVM_VER < 1400
|
||||||
return legacy_ldc_optimize_module(M);
|
return legacy_ldc_optimize_module(M);
|
||||||
#elif LDC_LLVM_VER < 1500
|
#elif LDC_LLVM_VER < 1500
|
||||||
return passmanager==0 ? legacy_ldc_optimize_module(M)
|
return opts::passmanager == 0 ? legacy_ldc_optimize_module(M)
|
||||||
: new_ldc_optimize_module(M);
|
: new_ldc_optimize_module(M);
|
||||||
#else
|
#else
|
||||||
return new_ldc_optimize_module(M);
|
return new_ldc_optimize_module(M);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue