[FunctionAttrs] Added noalias for memccpy/mempcpy arguments

llvm-svn: 373251
This commit is contained in:
David Bolvansky 2019-09-30 19:43:48 +00:00
parent b0ccef143a
commit a05e671c7e
2 changed files with 13 additions and 4 deletions

View File

@ -306,12 +306,21 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) {
case LibFunc_memcpy: case LibFunc_memcpy:
Changed |= setDoesNotAlias(F, 0); Changed |= setDoesNotAlias(F, 0);
Changed |= setDoesNotAlias(F, 1); 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: case LibFunc_memmove:
Changed |= setReturnedArg(F, 0); Changed |= setReturnedArg(F, 0);
LLVM_FALLTHROUGH; Changed |= setDoesNotThrow(F);
Changed |= setDoesNotCapture(F, 1);
Changed |= setOnlyReadsMemory(F, 1);
return Changed;
case LibFunc_mempcpy: case LibFunc_mempcpy:
case LibFunc_memccpy: case LibFunc_memccpy:
Changed |= setDoesNotAlias(F, 0);
Changed |= setDoesNotAlias(F, 1);
Changed |= setDoesNotThrow(F); Changed |= setDoesNotThrow(F);
Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 1);
Changed |= setOnlyReadsMemory(F, 1); Changed |= setOnlyReadsMemory(F, 1);

View File

@ -619,7 +619,7 @@ declare i8* @malloc(i64)
; CHECK-LINUX: declare noalias i8* @memalign(i64, i64) [[G0]] ; CHECK-LINUX: declare noalias i8* @memalign(i64, i64) [[G0]]
declare i8* @memalign(i64, i64) 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) declare i8* @memccpy(i8*, i8*, i32, i64)
; CHECK: declare i8* @memchr(i8*, i32, i64) [[G2]] ; 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]] ; CHECK: declare i8* @memcpy(i8* noalias returned, i8* noalias nocapture readonly, i64) [[G1]]
declare i8* @memcpy(i8*, i8*, i64) 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) declare i8* @mempcpy(i8*, i8*, i64)
; CHECK: declare i8* @memmove(i8* returned, i8* nocapture readonly, i64) [[G1]] ; CHECK: declare i8* @memmove(i8* returned, i8* nocapture readonly, i64) [[G1]]