<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Jul 1, 2015 at 6:26 PM David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><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=JUcjUMjbkwF0BVUD5FV6YN-2CRMfA5RtFtvntOxymvs&s=WQXvpZW6to0dvxqG-2t4ybDa5xL8CLa66WnAJt6bc7o&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=JUcjUMjbkwF0BVUD5FV6YN-2CRMfA5RtFtvntOxymvs&s=zX03_O4CybNWW24Aq_dSLtQqxxzIbnD1Ucryfymh5Hs&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></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><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></div></div></div></div></blockquote><div><br></div><div>Naming is hard. No particular preference here so if you like this one I'll happily change it :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Otherwise, can the attribute set/list/container be passed directly, not exposing the whole function to TTI?<br> </div></div></div></div></blockquote><div><br></div><div>They could look at other properties, also if you take a look at the x86 one it makes it a bit more obvious that I'm using the function to get parsed subtarget attributes there.</div><div><br></div><div>-eric</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><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=JUcjUMjbkwF0BVUD5FV6YN-2CRMfA5RtFtvntOxymvs&s=7Uh72eBQ7_1e3ETkqqz7-NAOEm5coSVAFXgihUuchvA&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=JUcjUMjbkwF0BVUD5FV6YN-2CRMfA5RtFtvntOxymvs&s=TtuR8ZMRfCw_-hfDd-atG-OmaFjsR8-rhCP54j9oDPI&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=JUcjUMjbkwF0BVUD5FV6YN-2CRMfA5RtFtvntOxymvs&s=iEIGmc9iNfSKasX0k8qF8w00-OgBMlR6zpEg0AhLe0s&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" target="_blank">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></div></div></blockquote></div></div>