aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Attributes.cpp
diff options
context:
space:
mode:
authorAndrew Litteken <andrew.litteken@gmail.com>2020-08-24 03:24:59 -0500
committerAndrew Litteken <andrew.litteken@gmail.com>2020-12-31 12:30:23 -0600
commit1a9eb19af9ba1c6fcd63f84f4053c77881e6ae1c (patch)
tree388dfdf2555a83d1f46101048514b76ab1ddb63b /llvm/lib/IR/Attributes.cpp
parenta90b42b0fec618124a3ed573ecd0e192a61815f7 (diff)
downloadllvm-1a9eb19af9ba1c6fcd63f84f4053c77881e6ae1c.zip
llvm-1a9eb19af9ba1c6fcd63f84f4053c77881e6ae1c.tar.gz
llvm-1a9eb19af9ba1c6fcd63f84f4053c77881e6ae1c.tar.bz2
[IROutliner] Adding consistent function attribute merging
When combining extracted functions, they may have different function attributes. We want to make sure that we do not make any assumptions, or lose any information. This attempts to make sure that we consolidate function attributes to their most general case. Tests: llvm/test/Transforms/IROutliner/outlining-compatible-and-attribute-transfer.ll llvm/test/Transforms/IROutliner/outlining-compatible-or-attribute-transfer.ll Reviewers: jdoefert, paquette Differential Revision: https://reviews.llvm.org/D87301
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r--llvm/lib/IR/Attributes.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index 7001ab8..d39cdf7 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -2091,7 +2091,25 @@ bool AttributeFuncs::areInlineCompatible(const Function &Caller,
return hasCompatibleFnAttrs(Caller, Callee);
}
+bool AttributeFuncs::areOutlineCompatible(const Function &A,
+ const Function &B) {
+ return hasCompatibleFnAttrs(A, B);
+}
+
void AttributeFuncs::mergeAttributesForInlining(Function &Caller,
const Function &Callee) {
mergeFnAttrs(Caller, Callee);
}
+
+void AttributeFuncs::mergeAttributesForOutlining(Function &Base,
+ const Function &ToMerge) {
+
+ // We merge functions so that they meet the most general case.
+ // For example, if the NoNansFPMathAttr is set in one function, but not in
+ // the other, in the merged function we can say that the NoNansFPMathAttr
+ // is not set.
+ // However if we have the SpeculativeLoadHardeningAttr set true in one
+ // function, but not the other, we make sure that the function retains
+ // that aspect in the merged function.
+ mergeFnAttrs(Base, ToMerge);
+}