aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2021-04-14 16:06:25 -0700
committerPhilip Reames <listmail@philipreames.com>2021-04-14 16:38:07 -0700
commitdd985551c247752ee2be71f04a141225a40641ef (patch)
treedcc8a7a7ab2c7f49a88ed357ee2b6102e1a44b34 /llvm/lib/Transforms/Utils/Local.cpp
parentebee45713190d9844ef860bf491035e3dcf3a538 (diff)
downloadllvm-dd985551c247752ee2be71f04a141225a40641ef.zip
llvm-dd985551c247752ee2be71f04a141225a40641ef.tar.gz
llvm-dd985551c247752ee2be71f04a141225a40641ef.tar.bz2
Reapply "[InferAttributes] Materialize all infered attributes for declaration"" and follow on patches.
This reverts commit ab98f2c7129a52e216fd7e088b964cf4af27b0f2 and 98eea392cdbcdb7360e58b46e9329573f092cd96. It includes a fix for the clang test which triggered the revert. I failed to notice this one because there was another AMDGPU llvm test with a similiar name and the exact same text in the error message. Odd. Since only one build bot reported the clang test, I didn't notice that one.
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index e285f8a..89e62fb 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3392,3 +3392,33 @@ Value *llvm::invertCondition(Value *Condition) {
Inverted->insertBefore(&*Parent->getFirstInsertionPt());
return Inverted;
}
+
+bool llvm::inferAttributesFromOthers(Function &F) {
+ // Note: We explicitly check for attributes rather than using cover functions
+ // because some of the cover functions include the logic being implemented.
+
+ bool Changed = false;
+ // readnone + not convergent implies nosync
+ if (!F.hasFnAttribute(Attribute::NoSync) &&
+ F.doesNotAccessMemory() && !F.isConvergent()) {
+ F.setNoSync();
+ Changed = true;
+ }
+
+ // readonly implies nofree
+ if (!F.hasFnAttribute(Attribute::NoFree) && F.onlyReadsMemory()) {
+ F.setDoesNotFreeMemory();
+ Changed = true;
+ }
+
+ // willreturn implies mustprogress
+ if (!F.hasFnAttribute(Attribute::MustProgress) && F.willReturn()) {
+ F.setMustProgress();
+ Changed = true;
+ }
+
+ // TODO: There are a bunch of cases of restrictive memory effects we
+ // can infer by inspecting arguments of argmemonly-ish functions.
+
+ return Changed;
+}