<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 17, 2014 at 5:34 PM, Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: echristo<br>
Date: Wed Sep 17 19:34:14 2014<br>
New Revision: 218004<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=218004&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=218004&view=rev</a><br>
Log:<br>
Add a new pass FunctionTargetTransformInfo. This pass serves as a<br>
shim between the TargetTransformInfo immutable pass and the Subtarget<br>
via the TargetMachine and Function. Migrate a single call from<br>
BasicTargetTransformInfo as an example and provide shims where TargetMachine<br>
begins taking a Function to determine the subtarget.<br>
<br>
No functional change.<br>
<br>
Added:<br>
    llvm/trunk/include/llvm/Analysis/FunctionTargetTransformInfo.h<br>
    llvm/trunk/lib/Analysis/FunctionTargetTransformInfo.cpp<br>
Modified:<br>
    llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h<br>
    llvm/trunk/include/llvm/InitializePasses.h<br>
    llvm/trunk/include/llvm/Target/TargetMachine.h<br>
    llvm/trunk/lib/Analysis/TargetTransformInfo.cpp<br>
    llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp<br>
    llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp<br>
    llvm/trunk/lib/Target/R600/AMDGPUTargetTransformInfo.cpp<br>
    llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp<br>
<br>
Added: llvm/trunk/include/llvm/Analysis/FunctionTargetTransformInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/FunctionTargetTransformInfo.h?rev=218004&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/FunctionTargetTransformInfo.h?rev=218004&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Analysis/FunctionTargetTransformInfo.h (added)<br>
+++ llvm/trunk/include/llvm/Analysis/FunctionTargetTransformInfo.h Wed Sep 17 19:34:14 2014<br>
@@ -0,0 +1,49 @@<br>
+//===- llvm/Analysis/FunctionTargetTransformInfo.h --------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+//<br>
+// This pass wraps a TargetTransformInfo in a FunctionPass so that it can<br>
+// forward along the current Function so that we can make target specific<br>
+// decisions based on the particular subtarget specified for each Function.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#ifndef LLVM_ANALYSIS_FUNCTIONTARGETTRANSFORMINFO_H<br>
+#define LLVM_ANALYSIS_FUNCTIONTARGETTRANSFORMINFO_H<br>
+<br>
+#include "llvm/Pass.h"<br>
+#include "TargetTransformInfo.h"<br>
+<br>
+namespace llvm {<br>
+class FunctionTargetTransformInfo final : public FunctionPass {<br>
+private:<br>
+  const Function *Fn;<br>
+  const TargetTransformInfo *TTI;<br>
+<br>
+  FunctionTargetTransformInfo(const FunctionTargetTransformInfo &)<br>
+      LLVM_DELETED_FUNCTION;<br>
+  void operator=(const FunctionTargetTransformInfo &) LLVM_DELETED_FUNCTION;<br>
+<br>
+public:<br>
+  static char ID;<br>
+  FunctionTargetTransformInfo();<br>
+<br>
+  // Implementation boilerplate.<br>
+  void getAnalysisUsage(AnalysisUsage &AU) const override;<br>
+  void releaseMemory() override;<br>
+  bool runOnFunction(Function &F) override;<br>
+<br>
+  // Shimmed functions from TargetTransformInfo.<br>
+  void<br>
+  getUnrollingPreferences(Loop *L,<br>
+                          TargetTransformInfo::UnrollingPreferences &UP) const {<br>
+    TTI->getUnrollingPreferences(Fn, L, UP);<br>
+  }<br>
+};<br>
+}<br>
+#endif<br>
<br>
Modified: llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h?rev=218004&r1=218003&r2=218004&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h?rev=218004&r1=218003&r2=218004&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h (original)<br>
+++ llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h Wed Sep 17 19:34:14 2014<br>
@@ -28,6 +28,7 @@<br>
<br>
 namespace llvm {<br>
<br>
+class Function;<br>
 class GlobalValue;<br>
 class Loop;<br>
 class Type;<br>
@@ -227,7 +228,8 @@ public:<br>
   /// \brief Get target-customized preferences for the generic loop unrolling<br>
   /// transformation. The caller will initialize UP with the current<br>
   /// target-independent defaults.<br>
-  virtual void getUnrollingPreferences(Loop *L, UnrollingPreferences &UP) const;<br>
+  virtual void getUnrollingPreferences(const Function *F, Loop *L,<br>
+                                       UnrollingPreferences &UP) const;<br>
<br>
   /// @}<br>
<br>
<br>
Modified: llvm/trunk/include/llvm/InitializePasses.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=218004&r1=218003&r2=218004&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=218004&r1=218003&r2=218004&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/InitializePasses.h (original)<br>
+++ llvm/trunk/include/llvm/InitializePasses.h Wed Sep 17 19:34:14 2014<br>
@@ -261,6 +261,7 @@ void initializeTailDuplicatePassPass(Pas<br>
 void initializeTargetPassConfigPass(PassRegistry&);<br>
 void initializeDataLayoutPassPass(PassRegistry &);<br>
 void initializeTargetTransformInfoAnalysisGroup(PassRegistry&);<br>
+void initializeFunctionTargetTransformInfoPass(PassRegistry &);<br>
 void initializeNoTTIPass(PassRegistry&);<br>
 void initializeTargetLibraryInfoPass(PassRegistry&);<br>
 void initializeAssumptionTrackerPass(PassRegistry &);<br>
<br>
Modified: llvm/trunk/include/llvm/Target/TargetMachine.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=218004&r1=218003&r2=218004&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=218004&r1=218003&r2=218004&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Target/TargetMachine.h (original)<br>
+++ llvm/trunk/include/llvm/Target/TargetMachine.h Wed Sep 17 19:34:14 2014<br>
@@ -99,6 +99,9 @@ public:<br>
   virtual const TargetSubtargetInfo *getSubtargetImpl() const {<br>
     return nullptr;<br>
   }<br>
+  virtual const TargetSubtargetInfo *getSubtargetImpl(const Function *) const {<br>
+    return getSubtargetImpl();<br></blockquote><div><br></div><div>So what's left to do to make this actually do the real work of picking a Subtarget based on the Function? I'm just curious about where that'll fit in your migration plan?<br><br>Once this function is actually implemented, would it be possible to test just this one change (& then test each subsequent feature as you port it over)? </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  }<br>
<br>
   /// getSubtarget - This method returns a pointer to the specified type of<br>
   /// TargetSubtargetInfo.  In debug builds, it verifies that the object being<br>
@@ -106,6 +109,9 @@ public:<br>
   template<typename STC> const STC &getSubtarget() const {<br>
     return *static_cast<const STC*>(getSubtargetImpl());<br>
   }<br>
+  template <typename STC> const STC &getSubtarget(const Function *) const {<br>
+    return *static_cast<const STC*>(getSubtargetImpl());<br>
+  }<br>
<br>
   /// \brief Reset the target options based on the function's attributes.<br>
   void resetTargetOptions(const MachineFunction *MF) const;<br>
<br>
Added: llvm/trunk/lib/Analysis/FunctionTargetTransformInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/FunctionTargetTransformInfo.cpp?rev=218004&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/FunctionTargetTransformInfo.cpp?rev=218004&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/FunctionTargetTransformInfo.cpp (added)<br>
+++ llvm/trunk/lib/Analysis/FunctionTargetTransformInfo.cpp Wed Sep 17 19:34:14 2014<br>
@@ -0,0 +1,50 @@<br>
+//===- llvm/Analysis/FunctionTargetTransformInfo.h --------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+//<br>
+// This pass wraps a TargetTransformInfo in a FunctionPass so that it can<br>
+// forward along the current Function so that we can make target specific<br>
+// decisions based on the particular subtarget specified for each Function.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "llvm/InitializePasses.h"<br>
+#include "llvm/Analysis/FunctionTargetTransformInfo.h"<br>
+<br>
+using namespace llvm;<br>
+<br>
+#define DEBUG_TYPE "function-tti"<br>
+static const char ftti_name[] = "Function TargetTransformInfo";<br>
+INITIALIZE_PASS_BEGIN(FunctionTargetTransformInfo, "function_tti", ftti_name, false, true)<br>
+INITIALIZE_AG_DEPENDENCY(TargetTransformInfo)<br>
+INITIALIZE_PASS_END(FunctionTargetTransformInfo, "function_tti", ftti_name, false, true)<br>
+char FunctionTargetTransformInfo::ID = 0;<br>
+<br>
+namespace llvm {<br>
+FunctionPass *createFunctionTargetTransformInfoPass() {<br>
+  return new FunctionTargetTransformInfo();<br>
+}<br>
+}<br>
+<br>
+FunctionTargetTransformInfo::FunctionTargetTransformInfo()<br>
+  : FunctionPass(ID), Fn(nullptr), TTI(nullptr) {<br>
+  initializeFunctionTargetTransformInfoPass(*PassRegistry::getPassRegistry());<br>
+}<br>
+<br>
+void FunctionTargetTransformInfo::getAnalysisUsage(AnalysisUsage &AU) const {<br>
+  AU.setPreservesAll();<br>
+  AU.addRequired<TargetTransformInfo>();<br>
+}<br>
+<br>
+void FunctionTargetTransformInfo::releaseMemory() {}<br>
+<br>
+bool FunctionTargetTransformInfo::runOnFunction(Function &F) {<br>
+  Fn = &F;<br>
+  TTI = &getAnalysis<TargetTransformInfo>();<br>
+  return false;<br>
+}<br>
<br>
Modified: llvm/trunk/lib/Analysis/TargetTransformInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TargetTransformInfo.cpp?rev=218004&r1=218003&r2=218004&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TargetTransformInfo.cpp?rev=218004&r1=218003&r2=218004&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/TargetTransformInfo.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/TargetTransformInfo.cpp Wed Sep 17 19:34:14 2014<br>
@@ -87,9 +87,10 @@ bool TargetTransformInfo::isLoweredToCal<br>
   return PrevTTI->isLoweredToCall(F);<br>
 }<br>
<br>
-void TargetTransformInfo::getUnrollingPreferences(Loop *L,<br>
-                            UnrollingPreferences &UP) const {<br>
-  PrevTTI->getUnrollingPreferences(L, UP);<br>
+void<br>
+TargetTransformInfo::getUnrollingPreferences(const Function *F, Loop *L,<br>
+                                             UnrollingPreferences &UP) const {<br>
+  PrevTTI->getUnrollingPreferences(F, L, UP);<br>
 }<br>
<br>
 bool TargetTransformInfo::isLegalAddImmediate(int64_t Imm) const {<br>
@@ -487,8 +488,8 @@ struct NoTTI final : ImmutablePass, Targ<br>
     return true;<br>
   }<br>
<br>
-  void getUnrollingPreferences(Loop *, UnrollingPreferences &) const override {<br>
-  }<br>
+  void getUnrollingPreferences(const Function *, Loop *,<br>
+                               UnrollingPreferences &) const override {}<br>
<br>
   bool isLegalAddImmediate(int64_t Imm) const override {<br>
     return false;<br>
<br>
Modified: llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp?rev=218004&r1=218003&r2=218004&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp?rev=218004&r1=218003&r2=218004&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp Wed Sep 17 19:34:14 2014<br>
@@ -92,7 +92,7 @@ public:<br>
   unsigned getJumpBufSize() const override;<br>
   bool shouldBuildLookupTables() const override;<br>
   bool haveFastSqrt(Type *Ty) const override;<br>
-  void getUnrollingPreferences(Loop *L,<br>
+  void getUnrollingPreferences(const Function *F, Loop *L,<br></blockquote><div><br></div><div>Would it make more sense for this to take the TargetSubtargetInfo directly? A more constrained API (makes it clear what this function is using - just the subtarget info, not other things with the Function) and potentially fewer Subtarget lookups (which are zero cost today, but later will become at least some kind of map lookup/lazy construction/etc?).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                                UnrollingPreferences &UP) const override;<br>
<br>
   /// @}<br>
@@ -199,7 +199,7 @@ bool BasicTTI::haveFastSqrt(Type *Ty) co<br>
   return TLI->isTypeLegal(VT) && TLI->isOperationLegalOrCustom(ISD::FSQRT, VT);<br>
 }<br>
<br>
-void BasicTTI::getUnrollingPreferences(Loop *L,<br>
+void BasicTTI::getUnrollingPreferences(const Function *F, Loop *L,<br>
                                        UnrollingPreferences &UP) const {<br>
   // This unrolling functionality is target independent, but to provide some<br>
   // motivation for its intended use, for x86:<br>
@@ -225,7 +225,7 @@ void BasicTTI::getUnrollingPreferences(L<br>
   // until someone finds a case where it matters in practice.<br>
<br>
   unsigned MaxOps;<br>
-  const TargetSubtargetInfo *ST = &TM->getSubtarget<TargetSubtargetInfo>();<br>
+  const TargetSubtargetInfo *ST = &TM->getSubtarget<TargetSubtargetInfo>(F);<br>
   if (PartialUnrollingThreshold.getNumOccurrences() > 0)<br>
     MaxOps = PartialUnrollingThreshold;<br>
   else if (ST->getSchedModel().LoopMicroOpBufferSize > 0)<br>
<br>
Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp?rev=218004&r1=218003&r2=218004&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp?rev=218004&r1=218003&r2=218004&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp (original)<br>
+++ llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp Wed Sep 17 19:34:14 2014<br>
@@ -38,6 +38,7 @@ void initializePPCTTIPass(PassRegistry &<br>
 namespace {<br>
<br>
 class PPCTTI final : public ImmutablePass, public TargetTransformInfo {<br>
+  const TargetMachine *TM;<br>
   const PPCSubtarget *ST;<br>
   const PPCTargetLowering *TLI;<br>
<br>
@@ -47,7 +48,7 @@ public:<br>
   }<br>
<br>
   PPCTTI(const PPCTargetMachine *TM)<br>
-      : ImmutablePass(ID), ST(TM->getSubtargetImpl()),<br>
+      : ImmutablePass(ID), TM(TM), ST(TM->getSubtargetImpl()),<br>
         TLI(TM->getSubtargetImpl()->getTargetLowering()) {<br>
     initializePPCTTIPass(*PassRegistry::getPassRegistry());<br>
   }<br>
@@ -80,8 +81,8 @@ public:<br>
                          Type *Ty) const override;<br>
<br>
   PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override;<br>
-  void getUnrollingPreferences(<br>
-    Loop *L, UnrollingPreferences &UP) const override;<br>
+  void getUnrollingPreferences(const Function *F, Loop *L,<br>
+                               UnrollingPreferences &UP) const override;<br>
<br>
   /// @}<br>
<br>
@@ -269,8 +270,9 @@ unsigned PPCTTI::getIntImmCost(unsigned<br>
   return PPCTTI::getIntImmCost(Imm, Ty);<br>
 }<br>
<br>
-void PPCTTI::getUnrollingPreferences(Loop *L, UnrollingPreferences &UP) const {<br>
-  if (ST->getDarwinDirective() == PPC::DIR_A2) {<br>
+void PPCTTI::getUnrollingPreferences(const Function *F, Loop *L,<br>
+                                     UnrollingPreferences &UP) const {<br></blockquote><div><br></div><div>And in places like this, if you passed the Subtarget, you could even call it "ST" and then the body of the function wouldn't need any changes at all. (granted, shadowing is subtle stuff... so I can understand if that's not ideal - but given the ultimate future will end up removing the member variable, it might be an acceptable intermediate state to reduce typing/churn)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  if (TM->getSubtarget<PPCSubtarget>(F).getDarwinDirective() == PPC::DIR_A2) {<br>
     // The A2 is in-order with a deep pipeline, and concatenation unrolling<br>
     // helps expose latency-hiding opportunities to the instruction scheduler.<br>
     UP.Partial = UP.Runtime = true;<br>
<br>
Modified: llvm/trunk/lib/Target/R600/AMDGPUTargetTransformInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/AMDGPUTargetTransformInfo.cpp?rev=218004&r1=218003&r2=218004&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/AMDGPUTargetTransformInfo.cpp?rev=218004&r1=218003&r2=218004&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/R600/AMDGPUTargetTransformInfo.cpp (original)<br>
+++ llvm/trunk/lib/Target/R600/AMDGPUTargetTransformInfo.cpp Wed Sep 17 19:34:14 2014<br>
@@ -74,7 +74,7 @@ public:<br>
<br>
   bool hasBranchDivergence() const override;<br>
<br>
-  void getUnrollingPreferences(Loop *L,<br>
+  void getUnrollingPreferences(const Function *F, Loop *L,<br>
                                UnrollingPreferences &UP) const override;<br>
<br>
   PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) const override;<br>
@@ -99,7 +99,7 @@ llvm::createAMDGPUTargetTransformInfoPas<br>
<br>
 bool AMDGPUTTI::hasBranchDivergence() const { return true; }<br>
<br>
-void AMDGPUTTI::getUnrollingPreferences(Loop *L,<br>
+void AMDGPUTTI::getUnrollingPreferences(const Function *, Loop *L,<br>
                                         UnrollingPreferences &UP) const {<br>
   UP.Threshold = 300; // Twice the default.<br>
   UP.Count = UINT_MAX;<br>
<br>
Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp?rev=218004&r1=218003&r2=218004&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp?rev=218004&r1=218003&r2=218004&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp Wed Sep 17 19:34:14 2014<br>
@@ -15,6 +15,7 @@<br>
 #include "llvm/Transforms/Scalar.h"<br>
 #include "llvm/Analysis/AssumptionTracker.h"<br>
 #include "llvm/Analysis/CodeMetrics.h"<br>
+#include "llvm/Analysis/FunctionTargetTransformInfo.h"<br>
 #include "llvm/Analysis/LoopPass.h"<br>
 #include "llvm/Analysis/ScalarEvolution.h"<br>
 #include "llvm/Analysis/TargetTransformInfo.h"<br>
@@ -113,6 +114,7 @@ namespace {<br>
       AU.addRequired<ScalarEvolution>();<br>
       AU.addPreserved<ScalarEvolution>();<br>
       AU.addRequired<TargetTransformInfo>();<br>
+      AU.addRequired<FunctionTargetTransformInfo>();<br>
       // FIXME: Loop unroll requires LCSSA. And LCSSA requires dom info.<br>
       // If loop unroll does not preserve dom info then LCSSA pass on next<br>
       // loop will receive invalid dom info.<br>
@@ -122,7 +124,7 @@ namespace {<br>
<br>
     // Fill in the UnrollingPreferences parameter with values from the<br>
     // TargetTransformationInfo.<br>
-    void getUnrollingPreferences(Loop *L, const TargetTransformInfo &TTI,<br>
+    void getUnrollingPreferences(Loop *L, const FunctionTargetTransformInfo &FTTI,<br></blockquote><div><br></div><div>Hmm - might chat to you offline to better understand the relationship between a Target and a TargetTransformInfo and a Subtarget and the FunctionTargetTransformInfo (the proto-question forming in my head is "why not move the Function-requiring operations to the FunctionTargetTransformInfo (& have the FTTI use a Subtarget member, rather than a Function member passed down into the TTI)"... probably lots of good reasons that I know nothing about))</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                                  TargetTransformInfo::UnrollingPreferences &UP) {<br>
       UP.Threshold = CurrentThreshold;<br>
       UP.OptSizeThreshold = OptSizeUnrollThreshold;<br>
@@ -132,7 +134,7 @@ namespace {<br>
       UP.MaxCount = UINT_MAX;<br>
       UP.Partial = CurrentAllowPartial;<br>
       UP.Runtime = CurrentRuntime;<br>
-      TTI.getUnrollingPreferences(L, UP);<br>
+      FTTI.getUnrollingPreferences(L, UP);<br>
     }<br>
<br>
     // Select and return an unroll count based on parameters from<br>
@@ -185,6 +187,7 @@ char LoopUnroll::ID = 0;<br>
 INITIALIZE_PASS_BEGIN(LoopUnroll, "loop-unroll", "Unroll loops", false, false)<br>
 INITIALIZE_AG_DEPENDENCY(TargetTransformInfo)<br>
 INITIALIZE_PASS_DEPENDENCY(AssumptionTracker)<br>
+INITIALIZE_PASS_DEPENDENCY(FunctionTargetTransformInfo)<br>
 INITIALIZE_PASS_DEPENDENCY(LoopInfo)<br>
 INITIALIZE_PASS_DEPENDENCY(LoopSimplify)<br>
 INITIALIZE_PASS_DEPENDENCY(LCSSA)<br>
@@ -358,6 +361,8 @@ bool LoopUnroll::runOnLoop(Loop *L, LPPa<br>
   LoopInfo *LI = &getAnalysis<LoopInfo>();<br>
   ScalarEvolution *SE = &getAnalysis<ScalarEvolution>();<br>
   const TargetTransformInfo &TTI = getAnalysis<TargetTransformInfo>();<br>
+  const FunctionTargetTransformInfo &FTTI =<br>
+      getAnalysis<FunctionTargetTransformInfo>();<br>
   AssumptionTracker *AT = &getAnalysis<AssumptionTracker>();<br>
<br>
   BasicBlock *Header = L->getHeader();<br>
@@ -372,7 +377,7 @@ bool LoopUnroll::runOnLoop(Loop *L, LPPa<br>
   bool HasPragma = PragmaFullUnroll || PragmaCount > 0;<br>
<br>
   TargetTransformInfo::UnrollingPreferences UP;<br>
-  getUnrollingPreferences(L, TTI, UP);<br>
+  getUnrollingPreferences(L, FTTI, UP);<br>
<br>
   // Find trip count and trip multiple if count is not available<br>
   unsigned TripCount = 0;<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>