summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2016-09-16 21:03:21 +0000
committerDavide Italiano <davide@freebsd.org>2016-09-16 21:03:21 +0000
commit463cfe4e607ccbf6c9c7d6f24c8e803921ca597e (patch)
tree045c20175af9ee55b5751dcec2eaa8ef2f48bdb1
parent740da34c340f913112358b3baa566fbc7f773e8d (diff)
[LTO] Add ability to parse AA pipelines.
This is supposed to be a drop in replacement for what lld provides via --lto-newpm-aa-pipeline. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281774 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/LTO/Config.h7
-rw-r--r--lib/LTO/LTOBackend.cpp11
-rw-r--r--test/tools/llvm-lto2/X86/pipeline.ll14
-rw-r--r--tools/llvm-lto2/llvm-lto2.cpp5
4 files changed, 33 insertions, 4 deletions
diff --git a/include/llvm/LTO/Config.h b/include/llvm/LTO/Config.h
index 3d19ab60497..39bddcd3ada 100644
--- a/include/llvm/LTO/Config.h
+++ b/include/llvm/LTO/Config.h
@@ -83,6 +83,11 @@ struct Config {
/// manager as the old one doesn't have this ability.
std::string OptPipeline;
+ // If this field is set, it has the same effect of specifying an AA pipeline
+ // identified by the string. Only works with the new pass manager, in
+ // conjunction OptPipeline.
+ std::string AAPipeline;
+
/// Setting this field will replace target triples in input files with this
/// triple.
std::string OverrideTriple;
@@ -170,6 +175,7 @@ struct Config {
CGOptLevel(std::move(X.CGOptLevel)), OptLevel(std::move(X.OptLevel)),
DisableVerify(std::move(X.DisableVerify)),
OptPipeline(std::move(X.OptPipeline)),
+ AAPipeline(std::move(X.AAPipeline)),
OverrideTriple(std::move(X.OverrideTriple)),
DefaultTriple(std::move(X.DefaultTriple)),
ShouldDiscardValueNames(std::move(X.ShouldDiscardValueNames)),
@@ -194,6 +200,7 @@ struct Config {
OptLevel = std::move(X.OptLevel);
DisableVerify = std::move(X.DisableVerify);
OptPipeline = std::move(X.OptPipeline);
+ AAPipeline = std::move(X.AAPipeline);
OverrideTriple = std::move(X.OverrideTriple);
DefaultTriple = std::move(X.DefaultTriple);
ShouldDiscardValueNames = std::move(X.ShouldDiscardValueNames);
diff --git a/lib/LTO/LTOBackend.cpp b/lib/LTO/LTOBackend.cpp
index 76b20b5130f..9e53972a9d4 100644
--- a/lib/LTO/LTOBackend.cpp
+++ b/lib/LTO/LTOBackend.cpp
@@ -124,9 +124,17 @@ createTargetMachine(Config &Conf, StringRef TheTriple,
static void runNewPMCustomPasses(Module &Mod, TargetMachine *TM,
std::string PipelineDesc,
+ std::string AAPipelineDesc,
bool DisableVerify) {
PassBuilder PB(TM);
AAManager AA;
+
+ // Parse a custom AA pipeline if asked to.
+ if (!AAPipelineDesc.empty())
+ if (!PB.parseAAPipeline(AA, AAPipelineDesc))
+ report_fatal_error("unable to parse AA pipeline description: " +
+ AAPipelineDesc);
+
LoopAnalysisManager LAM;
FunctionAnalysisManager FAM;
CGSCCAnalysisManager CGAM;
@@ -185,7 +193,8 @@ bool opt(Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod,
if (Conf.OptPipeline.empty())
runOldPMPasses(Conf, Mod, TM, IsThinLto);
else
- runNewPMCustomPasses(Mod, TM, Conf.OptPipeline, Conf.DisableVerify);
+ runNewPMCustomPasses(Mod, TM, Conf.OptPipeline, Conf.AAPipeline,
+ Conf.DisableVerify);
return !Conf.PostOptModuleHook || Conf.PostOptModuleHook(Task, Mod);
}
diff --git a/test/tools/llvm-lto2/X86/pipeline.ll b/test/tools/llvm-lto2/X86/pipeline.ll
index 3cdf64e8999..69c1b8b1063 100644
--- a/test/tools/llvm-lto2/X86/pipeline.ll
+++ b/test/tools/llvm-lto2/X86/pipeline.ll
@@ -2,7 +2,8 @@
; Try a custom pipeline
; RUN: llvm-lto2 %t1.bc -o %t.o -save-temps \
-; RUN: -r %t1.bc,patatino,px -opt-pipeline loweratomic
+; RUN: -r %t1.bc,patatino,px -opt-pipeline loweratomic \
+; RUN: -aa-pipeline basic-aa
; RUN: llvm-dis < %t.o.0.4.opt.bc | FileCheck %s --check-prefix=CUSTOM
target triple = "x86_64-unknown-linux-gnu"
@@ -16,9 +17,16 @@ define void @patatino() {
; CUSTOM-NEXT: ret void
; CUSTOM-NEXT: }
-; Check that invalid pipeline are caught as errors.
-; RUN: not llvm-lto2 %t1.bc -o %t.o -save-temps \
+; Check that invalid pipelines are caught as errors.
+; RUN: not llvm-lto2 %t1.bc -o %t.o \
; RUN: -r %t1.bc,patatino,px -opt-pipeline foogoo 2>&1 | \
; RUN: FileCheck %s --check-prefix=ERR
; ERR: LLVM ERROR: unable to parse pass pipeline description: foogoo
+
+; RUN: not llvm-lto2 %t1.bc -o %t.o \
+; RUN: -r %t1.bc,patatino,px -aa-pipeline patatino \
+; RUN: -opt-pipeline loweratomic 2>&1 | \
+; RUN: FileCheck %s --check-prefix=AAERR
+
+; AAERR: LLVM ERROR: unable to parse AA pipeline description: patatino
diff --git a/tools/llvm-lto2/llvm-lto2.cpp b/tools/llvm-lto2/llvm-lto2.cpp
index a2cc54ad7da..e5f0b3a1ad5 100644
--- a/tools/llvm-lto2/llvm-lto2.cpp
+++ b/tools/llvm-lto2/llvm-lto2.cpp
@@ -39,6 +39,10 @@ static cl::opt<std::string> OptPipeline("opt-pipeline",
cl::desc("Optimizer Pipeline"),
cl::value_desc("pipeline"));
+static cl::opt<std::string> AAPipeline("aa-pipeline",
+ cl::desc("Alias Analysis Pipeline"),
+ cl::value_desc("aapipeline"));
+
static cl::opt<bool> SaveTemps("save-temps", cl::desc("Save temporary files"));
static cl::opt<bool>
@@ -154,6 +158,7 @@ int main(int argc, char **argv) {
// Run a custom pipeline, if asked for.
Conf.OptPipeline = OptPipeline;
+ Conf.AAPipeline = AAPipeline;
ThinBackend Backend;
if (ThinLTODistributedIndexes)