summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Analysis/TargetTransformInfo.h10
-rw-r--r--llvm/lib/Analysis/TargetTransformInfo.cpp15
-rw-r--r--llvm/lib/CodeGen/LLVMTargetMachine.cpp2
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp3
-rw-r--r--llvm/lib/Target/TargetMachineC.cpp3
-rw-r--r--llvm/tools/opt/opt.cpp6
6 files changed, 24 insertions, 15 deletions
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index affa9336e1f..1d3db7bfe45 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -22,6 +22,7 @@
#ifndef LLVM_ANALYSIS_TARGETTRANSFORMINFO_H
#define LLVM_ANALYSIS_TARGETTRANSFORMINFO_H
+#include "llvm/ADT/Optional.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/Pass.h"
@@ -791,7 +792,8 @@ private:
/// This pass can be constructed from a TTI object which it stores internally
/// and is queried by passes.
class TargetTransformInfoWrapperPass : public ImmutablePass {
- TargetTransformInfo TTI;
+ TargetIRAnalysis TIRA;
+ Optional<TargetTransformInfo> TTI;
virtual void anchor();
@@ -804,16 +806,16 @@ public:
/// Use the constructor below or call one of the creation routines.
TargetTransformInfoWrapperPass();
- explicit TargetTransformInfoWrapperPass(TargetTransformInfo TTI);
+ explicit TargetTransformInfoWrapperPass(TargetIRAnalysis TIRA);
- TargetTransformInfo &getTTI(Function &F) { return TTI; }
+ TargetTransformInfo &getTTI(Function &F);
};
/// \brief Create an analysis pass wrapper around a TTI object.
///
/// This analysis pass just holds the TTI instance and makes it available to
/// clients.
-ImmutablePass *createTargetTransformInfoWrapperPass(TargetTransformInfo TTI);
+ImmutablePass *createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA);
} // End llvm namespace
diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp
index 6bd79f667b4..d51cfb347ff 100644
--- a/llvm/lib/Analysis/TargetTransformInfo.cpp
+++ b/llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -280,19 +280,24 @@ char TargetTransformInfoWrapperPass::ID = 0;
void TargetTransformInfoWrapperPass::anchor() {}
TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass()
- : ImmutablePass(ID), TTI(NoTTIImpl(/*DataLayout*/ nullptr)) {
+ : ImmutablePass(ID) {
initializeTargetTransformInfoWrapperPassPass(
*PassRegistry::getPassRegistry());
}
TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass(
- TargetTransformInfo TTI)
- : ImmutablePass(ID), TTI(std::move(TTI)) {
+ TargetIRAnalysis TIRA)
+ : ImmutablePass(ID), TIRA(std::move(TIRA)) {
initializeTargetTransformInfoWrapperPassPass(
*PassRegistry::getPassRegistry());
}
+TargetTransformInfo &TargetTransformInfoWrapperPass::getTTI(Function &F) {
+ TTI = TIRA.run(F);
+ return *TTI;
+}
+
ImmutablePass *
-llvm::createTargetTransformInfoWrapperPass(TargetTransformInfo TTI) {
- return new TargetTransformInfoWrapperPass(std::move(TTI));
+llvm::createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA) {
+ return new TargetTransformInfoWrapperPass(std::move(TIRA));
}
diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
index f7377c858f3..fd242b36045 100644
--- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp
+++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
@@ -90,7 +90,7 @@ static MCContext *addPassesToGenerateCode(LLVMTargetMachine *TM,
AnalysisID StopAfter) {
// Add internal analysis passes from the target machine.
- PM.add(createTargetTransformInfoWrapperPass(TM->getTTI()));
+ PM.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
// Targets may override createPassConfig to provide a target-specific
// subclass.
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index feea6570a31..27b87764065 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -490,7 +490,8 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
mergedModule->setDataLayout(TargetMach->getDataLayout());
passes.add(new DataLayoutPass());
- passes.add(createTargetTransformInfoWrapperPass(TargetMach->getTTI()));
+ passes.add(
+ createTargetTransformInfoWrapperPass(TargetMach->getTargetIRAnalysis()));
Triple TargetTriple(TargetMach->getTargetTriple());
PassManagerBuilder PMB;
diff --git a/llvm/lib/Target/TargetMachineC.cpp b/llvm/lib/Target/TargetMachineC.cpp
index 9d759a3e644..8be10cb3262 100644
--- a/llvm/lib/Target/TargetMachineC.cpp
+++ b/llvm/lib/Target/TargetMachineC.cpp
@@ -256,5 +256,6 @@ char *LLVMGetDefaultTargetTriple(void) {
}
void LLVMAddAnalysisPasses(LLVMTargetMachineRef T, LLVMPassManagerRef PM) {
- unwrap(PM)->add(createTargetTransformInfoWrapperPass(unwrap(T)->getTTI()));
+ unwrap(PM)->add(
+ createTargetTransformInfoWrapperPass(unwrap(T)->getTargetIRAnalysis()));
}
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index af2cdd82460..00337ded99a 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -427,8 +427,8 @@ int main(int argc, char **argv) {
Passes.add(new DataLayoutPass());
// Add internal analysis passes from the target machine.
- Passes.add(createTargetTransformInfoWrapperPass(
- TM ? TM->getTTI() : TargetTransformInfo(DL)));
+ Passes.add(createTargetTransformInfoWrapperPass(TM ? TM->getTargetIRAnalysis()
+ : TargetIRAnalysis()));
std::unique_ptr<FunctionPassManager> FPasses;
if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) {
@@ -436,7 +436,7 @@ int main(int argc, char **argv) {
if (DL)
FPasses->add(new DataLayoutPass());
FPasses->add(createTargetTransformInfoWrapperPass(
- TM ? TM->getTTI() : TargetTransformInfo(DL)));
+ TM ? TM->getTargetIRAnalysis() : TargetIRAnalysis()));
}
if (PrintBreakpoints) {
OpenPOWER on IntegriCloud