[llvm] f3a113f - [TLI] Fix signature for fprintf (PR59757)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 3 06:28:54 PST 2023


Author: Nikita Popov
Date: 2023-01-03T15:28:47+01:00
New Revision: f3a113ff48a8b5e88455d45debbdc0bce2635b9a

URL: https://github.com/llvm/llvm-project/commit/f3a113ff48a8b5e88455d45debbdc0bce2635b9a
DIFF: https://github.com/llvm/llvm-project/commit/f3a113ff48a8b5e88455d45debbdc0bce2635b9a.diff

LOG: [TLI] Fix signature for fprintf (PR59757)

fprintf() requires two pointer arguments.

Fixes https://github.com/llvm/llvm-project/issues/59757.

Added: 
    llvm/test/Transforms/InstCombine/fprintf-wrong-sig.ll

Modified: 
    llvm/include/llvm/Analysis/TargetLibraryInfo.def

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.def b/llvm/include/llvm/Analysis/TargetLibraryInfo.def
index 3602e9183301d..5f6af3514fc24 100644
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.def
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.def
@@ -1315,7 +1315,7 @@ TLI_DEFINE_SIG_INTERNAL(Int)
 /// int fprintf(FILE *stream, const char *format, ...);
 TLI_DEFINE_ENUM_INTERNAL(fprintf)
 TLI_DEFINE_STRING_INTERNAL("fprintf")
-TLI_DEFINE_SIG_INTERNAL(Int, Ptr, Ellip)
+TLI_DEFINE_SIG_INTERNAL(Int, Ptr, Ptr, Ellip)
 
 /// int fputc(int c, FILE *stream);
 TLI_DEFINE_ENUM_INTERNAL(fputc)

diff  --git a/llvm/test/Transforms/InstCombine/fprintf-wrong-sig.ll b/llvm/test/Transforms/InstCombine/fprintf-wrong-sig.ll
new file mode 100644
index 0000000000000..4810f36fade0e
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/fprintf-wrong-sig.ll
@@ -0,0 +1,15 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -passes=instcombine < %s | FileCheck %s
+
+ at .str = private constant [13 x i8] c"an error: %d\00"
+
+declare i32 @fprintf(ptr, ...)
+
+define i32 @test1() {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT:    [[CALL:%.*]] = call i32 (ptr, ...) @fprintf(ptr nonnull @.str)
+; CHECK-NEXT:    ret i32 0
+;
+  %call = call i32 (ptr, ...) @fprintf(ptr @.str)
+  ret i32 0
+}


        


More information about the llvm-commits mailing list