[PATCH] D99138: [deref] Infer a few more cases of global dereferenceability in a callee
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 24 17:24:34 PDT 2021
reames updated this revision to Diff 333179.
reames added a comment.
Refresh per reviewer preference for attribute handling.
Byval, etc... split to https://reviews.llvm.org/D99310.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99138/new/
https://reviews.llvm.org/D99138
Files:
llvm/include/llvm/IR/Function.h
llvm/lib/IR/Value.cpp
llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll
Index: llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll
===================================================================
--- llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll
+++ llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll
@@ -260,9 +260,7 @@
}
; CHECK-LABEL: 'infer_func_attrs2'
-; GLOBAL: %p
-; POINT-NOT: %p
-; FIXME: Can be inferred from attributes
+; CHECK: %p
define void @infer_func_attrs2(i32* dereferenceable(8) %p) readonly {
call void @mayfree()
%v = load i32, i32* %p
Index: llvm/lib/IR/Value.cpp
===================================================================
--- llvm/lib/IR/Value.cpp
+++ llvm/lib/IR/Value.cpp
@@ -750,7 +750,8 @@
// A pointer to an object in a function which neither frees, nor can arrange
// for another thread to free on its behalf, can not be freed in the scope
- // of the function.
+ // of the function. Note that readonly implies both of these. Which is good
+ // because we don't directly infer nosync, but do readonly.
if (F->doesNotFreeMemory() && F->hasNoSync())
return false;
Index: llvm/include/llvm/IR/Function.h
===================================================================
--- llvm/include/llvm/IR/Function.h
+++ llvm/include/llvm/IR/Function.h
@@ -626,7 +626,9 @@
/// Determine if the call can synchroize with other threads
bool hasNoSync() const {
- return hasFnAttribute(Attribute::NoSync);
+ // Coordination with another thread requires at least one write to shared
+ // memory, so readonly also implies nosync.
+ return onlyReadsMemory() || hasFnAttribute(Attribute::NoSync);
}
void setNoSync() {
addFnAttr(Attribute::NoSync);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99138.333179.patch
Type: text/x-patch
Size: 1691 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210325/4014c2e9/attachment.bin>
More information about the llvm-commits
mailing list