[PATCH] D136140: [SimplifyLibCalls] Add NoUndef/NonNull/Dereferenceable attributes to iprintf/siprintf
Karl-Johan Karlsson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 18 01:14:36 PDT 2022
Ka-Ka updated this revision to Diff 468446.
Ka-Ka marked an inline comment as done.
Ka-Ka added a comment.
Moved call annotateNonNullNoUndefBasedOnAccess()
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136140/new/
https://reviews.llvm.org/D136140
Files:
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/test/Transforms/InstCombine/printf-1.ll
llvm/test/Transforms/InstCombine/sprintf-1.ll
Index: llvm/test/Transforms/InstCombine/sprintf-1.ll
===================================================================
--- llvm/test/Transforms/InstCombine/sprintf-1.ll
+++ llvm/test/Transforms/InstCombine/sprintf-1.ll
@@ -79,7 +79,7 @@
define void @test_simplify6(ptr %dst) {
; CHECK-IPRINTF-LABEL: @test_simplify6(
-; CHECK-IPRINTF-NEXT: [[TMP1:%.*]] = call i32 (ptr, ptr, ...) @siprintf(ptr [[DST:%.*]], ptr nonnull @percent_d, i32 187)
+; CHECK-IPRINTF-NEXT: [[TMP1:%.*]] = call i32 (ptr, ptr, ...) @siprintf(ptr noundef nonnull dereferenceable(1) [[DST:%.*]], ptr noundef nonnull dereferenceable(1) @percent_d, i32 187)
; CHECK-IPRINTF-NEXT: ret void
;
; WIN-LABEL: @test_simplify6(
Index: llvm/test/Transforms/InstCombine/printf-1.ll
===================================================================
--- llvm/test/Transforms/InstCombine/printf-1.ll
+++ llvm/test/Transforms/InstCombine/printf-1.ll
@@ -127,7 +127,7 @@
; CHECK-NEXT: ret void
;
; CHECK-IPRINTF-LABEL: @test_simplify7(
-; CHECK-IPRINTF-NEXT: [[TMP1:%.*]] = call i32 (ptr, ...) @iprintf(ptr nonnull @percent_d, i32 187)
+; CHECK-IPRINTF-NEXT: [[TMP1:%.*]] = call i32 (ptr, ...) @iprintf(ptr noundef nonnull dereferenceable(1) @percent_d, i32 187)
; CHECK-IPRINTF-NEXT: ret void
;
call i32 (ptr, ...) @printf(ptr @percent_d, i32 187)
@@ -166,7 +166,7 @@
; CHECK-NEXT: ret i32 [[RET]]
;
; CHECK-IPRINTF-LABEL: @test_no_simplify3(
-; CHECK-IPRINTF-NEXT: [[TMP1:%.*]] = call i32 (ptr, ...) @iprintf(ptr nonnull @h)
+; CHECK-IPRINTF-NEXT: [[TMP1:%.*]] = call i32 (ptr, ...) @iprintf(ptr noundef nonnull dereferenceable(1) @h)
; CHECK-IPRINTF-NEXT: ret i32 [[TMP1]]
;
%ret = call i32 (ptr, ...) @printf(ptr @h)
Index: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -2887,6 +2887,8 @@
return V;
}
+ annotateNonNullNoUndefBasedOnAccess(CI, 0);
+
// printf(format, ...) -> iprintf(format, ...) if no floating point
// arguments.
if (isLibFuncEmittable(M, TLI, LibFunc_iprintf) &&
@@ -2911,7 +2913,6 @@
return New;
}
- annotateNonNullNoUndefBasedOnAccess(CI, 0);
return nullptr;
}
@@ -3010,6 +3011,8 @@
return V;
}
+ annotateNonNullNoUndefBasedOnAccess(CI, {0, 1});
+
// sprintf(str, format, ...) -> siprintf(str, format, ...) if no floating
// point arguments.
if (isLibFuncEmittable(M, TLI, LibFunc_siprintf) &&
@@ -3034,7 +3037,6 @@
return New;
}
- annotateNonNullNoUndefBasedOnAccess(CI, {0, 1});
return nullptr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136140.468446.patch
Type: text/x-patch
Size: 2685 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221018/9e4c2741/attachment.bin>
More information about the llvm-commits
mailing list