<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 1, 2015 at 6:11 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 Jul  1 20:11:47 2015<br>
New Revision: 241220<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D241220-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=k7JRKcYxF7Om4zfoGN5X6v30DyQT_UvgvI-OUGvC0z4&s=Hc7K7rkFcwl0LLkNtGKyEZVJj3svHgpgQTuF5BJ7DC0&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=241220&view=rev</a><br>
Log:<br>
Add a routine to TargetTransformInfo that will allow targets to look<br>
at the attributes on a function to determine whether or not to allow<br>
inlining.<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h<br>
    llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h<br>
    llvm/trunk/lib/Analysis/IPA/InlineCost.cpp<br>
    llvm/trunk/lib/Analysis/TargetTransformInfo.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_Analysis_TargetTransformInfo.h-3Frev-3D241220-26r1-3D241219-26r2-3D241220-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=k7JRKcYxF7Om4zfoGN5X6v30DyQT_UvgvI-OUGvC0z4&s=a7xqjfEhNO_Qb7D6iy4knGVzVg0ryZBp--1xu20XsaY&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h?rev=241220&r1=241219&r2=241220&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h (original)<br>
+++ llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h Wed Jul  1 20:11:47 2015<br>
@@ -519,6 +519,11 @@ public:<br>
   Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,<br>
                                            Type *ExpectedType) const;<br>
<br>
+  /// \returns True if the two functions have compatible attributes for inlining<br>
+  /// purposes.<br>
+  bool hasCompatibleFunctionAttributes(const Function *Caller,<br>
+                                       const Function *Callee) const;<br></blockquote><div><br>Given that it gets the whole function, perhaps it should be "areCompatibleFunctions"? (they could look at other properties of the function)<br><br>Otherwise, can the attribute set/list/container be passed directly, not exposing the whole function to TTI?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
   /// @}<br>
<br>
 private:<br>
@@ -619,6 +624,8 @@ public:<br>
                                   MemIntrinsicInfo &Info) = 0;<br>
   virtual Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,<br>
                                                    Type *ExpectedType) = 0;<br>
+  virtual bool hasCompatibleFunctionAttributes(const Function *Caller,<br>
+                                               const Function *Callee) const = 0;<br>
 };<br>
<br>
 template <typename T><br>
@@ -804,6 +811,10 @@ public:<br>
                                            Type *ExpectedType) override {<br>
     return Impl.getOrCreateResultFromMemIntrinsic(Inst, ExpectedType);<br>
   }<br>
+  bool hasCompatibleFunctionAttributes(const Function *Caller,<br>
+                                       const Function *Callee) const override {<br>
+    return Impl.hasCompatibleFunctionAttributes(Caller, Callee);<br>
+  }<br>
 };<br>
<br>
 template <typename T><br>
<br>
Modified: llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_Analysis_TargetTransformInfoImpl.h-3Frev-3D241220-26r1-3D241219-26r2-3D241220-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=k7JRKcYxF7Om4zfoGN5X6v30DyQT_UvgvI-OUGvC0z4&s=z6MPEal3avm4afG9a3UUCxxIyXuw_CJ94oYXRNiFlJQ&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h?rev=241220&r1=241219&r2=241220&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h (original)<br>
+++ llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h Wed Jul  1 20:11:47 2015<br>
@@ -335,6 +335,14 @@ public:<br>
                                            Type *ExpectedType) {<br>
     return nullptr;<br>
   }<br>
+<br>
+  bool hasCompatibleFunctionAttributes(const Function *Caller,<br>
+                                       const Function *Callee) const {<br>
+    return (Caller->getFnAttribute("target-cpu") ==<br>
+            Callee->getFnAttribute("target-cpu")) &&<br>
+           (Caller->getFnAttribute("target-features") ==<br>
+            Callee->getFnAttribute("target-features"));<br>
+  }<br>
 };<br>
<br>
 /// \brief CRTP base class for use as a mix-in that aids implementing<br>
<br>
Modified: llvm/trunk/lib/Analysis/IPA/InlineCost.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_Analysis_IPA_InlineCost.cpp-3Frev-3D241220-26r1-3D241219-26r2-3D241220-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=k7JRKcYxF7Om4zfoGN5X6v30DyQT_UvgvI-OUGvC0z4&s=5tbyNN4wbA8bzvxoH4jD-vAHdLUX5xxtSxkI96dyyXs&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/InlineCost.cpp?rev=241220&r1=241219&r2=241220&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/IPA/InlineCost.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/IPA/InlineCost.cpp Wed Jul  1 20:11:47 2015<br>
@@ -1344,9 +1344,9 @@ static bool attributeMatches(Function *F<br>
 /// \brief Test that there are no attribute conflicts between Caller and Callee<br>
 ///        that prevent inlining.<br>
 static bool functionsHaveCompatibleAttributes(Function *Caller,<br>
-                                              Function *Callee) {<br>
-  return attributeMatches(Caller, Callee, "target-cpu") &&<br>
-         attributeMatches(Caller, Callee, "target-features") &&<br>
+                                              Function *Callee,<br>
+                                              TargetTransformInfo &TTI) {<br>
+  return TTI.hasCompatibleFunctionAttributes(Caller, Callee) &&<br>
          attributeMatches(Caller, Callee, Attribute::SanitizeAddress) &&<br>
          attributeMatches(Caller, Callee, Attribute::SanitizeMemory) &&<br>
          attributeMatches(Caller, Callee, Attribute::SanitizeThread);<br>
@@ -1368,7 +1368,8 @@ InlineCost InlineCostAnalysis::getInline<br>
<br>
   // Never inline functions with conflicting attributes (unless callee has<br>
   // always-inline attribute).<br>
-  if (!functionsHaveCompatibleAttributes(CS.getCaller(), Callee))<br>
+  if (!functionsHaveCompatibleAttributes(CS.getCaller(), Callee,<br>
+                                         TTIWP->getTTI(*Callee)))<br>
     return llvm::InlineCost::getNever();<br>
<br>
   // Don't inline this call if the caller has the optnone attribute.<br>
<br>
Modified: llvm/trunk/lib/Analysis/TargetTransformInfo.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_Analysis_TargetTransformInfo.cpp-3Frev-3D241220-26r1-3D241219-26r2-3D241220-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=k7JRKcYxF7Om4zfoGN5X6v30DyQT_UvgvI-OUGvC0z4&s=AM-GrWW--5kh70hia5n07ARFRlwtoDAa0U_wK1KVR_Y&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TargetTransformInfo.cpp?rev=241220&r1=241219&r2=241220&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/TargetTransformInfo.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/TargetTransformInfo.cpp Wed Jul  1 20:11:47 2015<br>
@@ -284,6 +284,11 @@ Value *TargetTransformInfo::getOrCreateR<br>
   return TTIImpl->getOrCreateResultFromMemIntrinsic(Inst, ExpectedType);<br>
 }<br>
<br>
+bool TargetTransformInfo::hasCompatibleFunctionAttributes(<br>
+    const Function *Caller, const Function *Callee) const {<br>
+  return TTIImpl->hasCompatibleFunctionAttributes(Caller, Callee);<br>
+}<br>
+<br>
 TargetTransformInfo::Concept::~Concept() {}<br>
<br>
 TargetIRAnalysis::TargetIRAnalysis() : TTICallback(&getDefaultTTI) {}<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" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>