From c558f9caab2bf9620d06c8ce4e522a20389484c6 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Tue, 6 Nov 2012 23:53:59 +0100 Subject: [PATCH] Added -disable-simplify-libcalls. -disable-simplify-drtcalls was only intended to disable our custom druntime call simplication pass for debugging purposes. The new flag controls C runtime library calls optimizations as performed by the LLVM pass, just as the corresponding LLVM tool flags do. --- gen/optimizer.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gen/optimizer.cpp b/gen/optimizer.cpp index d01c3037..81d804d7 100644 --- a/gen/optimizer.cpp +++ b/gen/optimizer.cpp @@ -66,10 +66,15 @@ disableLangSpecificPasses("disable-d-passes", cl::ZeroOrMore); static cl::opt -disableSimplifyRuntimeCalls("disable-simplify-drtcalls", +disableSimplifyDruntimeCalls("disable-simplify-drtcalls", cl::desc("Disable simplification of druntime calls"), cl::ZeroOrMore); +static cl::opt +disableSimplifyLibCalls("disable-simplify-libcalls", + cl::desc("Disable simplification of well-known C runtime calls"), + cl::ZeroOrMore); + static cl::opt disableGCToStack("disable-gc2stack", cl::desc("Disable promotion of GC allocations to stack memory"), @@ -173,12 +178,13 @@ static void addOptimizationPasses(PassManagerBase &mpm, FunctionPassManager &fpm } else { builder.Inliner = createAlwaysInlinerPass(); } + builder.DisableSimplifyLibCalls = disableSimplifyLibCalls; builder.DisableUnitAtATime = !unitAtATime; builder.DisableUnrollLoops = optLevel == 0; /* builder.Vectorize is set in ctor from command line switch */ if (!disableLangSpecificPasses) { - if (!disableSimplifyRuntimeCalls) + if (!disableSimplifyDruntimeCalls) builder.addExtension(PassManagerBuilder::EP_LoopOptimizerEnd, addSimplifyDRuntimeCallsPass); #if USE_METADATA @@ -213,7 +219,7 @@ bool ldc_optimize_module(llvm::Module* m) TargetLibraryInfo *tli = new TargetLibraryInfo(Triple(m->getTargetTriple())); // The -disable-simplify-libcalls flag actually disables all builtin optzns. - if (disableSimplifyRuntimeCalls) + if (disableSimplifyLibCalls) tli->disableAllFunctions(); mpm.add(tli);