[TLI] Fix signature for fprintf (PR59757)
authorNikita Popov <npopov@redhat.com>
Tue, 3 Jan 2023 14:26:31 +0000 (15:26 +0100)
committerNikita Popov <npopov@redhat.com>
Tue, 3 Jan 2023 14:28:47 +0000 (15:28 +0100)
fprintf() requires two pointer arguments.

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

llvm/include/llvm/Analysis/TargetLibraryInfo.def
llvm/test/Transforms/InstCombine/fprintf-wrong-sig.ll [new file with mode: 0644]

index 3602e91..5f6af35 100644 (file)
@@ -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 (file)
index 0000000..4810f36
--- /dev/null
@@ -0,0 +1,15 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -passes=instcombine < %s | FileCheck %s
+
+@.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
+}