summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDavid Bolvansky <david.bolvansky@gmail.com>2019-09-17 10:12:48 +0000
committerDavid Bolvansky <david.bolvansky@gmail.com>2019-09-17 10:12:48 +0000
commitbe2487a2ba43f3929c894e8cf8fe3ddb0b9c6a24 (patch)
tree342efda7d6566f80cd109f3b6576a49da36d6d0a /llvm/lib/Transforms
parent3a3dddd9d72edecc774efaee153e876fe74fed6c (diff)
downloadbcm5719-llvm-be2487a2ba43f3929c894e8cf8fe3ddb0b9c6a24.tar.gz
bcm5719-llvm-be2487a2ba43f3929c894e8cf8fe3ddb0b9c6a24.zip
[InstCombine] Annotate strdup with deref_or_null
llvm-svn: 372098
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index e96e45e802a..90438189f89 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -4208,6 +4208,12 @@ static void annotateAnyAllocSite(CallBase &Call, const TargetLibraryInfo *TLI) {
Call.addAttribute(AttributeList::ReturnIndex,
Attribute::getWithDereferenceableOrNullBytes(
Call.getContext(), Size.getZExtValue()));
+ } else if (isStrdupLikeFn(&Call, TLI) && Call.getNumArgOperands() == 1) {
+ // TODO: handle strndup
+ if (uint64_t Len = GetStringLength(Call.getOperand(0)))
+ Call.addAttribute(
+ AttributeList::ReturnIndex,
+ Attribute::getWithDereferenceableOrNullBytes(Call.getContext(), Len));
}
}
OpenPOWER on IntegriCloud