[PATCH] D149633: [clang][codegen] Add F128 svnprintf_chk builtin

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 1 23:09:10 PDT 2023


tbaeder created this revision.
tbaeder added reviewers: ecnelises, tstellar, tuliom, efriedma.
Herald added subscribers: kbarton, nemanjai.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149633

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/PowerPC/ppc64-f128-builtins.c


Index: clang/test/CodeGen/PowerPC/ppc64-f128-builtins.c
===================================================================
--- clang/test/CodeGen/PowerPC/ppc64-f128-builtins.c
+++ clang/test/CodeGen/PowerPC/ppc64-f128-builtins.c
@@ -25,6 +25,17 @@
   __builtin_va_end(va);
 }
 
+// IEEE128-LABEL: define dso_local void @test_vsnprintf_chk
+// IEEE128: call signext i32 @__vsnprintfieee128
+// PPC128-LABEL: define dso_local void @test_vsnprintf_chk
+// PPC128: call signext i32 @__vsnprintf_chk
+void test_vsnprintf_chk(int n, ...) {
+  __builtin_va_list va;
+  __builtin_va_start(va, n);
+  __builtin___vsnprintf_chk(buf, 20, 0 , sizeof(buf), "%.Lf", va);
+  __builtin_va_end(va);
+}
+
 // IEEE128-LABEL: define dso_local void @test_vsprintf
 // IEEE128: call signext i32 @__vsprintfieee128
 // PPC128-LABEL: define dso_local void @test_vsprintf
Index: clang/lib/CodeGen/CGBuiltin.cpp
===================================================================
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -101,6 +101,7 @@
   // std libcall builtins are implemented.
   static SmallDenseMap<unsigned, StringRef, 8> F128Builtins{
       {Builtin::BI__builtin_printf, "__printfieee128"},
+      {Builtin::BI__builtin___vsnprintf_chk, "__vsnprintfieee128"},
       {Builtin::BI__builtin_vsnprintf, "__vsnprintfieee128"},
       {Builtin::BI__builtin_vsprintf, "__vsprintfieee128"},
       {Builtin::BI__builtin_sprintf, "__sprintfieee128"},


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149633.518639.patch
Type: text/x-patch
Size: 1462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230502/ad7bf9e7/attachment.bin>


More information about the cfe-commits mailing list