summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorStefan Stipanovic <sstipanovic@s-energize.com>2019-11-17 21:35:04 +0100
committerStefan Stipanovic <sstipanovic@s-energize.com>2019-11-17 21:35:04 +0100
commita516fbac520287307e909761dc7a083065d16049 (patch)
tree7ee2ebbf8f8d2d616e1873d9396b04b17e9c1d41 /llvm/lib
parentebf9bf2cbc8fa68d536e481e370c4ba40ce61a8a (diff)
downloadbcm5719-llvm-a516fbac520287307e909761dc7a083065d16049.tar.gz
bcm5719-llvm-a516fbac520287307e909761dc7a083065d16049.zip
[Attributor] Use nofree argument attribute for heap-to-stack conversion
Reviewers: jdoerfert, uenoku Subscribers: Differential Revision: https://reviews.llvm.org/D70140
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/Attributor.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index db6a07ba46d..0e1f2e97d8f 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -4155,11 +4155,6 @@ ChangeStatus AAHeapToStackImpl::updateImpl(Attributor &A) {
continue;
}
- // NOTE: Right now, if a function that has malloc pointer as an argument
- // frees memory, we assume that the malloc pointer is freed.
-
- // TODO: Add nofree callsite argument attribute to indicate that pointer
- // argument is not freed.
if (auto *CB = dyn_cast<CallBase>(UserI)) {
if (!CB->isArgOperand(U))
continue;
@@ -4180,15 +4175,16 @@ ChangeStatus AAHeapToStackImpl::updateImpl(Attributor &A) {
continue;
}
- // If a function does not free memory we are fine
- const auto &NoFreeAA =
- A.getAAFor<AANoFree>(*this, IRPosition::callsite_function(*CB));
-
unsigned ArgNo = CB->getArgOperandNo(U);
+
const auto &NoCaptureAA = A.getAAFor<AANoCapture>(
*this, IRPosition::callsite_argument(*CB, ArgNo));
- if (!NoCaptureAA.isAssumedNoCapture() || !NoFreeAA.isAssumedNoFree()) {
+ // If a callsite argument use is nofree, we are fine.
+ const auto &ArgNoFreeAA = A.getAAFor<AANoFree>(
+ *this, IRPosition::callsite_argument(*CB, ArgNo));
+
+ if (!NoCaptureAA.isAssumedNoCapture() || !ArgNoFreeAA.isAssumedNoFree()) {
LLVM_DEBUG(dbgs() << "[H2S] Bad user: " << *UserI << "\n");
ValidUsesOnly = false;
}
OpenPOWER on IntegriCloud