forked from OSchip/llvm-project
[InferAttrs] Give strnlen the same attributes as strlen
This moves the only string function out of the big list of math funcs. And let's us CSE strnlen calls.
This commit is contained in:
parent
a96fe1bf3b
commit
4683ce2cd8
|
@ -233,6 +233,7 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) {
|
|||
|
||||
switch (TheLibFunc) {
|
||||
case LibFunc_strlen:
|
||||
case LibFunc_strnlen:
|
||||
case LibFunc_wcslen:
|
||||
Changed |= setOnlyReadsMemory(F);
|
||||
Changed |= setDoesNotThrow(F);
|
||||
|
@ -1158,7 +1159,6 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) {
|
|||
case LibFunc_sqrt:
|
||||
case LibFunc_sqrtf:
|
||||
case LibFunc_sqrtl:
|
||||
case LibFunc_strnlen:
|
||||
case LibFunc_tan:
|
||||
case LibFunc_tanf:
|
||||
case LibFunc_tanh:
|
||||
|
|
|
@ -921,10 +921,10 @@ declare i8* @strncpy(i8*, i8*, i64)
|
|||
; CHECK: declare noalias i8* @strndup(i8* nocapture readonly, i64 noundef) [[INACCESSIBLEMEMORARGONLY_NOFREE_NOUNWIND_WILLRETURN]]
|
||||
declare i8* @strndup(i8*, i64)
|
||||
|
||||
; CHECK: declare i64 @strnlen(i8*, i64) [[NOFREE_NOUNWIND_WILLRETURN]]
|
||||
; CHECK: declare i64 @strnlen(i8* nocapture, i64) [[ARGMEMONLY_NOFREE_NOUNWIND_READONLY_WILLRETURN:#[0-9]+]]
|
||||
declare i64 @strnlen(i8*, i64)
|
||||
|
||||
; CHECK: declare i8* @strpbrk(i8*, i8* nocapture) [[ARGMEMONLY_NOFREE_NOUNWIND_READONLY_WILLRETURN:#[0-9]+]]
|
||||
; CHECK: declare i8* @strpbrk(i8*, i8* nocapture) [[ARGMEMONLY_NOFREE_NOUNWIND_READONLY_WILLRETURN]]
|
||||
declare i8* @strpbrk(i8*, i8*)
|
||||
|
||||
; CHECK: declare i8* @strrchr(i8*, i32) [[ARGMEMONLY_NOFREE_NOUNWIND_READONLY]]
|
||||
|
|
Loading…
Reference in New Issue