[PATCH] D20271: [TM] Start collapsing LLVMTargetMachine into TargetMachine

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Sat May 14 20:33:04 PDT 2016


davide created this revision.
davide added reviewers: rafael, echristo, jyknight.
davide added a subscriber: llvm-commits.
Herald added a subscriber: joker.eph.

As already discussed in the review that lead to the removal of the CppBackend, it seems to be a good idea to merge LLVMTargetMachine and TargetMachine together. This patch is a first step, hopefully correct.
To put things into perspective, this work is (at least partly) motivated by the desire to make TargetMachine thread-safe, so that we can simplify the splitCodeGen() logic currently used by LTO. While the two projects may be considered orthogonal, I prefer to tackle this yak shaving.

http://reviews.llvm.org/D20271

Files:
  include/llvm/Target/TargetMachine.h
  lib/CodeGen/LLVMTargetMachine.cpp
  lib/Target/TargetMachine.cpp

Index: lib/Target/TargetMachine.cpp
===================================================================
--- lib/Target/TargetMachine.cpp
+++ lib/Target/TargetMachine.cpp
@@ -13,6 +13,7 @@
 
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
+#include "llvm/CodeGen/BasicTTIImpl.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GlobalAlias.h"
@@ -150,7 +151,7 @@
 
 TargetIRAnalysis TargetMachine::getTargetIRAnalysis() {
   return TargetIRAnalysis([this](const Function &F) {
-    return TargetTransformInfo(F.getParent()->getDataLayout());
+    return TargetTransformInfo(BasicTTIImpl(this, F));
   });
 }
 
Index: lib/CodeGen/LLVMTargetMachine.cpp
===================================================================
--- lib/CodeGen/LLVMTargetMachine.cpp
+++ lib/CodeGen/LLVMTargetMachine.cpp
@@ -86,12 +86,6 @@
   CodeGenInfo = T.createMCCodeGenInfo(TT.str(), RM, CM, OL);
 }
 
-TargetIRAnalysis LLVMTargetMachine::getTargetIRAnalysis() {
-  return TargetIRAnalysis([this](const Function &F) {
-    return TargetTransformInfo(BasicTTIImpl(this, F));
-  });
-}
-
 MachineModuleInfo &
 LLVMTargetMachine::addMachineModuleInfo(PassManagerBase &PM) const {
   MachineModuleInfo *MMI = new MachineModuleInfo(*getMCAsmInfo(),
Index: include/llvm/Target/TargetMachine.h
===================================================================
--- include/llvm/Target/TargetMachine.h
+++ include/llvm/Target/TargetMachine.h
@@ -278,12 +278,6 @@
 
   void initAsmInfo();
 public:
-  /// \brief Get a TargetIRAnalysis implementation for the target.
-  ///
-  /// This analysis will produce a TTI result which uses the common code
-  /// generator to answer queries about the IR.
-  TargetIRAnalysis getTargetIRAnalysis() override;
-
   /// Create a pass configuration object to be used by addPassToEmitX methods
   /// for generating a pipeline of CodeGen passes.
   virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20271.57291.patch
Type: text/x-patch
Size: 2003 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160515/3a6baea9/attachment.bin>


More information about the llvm-commits mailing list