diff options
| author | Akira Hatanaka <ahatanaka@apple.com> | 2015-04-13 18:43:38 +0000 |
|---|---|---|
| committer | Akira Hatanaka <ahatanaka@apple.com> | 2015-04-13 18:43:38 +0000 |
| commit | f99e1913ae449e7d7f95fc918f44a2a1116e03d4 (patch) | |
| tree | c34add212d5e8767eb75e084f76ced79becb264c /llvm/lib/Analysis | |
| parent | 13b4b013b557a3b1e39105bbf783098dcf533474 (diff) | |
| download | bcm5719-llvm-f99e1913ae449e7d7f95fc918f44a2a1116e03d4.tar.gz bcm5719-llvm-f99e1913ae449e7d7f95fc918f44a2a1116e03d4.zip | |
[inliner] Don't inline a function if it doesn't have exactly the same
target-cpu and target-features attribute strings as the caller.
Differential Revision: http://reviews.llvm.org/D8984
llvm-svn: 234773
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/IPA/InlineCost.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/IPA/InlineCost.cpp b/llvm/lib/Analysis/IPA/InlineCost.cpp index eeb3b87382e..aa015647926 100644 --- a/llvm/lib/Analysis/IPA/InlineCost.cpp +++ b/llvm/lib/Analysis/IPA/InlineCost.cpp @@ -1286,16 +1286,18 @@ InlineCost InlineCostAnalysis::getInlineCost(CallSite CS, int Threshold) { /// \brief Test that two functions either have or have not the given attribute /// at the same time. -static bool attributeMatches(Function *F1, Function *F2, - Attribute::AttrKind Attr) { - return F1->hasFnAttribute(Attr) == F2->hasFnAttribute(Attr); +template<typename AttrKind> +static bool attributeMatches(Function *F1, Function *F2, AttrKind Attr) { + return F1->getFnAttribute(Attr) == F2->getFnAttribute(Attr); } /// \brief Test that there are no attribute conflicts between Caller and Callee /// that prevent inlining. static bool functionsHaveCompatibleAttributes(Function *Caller, Function *Callee) { - return attributeMatches(Caller, Callee, Attribute::SanitizeAddress) && + return attributeMatches(Caller, Callee, "target-cpu") && + attributeMatches(Caller, Callee, "target-features") && + attributeMatches(Caller, Callee, Attribute::SanitizeAddress) && attributeMatches(Caller, Callee, Attribute::SanitizeMemory) && attributeMatches(Caller, Callee, Attribute::SanitizeThread); } |

