From 08b3f4834c626b527e495c3b05d740940f9eca35 Mon Sep 17 00:00:00 2001 From: David Bolvansky Date: Mon, 30 Sep 2019 19:43:48 +0000 Subject: [PATCH] [FunctionAttrs] Added noalias for memccpy/mempcpy arguments git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373251 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/BuildLibCalls.cpp | 13 +++++++++++-- test/Transforms/InferFunctionAttrs/annotate.ll | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/Transforms/Utils/BuildLibCalls.cpp b/lib/Transforms/Utils/BuildLibCalls.cpp index e8ce3f92749..71316ce8f75 100644 --- a/lib/Transforms/Utils/BuildLibCalls.cpp +++ b/lib/Transforms/Utils/BuildLibCalls.cpp @@ -306,12 +306,21 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) { case LibFunc_memcpy: Changed |= setDoesNotAlias(F, 0); Changed |= setDoesNotAlias(F, 1); - LLVM_FALLTHROUGH; + Changed |= setReturnedArg(F, 0); + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; case LibFunc_memmove: Changed |= setReturnedArg(F, 0); - LLVM_FALLTHROUGH; + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; case LibFunc_mempcpy: case LibFunc_memccpy: + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotAlias(F, 1); Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); diff --git a/test/Transforms/InferFunctionAttrs/annotate.ll b/test/Transforms/InferFunctionAttrs/annotate.ll index f3b0cd43640..8054802ff02 100644 --- a/test/Transforms/InferFunctionAttrs/annotate.ll +++ b/test/Transforms/InferFunctionAttrs/annotate.ll @@ -619,7 +619,7 @@ declare i8* @malloc(i64) ; CHECK-LINUX: declare noalias i8* @memalign(i64, i64) [[G0]] declare i8* @memalign(i64, i64) -; CHECK: declare i8* @memccpy(i8*, i8* nocapture readonly, i32, i64) [[G1]] +; CHECK: declare i8* @memccpy(i8* noalias, i8* noalias nocapture readonly, i32, i64) [[G1]] declare i8* @memccpy(i8*, i8*, i32, i64) ; CHECK: declare i8* @memchr(i8*, i32, i64) [[G2]] @@ -631,7 +631,7 @@ declare i32 @memcmp(i8*, i8*, i64) ; CHECK: declare i8* @memcpy(i8* noalias returned, i8* noalias nocapture readonly, i64) [[G1]] declare i8* @memcpy(i8*, i8*, i64) -; CHECK: declare i8* @mempcpy(i8*, i8* nocapture readonly, i64) [[G1]] +; CHECK: declare i8* @mempcpy(i8* noalias, i8* noalias nocapture readonly, i64) [[G1]] declare i8* @mempcpy(i8*, i8*, i64) ; CHECK: declare i8* @memmove(i8* returned, i8* nocapture readonly, i64) [[G1]] -- 2.50.0