[llvm] f955539 - [Attributor] Return uses do not free pointers
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 11 09:03:44 PST 2020
Author: Johannes Doerfert
Date: 2020-02-11T11:02:59-06:00
New Revision: f95553923f95f0c87b7ebbe5f8e41d313292dfda
URL: https://github.com/llvm/llvm-project/commit/f95553923f95f0c87b7ebbe5f8e41d313292dfda
DIFF: https://github.com/llvm/llvm-project/commit/f95553923f95f0c87b7ebbe5f8e41d313292dfda.diff
LOG: [Attributor] Return uses do not free pointers
If a pointer is returned that does not mean it is freed in the current
(function) scope. We can ignore such uses in AANoFree.
Added:
Modified:
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/test/Transforms/Attributor/returned.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 52eafe5b8a4e..3aebc97a8635 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -1772,6 +1772,8 @@ struct AANoFreeFloating : AANoFreeImpl {
Follow = true;
return true;
}
+ if (isa<ReturnInst>(UserI))
+ return true;
// Unknown user.
return false;
diff --git a/llvm/test/Transforms/Attributor/returned.ll b/llvm/test/Transforms/Attributor/returned.ll
index 85ab69a0d99a..3efa581c9b77 100644
--- a/llvm/test/Transforms/Attributor/returned.ll
+++ b/llvm/test/Transforms/Attributor/returned.ll
@@ -334,8 +334,8 @@ if.end:
; BOTH: declare void @unknown_fn(i32* (i32*)*)
;
; BOTH: Function Attrs: noinline nounwind uwtable
-; BOTH-NEXT: define i32* @calls_unknown_fn(i32* readnone returned "no-capture-maybe-returned" %r)
-; ATTRIBUTOR: define i32* @calls_unknown_fn(i32* readnone returned "no-capture-maybe-returned" %r)
+; BOTH-NEXT: define i32* @calls_unknown_fn(i32* nofree readnone returned "no-capture-maybe-returned" %r)
+; ATTRIBUTOR: define i32* @calls_unknown_fn(i32* nofree readnone returned "no-capture-maybe-returned" %r)
declare void @unknown_fn(i32* (i32*)*) #0
define i32* @calls_unknown_fn(i32* %r) #0 {
More information about the llvm-commits
mailing list