[PATCH] D100551: [deref] No need to check nosync in addition to nofree
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 15 05:07:26 PDT 2021
mkazantsev created this revision.
mkazantsev added reviewers: reames, nlopes, nikic.
Herald added subscribers: dexonsmith, hiraditya.
mkazantsev requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The attribute `nofree` guarantees that a function cannot free memory
by any means, directly or indirectly. If it is specified, there is no need to
check `nosync` separately because it imposes extra limitations (for example,
a function can sync but never write or free memory).
This was already discussed in D99135 <https://reviews.llvm.org/D99135>, but the discussion doesn't explain
case of synching readonly/nofree function.
https://reviews.llvm.org/D100551
Files:
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
@@ -261,8 +261,7 @@
; CHECK-LABEL: 'infer_func_attrs2'
; GLOBAL: %p
-; POINT-NOT: %p
-; FIXME: Can be inferred from attributes
+; POINT: %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
@@ -749,10 +749,9 @@
if (!F)
return true;
- // 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.
- if (F->doesNotFreeMemory() && F->hasNoSync())
+ // A pointer to an object in a function which doesn't free memory, directly
+ // or indirectly (e.g. via creation of other threads that do it).
+ if (F->doesNotFreeMemory())
return false;
// With garbage collection, deallocation typically occurs solely at or after
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100551.337722.patch
Type: text/x-patch
Size: 1236 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210415/e53e1434/attachment.bin>
More information about the llvm-commits
mailing list