[llvm] RuntimeLibcalls: Add function signatures to RTLIB. (PR #226264)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 11:47:16 PDT 2026


https://github.com/sujianIBM updated https://github.com/llvm/llvm-project/pull/226264

>From f17496c58167bec4a51ce78316b4afb4b5ad8735 Mon Sep 17 00:00:00 2001
From: sujianIBM <Jian.Su at ibm.com>
Date: Thu, 24 Sep 2026 13:53:40 -0400
Subject: [PATCH 1/2] Add function signatures to RTLIB.

---
 llvm/include/llvm/IR/RuntimeLibcalls.h        |   4 +
 llvm/include/llvm/IR/RuntimeLibcalls.td       | 848 ++++++++++--------
 llvm/include/llvm/IR/RuntimeLibcallsImpl.td   |  36 +-
 llvm/lib/IR/RuntimeLibcalls.cpp               |  72 ++
 llvm/test/TableGen/RuntimeLibcallEmitter.td   |  59 +-
 .../Util/DeclareRuntimeLibcalls/aix.ll        |   8 +-
 .../Util/DeclareRuntimeLibcalls/basic.ll      |  58 +-
 .../Util/DeclareRuntimeLibcalls/darwin.ll     |  31 +-
 .../Util/DeclareRuntimeLibcalls/emscripten.ll |   6 +-
 .../Util/DeclareRuntimeLibcalls/xcore.ll      |   6 +-
 llvm/utils/TableGen/Basic/RuntimeLibcalls.cpp |   2 +
 llvm/utils/TableGen/Basic/RuntimeLibcalls.h   |   6 +
 .../TableGen/Basic/RuntimeLibcallsEmitter.cpp |  58 +-
 13 files changed, 745 insertions(+), 449 deletions(-)

diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h
index 4ea0a7854f825..86fd47cb151c4 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.h
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.h
@@ -211,6 +211,10 @@ struct RuntimeLibcallsInfo {
   LLVM_ABI static const uint16_t RuntimeLibcallNameOffsetTable[];
   LLVM_ABI static const uint8_t RuntimeLibcallNameSizeTable[];
 
+  /// Function signature of runtime lib calls
+  LLVM_ABI static const FuncArgTypeID SignatureTable[];
+  LLVM_ABI static const uint16_t SignatureOffset[];
+
   /// Map from a concrete LibcallImpl implementation to its RTLIB::Libcall kind.
   LLVM_ABI static const RTLIB::Libcall ImplToLibcall[RTLIB::NumLibcallImpls];
 
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index 69a2793d23b7a..a3092812b263f 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -241,91 +241,125 @@ foreach IntTy = ["I32", "I64", "I128"] in {
   def CTPOP_#IntTy : RuntimeLibcall;
 }
 
-foreach FPTy = ["F32", "F64", "F80", "F128", "PPCF128"] in {
-  def ADD_#FPTy : RuntimeLibcall;
-  def FAST_ADD_#FPTy : RuntimeLibcall;
-
-  def SUB_#FPTy : RuntimeLibcall;
-  def FAST_SUB_#FPTy : RuntimeLibcall;
-
-  def MUL_#FPTy : RuntimeLibcall;
-  def FAST_MUL_#FPTy : RuntimeLibcall;
-
-  def DIV_#FPTy : RuntimeLibcall;
-  def FAST_DIV_#FPTy : RuntimeLibcall;
-
-  def REM_#FPTy : RuntimeLibcall;
-  def FMA_#FPTy : RuntimeLibcall;
-  def POWI_#FPTy : RuntimeLibcall;
-
-  def SQRT_#FPTy : RuntimeLibcall;
-  def FAST_SQRT_#FPTy : RuntimeLibcall;
-
-  def CBRT_#FPTy : RuntimeLibcall;
-  def LOG_#FPTy : RuntimeLibcall;
-  def LOG_FINITE_#FPTy : RuntimeLibcall;
-  def LOG2_#FPTy : RuntimeLibcall;
-  def LOG2_FINITE_#FPTy : RuntimeLibcall;
-  def LOG10_#FPTy : RuntimeLibcall;
-  def LOG10_FINITE_#FPTy : RuntimeLibcall;
-  def EXP_#FPTy : RuntimeLibcall;
-  def EXP_FINITE_#FPTy : RuntimeLibcall;
-  def EXP2_#FPTy : RuntimeLibcall;
-  def EXP2_FINITE_#FPTy : RuntimeLibcall;
-  def EXP10_#FPTy : RuntimeLibcall;
-  def EXP10_FINITE_#FPTy : RuntimeLibcall;
-  def SIN_#FPTy : RuntimeLibcall;
-  def COS_#FPTy : RuntimeLibcall;
-  def TAN_#FPTy : RuntimeLibcall;
-  def SINH_#FPTy : RuntimeLibcall;
-  def COSH_#FPTy : RuntimeLibcall;
-  def TANH_#FPTy : RuntimeLibcall;
-  def ASIN_#FPTy : RuntimeLibcall;
-  def ACOS_#FPTy : RuntimeLibcall;
-  def ATAN_#FPTy : RuntimeLibcall;
-  def ATAN2_#FPTy : RuntimeLibcall;
-  def SINCOS_#FPTy : RuntimeLibcall;
-  def REMQUO_#FPTy : RuntimeLibcall;
-  def FDIM_#FPTy : RuntimeLibcall;
-
-  def CABS_#FPTy : RuntimeLibcall;
+
+class TypeSuffix<string S, FuncArgType Ty> {
+  string Suffix = S;
+  FuncArgType Type = Ty;
+}
+def F32 : TypeSuffix<"F32", Flt>;
+def F64 : TypeSuffix<"F64", Dbl>;
+def F80 : TypeSuffix<"F80", LDbl>;
+def F128 : TypeSuffix<"F128", LDbl>;
+def PPCF128 : TypeSuffix<"PPCF128", LDbl>;
+
+foreach FPTy = [F32, F64, F80, F128, PPCF128] in {
+  def ADD_#FPTy.Suffix : RuntimeLibcall;
+  def FAST_ADD_#FPTy.Suffix : RuntimeLibcall;
+
+  def SUB_#FPTy.Suffix : RuntimeLibcall;
+  def FAST_SUB_#FPTy.Suffix : RuntimeLibcall;
+
+  def MUL_#FPTy.Suffix : RuntimeLibcall;
+  def FAST_MUL_#FPTy.Suffix : RuntimeLibcall;
+
+  def DIV_#FPTy.Suffix : RuntimeLibcall;
+  def FAST_DIV_#FPTy.Suffix : RuntimeLibcall;
+
+  def REM_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, FPTy.Type]>;
+  def FMA_#FPTy.Suffix : RuntimeLibcall;
+  def POWI_#FPTy.Suffix : RuntimeLibcall;
+
+  def SQRT_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def FAST_SQRT_#FPTy.Suffix : RuntimeLibcall;
+
+  def CBRT_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def LOG_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def LOG_FINITE_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def LOG2_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def LOG2_FINITE_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def LOG10_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def LOG10_FINITE_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def EXP_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def EXP_FINITE_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def EXP2_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def EXP2_FINITE_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def EXP10_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def EXP10_FINITE_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def SIN_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def COS_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def TAN_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def SINH_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def COSH_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def TANH_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def ASIN_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def ACOS_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def ATAN_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def ATAN2_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, FPTy.Type]>;
+  def SINCOS_#FPTy.Suffix : RuntimeLibcall<Void, [FPTy.Type, Ptr, Ptr]>;
+  def REMQUO_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, FPTy.Type, Ptr]>;
+  def FDIM_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, FPTy.Type]>;
+
+  def CABS_#FPTy.Suffix : RuntimeLibcall<NoneType, []>;
+
+  def ACOS_FINITE_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def ACOSH_FINITE_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def ASIN_FINITE_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def ATAN2_FINITE_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, FPTy.Type]>;
+  def ATANH_FINITE_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def COSH_FINITE_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def SINH_FINITE_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def SQRT_FINITE_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def COSPI_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def SINPI_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def ACOSH_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def ASINH_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def ATANH_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def ERF_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def EXPM1_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def FABS_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def HYPOT_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, FPTy.Type]>;
+  def LOG1P_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def ILOGB_#FPTy.Suffix : RuntimeLibcall<Int, [FPTy.Type]>;
+  def LOGB_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def NEXTAFTER_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, FPTy.Type]>;
 }
 
 foreach FPTy = [ "F32", "F64" ] in {
   def SINCOS_STRET_#FPTy : RuntimeLibcall;
+  def SINCOSPI_STRET_#FPTy : RuntimeLibcall<NoneType, []>;
 }
 
-foreach FPTy = ["F32", "F64", "F80", "F128", "PPCF128"] in {
-  def POW_#FPTy : RuntimeLibcall;
-  def POW_FINITE_#FPTy : RuntimeLibcall;
-  def CEIL_#FPTy : RuntimeLibcall;
-  def TRUNC_#FPTy : RuntimeLibcall;
-  def RINT_#FPTy : RuntimeLibcall;
-  def NEARBYINT_#FPTy : RuntimeLibcall;
-  def ROUND_#FPTy : RuntimeLibcall;
-  def ROUNDEVEN_#FPTy : RuntimeLibcall;
-  def FLOOR_#FPTy : RuntimeLibcall;
-  def COPYSIGN_#FPTy : RuntimeLibcall;
-  def FMIN_#FPTy : RuntimeLibcall;
-  def FMAX_#FPTy : RuntimeLibcall;
-  def FMINIMUM_#FPTy : RuntimeLibcall;
-  def FMAXIMUM_#FPTy : RuntimeLibcall;
-  def FMINIMUM_NUM_#FPTy : RuntimeLibcall;
-  def FMAXIMUM_NUM_#FPTy : RuntimeLibcall;
-  def LROUND_#FPTy : RuntimeLibcall;
-  def LLROUND_#FPTy : RuntimeLibcall;
-  def LRINT_#FPTy : RuntimeLibcall;
-  def LLRINT_#FPTy : RuntimeLibcall;
-  def LDEXP_#FPTy : RuntimeLibcall;
-  def FREXP_#FPTy : RuntimeLibcall;
-  def SINCOSPI_#FPTy : RuntimeLibcall;
-  def MODF_#FPTy : RuntimeLibcall;
-  def NAN_#FPTy : RuntimeLibcall;
-  def NEXTTOWARD_#FPTy : RuntimeLibcall;
-  def REMAINDER_#FPTy : RuntimeLibcall;
-  def SCALBLN_#FPTy : RuntimeLibcall;
-  def SCALBN_#FPTy : RuntimeLibcall;
-  def TGAMMA_#FPTy : RuntimeLibcall;
+foreach FPTy = [F32, F64, F80, F128, PPCF128] in {
+  def POW_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, FPTy.Type]>;
+  def POW_FINITE_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, FPTy.Type]>;
+  def CEIL_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def TRUNC_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def RINT_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def NEARBYINT_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def ROUND_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def ROUNDEVEN_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def FLOOR_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
+  def COPYSIGN_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, FPTy.Type]>;
+  def FMIN_#FPTy.Suffix : RuntimeLibcall<Floating, [Same, Same]>;
+  def FMAX_#FPTy.Suffix : RuntimeLibcall<Floating, [Same, Same]>;
+  def FMINIMUM_#FPTy.Suffix : RuntimeLibcall;
+  def FMAXIMUM_#FPTy.Suffix : RuntimeLibcall;
+  def FMINIMUM_NUM_#FPTy.Suffix : RuntimeLibcall<Floating, [Same, Same]>;
+  def FMAXIMUM_NUM_#FPTy.Suffix : RuntimeLibcall<Floating, [Same, Same]>;
+  def LROUND_#FPTy.Suffix : RuntimeLibcall;
+  def LLROUND_#FPTy.Suffix : RuntimeLibcall;
+  def LRINT_#FPTy.Suffix : RuntimeLibcall;
+  def LLRINT_#FPTy.Suffix : RuntimeLibcall;
+  def LDEXP_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, Int]>;
+  def FREXP_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, Ptr]>;
+  def SINCOSPI_#FPTy.Suffix : RuntimeLibcall;
+  def MODF_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, Ptr]>;
+  def NAN_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [Ptr]>;
+  def NEXTTOWARD_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, LDbl]>;
+  def REMAINDER_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, FPTy.Type]>;
+  def SCALBLN_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, Long]>;
+  def SCALBN_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type, Int]>;
+  def TGAMMA_#FPTy.Suffix : RuntimeLibcall<FPTy.Type, [FPTy.Type]>;
 }
 
 // Floating-point libcall families. Each generates the backend selector
@@ -591,18 +625,18 @@ foreach FPTy = ["F32", "F64", "F128", "PPCF128"] in {
 }
 
 // Memory
-def MEMCMP : RuntimeLibcall;
-def MEMCPY : RuntimeLibcall;
-def MEMCPY_CHK : RuntimeLibcall;
-def MEMMOVE : RuntimeLibcall;
-def MEMMOVE_CHK : RuntimeLibcall;
-def MEMSET : RuntimeLibcall;
-def MEMSET_CHK : RuntimeLibcall;
-def MALLOC : RuntimeLibcall;
-def CALLOC : RuntimeLibcall;
-def FREE : RuntimeLibcall;
-def BZERO : RuntimeLibcall;
-def STRLEN : RuntimeLibcall;
+def MEMCMP : RuntimeLibcall<Int, [Ptr, Ptr, SizeT]>;
+def MEMCPY : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT]>;
+def MEMCPY_CHK : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT, SizeT]>;
+def MEMMOVE : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT]>;
+def MEMMOVE_CHK : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT, SizeT]>;
+def MEMSET : RuntimeLibcall<Ptr, [Ptr, Int, SizeT]>;
+def MEMSET_CHK : RuntimeLibcall<Ptr, [Ptr, Int, SizeT, SizeT]>;
+def MALLOC : RuntimeLibcall<Ptr, [SizeT]>;
+def CALLOC : RuntimeLibcall<Ptr, [SizeT, SizeT]>;
+def FREE : RuntimeLibcall<Void, [Ptr]>;
+def BZERO : RuntimeLibcall<Void, [Ptr, SizeT]>;
+def STRLEN : RuntimeLibcall<SizeT, [Ptr]>;
 
 // Element-wise unordered-atomic memory of different sizes
 foreach MemSize = [1, 2, 4, 8, 16] in {
@@ -643,12 +677,19 @@ defset list<RuntimeLibcall> LibCalls__sync = {
 defset list<RuntimeLibcall> LibCalls__atomic = {
   // Atomic `__atomic_*' libcalls.
   foreach MemSize = ["", "_1", "_2", "_4", "_8", "_16"] in {
-    def ATOMIC_LOAD#MemSize : RuntimeLibcall;
-    def ATOMIC_STORE#MemSize : RuntimeLibcall;
+    //def ATOMIC_LOAD#MemSize : RuntimeLibcall;
+    //def ATOMIC_STORE#MemSize : RuntimeLibcall;
     def ATOMIC_EXCHANGE#MemSize : RuntimeLibcall;
     def ATOMIC_COMPARE_EXCHANGE#MemSize : RuntimeLibcall;
   }
 
+  def ATOMIC_LOAD : RuntimeLibcall<Void, [SizeT, Ptr, Ptr, Int]>;
+  def ATOMIC_STORE : RuntimeLibcall<Void, [SizeT, Ptr, Ptr, Int]>;
+  foreach MemSize = ["_1", "_2", "_4", "_8", "_16"] in {
+    def ATOMIC_LOAD#MemSize : RuntimeLibcall;
+    def ATOMIC_STORE#MemSize : RuntimeLibcall;
+  } 
+
   foreach MemSize = [1, 2, 4, 8, 16] in {
     def ATOMIC_FETCH_ADD_#MemSize : RuntimeLibcall;
     def ATOMIC_FETCH_SUB_#MemSize : RuntimeLibcall;
@@ -806,301 +847,304 @@ def OBJC_RETAIN_AUTORELEASE : RuntimeLibcall;
 def OBJC_SYNC_ENTER : RuntimeLibcall;
 def OBJC_SYNC_EXIT : RuntimeLibcall;
 
-def ABORT : RuntimeLibcall;
-def ABS : RuntimeLibcall;
-def ACCESS : RuntimeLibcall;
-def ALIGNED_ALLOC : RuntimeLibcall;
-def ATEXIT : RuntimeLibcall;
-def ATOF : RuntimeLibcall;
-def ATOI : RuntimeLibcall;
-def ATOL : RuntimeLibcall;
-def ATOLL : RuntimeLibcall;
-def BCMP : RuntimeLibcall;
-def BCOPY : RuntimeLibcall;
-def CHMOD : RuntimeLibcall;
-def CHOWN : RuntimeLibcall;
-def CLEARERR : RuntimeLibcall;
-def CLOSEDIR : RuntimeLibcall;
-def CTERMID : RuntimeLibcall;
-def CXA_ATEXIT : RuntimeLibcall;
-def CXA_GUARD_ABORT : RuntimeLibcall;
-def CXA_GUARD_ACQUIRE : RuntimeLibcall;
-def CXA_GUARD_RELEASE : RuntimeLibcall;
-def CXA_THROW : RuntimeLibcall;
-def DUNDER_ISOC99_SCANF : RuntimeLibcall;
-def DUNDER_ISOC99_SSCANF : RuntimeLibcall;
-def DUNDER_STRDUP : RuntimeLibcall;
-def DUNDER_STRNDUP : RuntimeLibcall;
-def DUNDER_STRTOK_R : RuntimeLibcall;
+def ABORT : RuntimeLibcall<Void, []>;
+def ABS : RuntimeLibcall<Int, [Int]>;
+def ACCESS : RuntimeLibcall<Int, [Ptr, Int]>;
+def ALIGNED_ALLOC : RuntimeLibcall<Ptr, [SizeT, SizeT]>;
+def ATEXIT : RuntimeLibcall<Int, [Ptr]>;
+def ATOF : RuntimeLibcall<Dbl, [Ptr]>;
+def ATOI : RuntimeLibcall<Int, [Ptr]>;
+def ATOL : RuntimeLibcall<Long, [Ptr]>;
+def ATOLL : RuntimeLibcall<LLong, [Ptr]>;
+def BCMP : RuntimeLibcall<Int, [Ptr, Ptr, SizeT]>;
+def BCOPY : RuntimeLibcall<Void, [Ptr, Ptr, SizeT]>;
+def CHMOD : RuntimeLibcall<Int, [Ptr, IntX]>;
+def CHOWN : RuntimeLibcall<Int, [Ptr, IntX, IntX]>;
+def CLEARERR : RuntimeLibcall<Void, [Ptr]>;
+def CLOSEDIR : RuntimeLibcall<Int, [Ptr]>;
+def CTERMID : RuntimeLibcall<Ptr, [Ptr]>;
+def CXA_ATEXIT : RuntimeLibcall<Int, [Ptr, Ptr, Ptr]>;
+def CXA_GUARD_ABORT : RuntimeLibcall<Void, [Ptr]>;
+def CXA_GUARD_ACQUIRE : RuntimeLibcall<Int, [Ptr]>;
+def CXA_GUARD_RELEASE : RuntimeLibcall<Void, [Ptr]>;
+def CXA_THROW : RuntimeLibcall<Void, [Ptr, Ptr, Ptr]>;
+def DUNDER_ISOC99_SCANF : RuntimeLibcall<Int, [Ptr, Ellip]>;
+def DUNDER_ISOC99_SSCANF : RuntimeLibcall<Int, [Ptr, Ptr, Ellip]>;
+def DUNDER_STRDUP : RuntimeLibcall<Ptr, [Ptr]>;
+def DUNDER_STRNDUP : RuntimeLibcall<Ptr, [Ptr, SizeT]>;
+def DUNDER_STRTOK_R : RuntimeLibcall<Ptr, [Ptr, Ptr, Ptr]>;
 def ENUM_VARIANT : RuntimeLibcall;
-def EXECL : RuntimeLibcall;
-def EXECLE : RuntimeLibcall;
-def EXECLP : RuntimeLibcall;
-def EXECV : RuntimeLibcall;
-def EXECVE : RuntimeLibcall;
-def EXECVP : RuntimeLibcall;
-def EXECVPE : RuntimeLibcall;
-def EXIT : RuntimeLibcall;
-def FCLOSE : RuntimeLibcall;
-def FDOPEN : RuntimeLibcall;
-def FEOF : RuntimeLibcall;
-def FERROR : RuntimeLibcall;
-def FFLUSH : RuntimeLibcall;
-def FFS : RuntimeLibcall;
-def FFSL : RuntimeLibcall;
-def FFSLL : RuntimeLibcall;
-def FGETC : RuntimeLibcall;
-def FGETC_UNLOCKED : RuntimeLibcall;
-def FGETPOS : RuntimeLibcall;
-def FGETS : RuntimeLibcall;
-def FGETS_UNLOCKED : RuntimeLibcall;
-def FILENO : RuntimeLibcall;
-def FIPRINTF : RuntimeLibcall;
-def FLOCKFILE : RuntimeLibcall;
-def FLS : RuntimeLibcall;
-def FLSL : RuntimeLibcall;
-def FLSLL : RuntimeLibcall;
-def FOPEN : RuntimeLibcall;
-def FOPEN64 : RuntimeLibcall;
-def FORK : RuntimeLibcall;
-def FPRINTF : RuntimeLibcall;
-def FPUTC : RuntimeLibcall;
-def FPUTC_UNLOCKED : RuntimeLibcall;
-def FPUTS : RuntimeLibcall;
-def FPUTS_UNLOCKED : RuntimeLibcall;
-def FREAD : RuntimeLibcall;
-def FREAD_UNLOCKED : RuntimeLibcall;
-def FSCANF : RuntimeLibcall;
-def FSEEK : RuntimeLibcall;
-def FSEEKO : RuntimeLibcall;
-def FSEEKO64 : RuntimeLibcall;
-def FSETPOS : RuntimeLibcall;
-def FSTAT : RuntimeLibcall;
-def FSTAT64 : RuntimeLibcall;
-def FSTATVFS : RuntimeLibcall;
-def FSTATVFS64 : RuntimeLibcall;
-def FTELL : RuntimeLibcall;
-def FTELLO : RuntimeLibcall;
-def FTELLO64 : RuntimeLibcall;
-def FTRYLOCKFILE : RuntimeLibcall;
-def FUNLOCKFILE : RuntimeLibcall;
-def FWRITE : RuntimeLibcall;
-def FWRITE_UNLOCKED : RuntimeLibcall;
-def GETC : RuntimeLibcall;
-def GETCHAR : RuntimeLibcall;
-def GETCHAR_UNLOCKED : RuntimeLibcall;
-def GETC_UNLOCKED : RuntimeLibcall;
-def GETENV : RuntimeLibcall;
-def GETITIMER : RuntimeLibcall;
-def GETLOGIN_R : RuntimeLibcall;
-def GETPWNAM : RuntimeLibcall;
-def GETS : RuntimeLibcall;
-def GETTIMEOFDAY : RuntimeLibcall;
-def HTONL : RuntimeLibcall;
-def HTONS : RuntimeLibcall;
-def IPRINTF : RuntimeLibcall;
-def ISASCII : RuntimeLibcall;
-def ISDIGIT : RuntimeLibcall;
-def LABS : RuntimeLibcall;
-def LCHOWN : RuntimeLibcall;
-def LLABS : RuntimeLibcall;
-def LSTAT : RuntimeLibcall;
-def LSTAT64 : RuntimeLibcall;
-def MEMALIGN : RuntimeLibcall;
-def MEMCCPY : RuntimeLibcall;
-def MEMCCPY_CHK : RuntimeLibcall;
-def MEMCHR : RuntimeLibcall;
-def MEMPCPY : RuntimeLibcall;
-def MEMPCPY_CHK : RuntimeLibcall;
-def MEMRCHR : RuntimeLibcall;
-def MEMSET_PATTERN16 : RuntimeLibcall;
-def MEMSET_PATTERN4 : RuntimeLibcall;
-def MEMSET_PATTERN8 : RuntimeLibcall;
-def MKDIR : RuntimeLibcall;
-def MKTIME : RuntimeLibcall;
-def MSVC_DELETE_ARRAY_PTR32 : RuntimeLibcall;
-def MSVC_DELETE_ARRAY_PTR32_INT : RuntimeLibcall;
-def MSVC_DELETE_ARRAY_PTR32_NOTHROW : RuntimeLibcall;
-def MSVC_DELETE_ARRAY_PTR64 : RuntimeLibcall;
-def MSVC_DELETE_ARRAY_PTR64_LONGLONG : RuntimeLibcall;
-def MSVC_DELETE_ARRAY_PTR64_NOTHROW : RuntimeLibcall;
-def MSVC_DELETE_PTR32 : RuntimeLibcall;
-def MSVC_DELETE_PTR32_INT : RuntimeLibcall;
-def MSVC_DELETE_PTR32_NOTHROW : RuntimeLibcall;
-def MSVC_DELETE_PTR64 : RuntimeLibcall;
-def MSVC_DELETE_PTR64_LONGLONG : RuntimeLibcall;
-def MSVC_DELETE_PTR64_NOTHROW : RuntimeLibcall;
-def MSVC_NEW_ARRAY_INT : RuntimeLibcall;
-def MSVC_NEW_ARRAY_INT_NOTHROW : RuntimeLibcall;
-def MSVC_NEW_ARRAY_LONGLONG : RuntimeLibcall;
-def MSVC_NEW_ARRAY_LONGLONG_NOTHROW : RuntimeLibcall;
-def MSVC_NEW_INT : RuntimeLibcall;
-def MSVC_NEW_INT_NOTHROW : RuntimeLibcall;
-def MSVC_NEW_LONGLONG : RuntimeLibcall;
-def MSVC_NEW_LONGLONG_NOTHROW : RuntimeLibcall;
-def NTOHL : RuntimeLibcall;
-def NTOHS : RuntimeLibcall;
-def OPEN : RuntimeLibcall;
-def OPEN64 : RuntimeLibcall;
-def OPENDIR : RuntimeLibcall;
-def PCLOSE : RuntimeLibcall;
-def PERROR : RuntimeLibcall;
-def POPEN : RuntimeLibcall;
-def POSIX_MEMALIGN : RuntimeLibcall;
-def PREAD : RuntimeLibcall;
-def PRINTF : RuntimeLibcall;
-def PUTC : RuntimeLibcall;
-def PUTCHAR : RuntimeLibcall;
-def PUTCHAR_UNLOCKED : RuntimeLibcall;
-def PUTC_UNLOCKED : RuntimeLibcall;
-def PUTS : RuntimeLibcall;
-def PVALLOC : RuntimeLibcall;
-def PWRITE : RuntimeLibcall;
-def QSORT : RuntimeLibcall;
-def READ : RuntimeLibcall;
-def READLINK : RuntimeLibcall;
-def REALLOC : RuntimeLibcall;
-def REALLOCARRAY : RuntimeLibcall;
-def REALLOCF : RuntimeLibcall;
-def REALPATH : RuntimeLibcall;
-def REMOVE : RuntimeLibcall;
-def RENAME : RuntimeLibcall;
-def REWIND : RuntimeLibcall;
-def RMDIR : RuntimeLibcall;
-def SCANF : RuntimeLibcall;
-def SETBUF : RuntimeLibcall;
-def SETITIMER : RuntimeLibcall;
-def SETVBUF : RuntimeLibcall;
-def SIPRINTF : RuntimeLibcall;
-def SIZE_RETURNING_NEW : RuntimeLibcall;
-def SIZE_RETURNING_NEW_ALIGNED : RuntimeLibcall;
-def SIZE_RETURNING_NEW_ALIGNED_HOT_COLD : RuntimeLibcall;
-def SIZE_RETURNING_NEW_HOT_COLD : RuntimeLibcall;
-def SMALL_FPRINTF : RuntimeLibcall;
-def SMALL_PRINTF : RuntimeLibcall;
-def SMALL_SPRINTF : RuntimeLibcall;
-def SNPRINTF : RuntimeLibcall;
-def SNPRINTF_CHK : RuntimeLibcall;
-def SPRINTF : RuntimeLibcall;
-def SPRINTF_CHK : RuntimeLibcall;
-def SSCANF : RuntimeLibcall;
-def STAT : RuntimeLibcall;
-def STAT64 : RuntimeLibcall;
-def STATVFS : RuntimeLibcall;
-def STATVFS64 : RuntimeLibcall;
-def STPCPY : RuntimeLibcall;
-def STPCPY_CHK : RuntimeLibcall;
-def STPNCPY : RuntimeLibcall;
-def STPNCPY_CHK : RuntimeLibcall;
-def STRCASECMP : RuntimeLibcall;
-def STRCAT : RuntimeLibcall;
-def STRCAT_CHK : RuntimeLibcall;
-def STRCHR : RuntimeLibcall;
-def STRCMP : RuntimeLibcall;
-def STRCOLL : RuntimeLibcall;
-def STRCPY : RuntimeLibcall;
-def STRCPY_CHK : RuntimeLibcall;
-def STRCSPN : RuntimeLibcall;
-def STRDUP : RuntimeLibcall;
-def STRLCAT : RuntimeLibcall;
-def STRLCAT_CHK : RuntimeLibcall;
-def STRLCPY : RuntimeLibcall;
-def STRLCPY_CHK : RuntimeLibcall;
-def STRLEN_CHK : RuntimeLibcall;
-def STRNCASECMP : RuntimeLibcall;
-def STRNCAT : RuntimeLibcall;
-def STRNCAT_CHK : RuntimeLibcall;
-def STRNCMP : RuntimeLibcall;
-def STRNCPY : RuntimeLibcall;
-def STRNCPY_CHK : RuntimeLibcall;
-def STRNDUP : RuntimeLibcall;
-def STRNLEN : RuntimeLibcall;
-def STRPBRK : RuntimeLibcall;
-def STRRCHR : RuntimeLibcall;
-def STRSPN : RuntimeLibcall;
-def STRSTR : RuntimeLibcall;
-def STRTOD : RuntimeLibcall;
-def STRTOF : RuntimeLibcall;
-def STRTOK : RuntimeLibcall;
-def STRTOK_R : RuntimeLibcall;
-def STRTOL : RuntimeLibcall;
-def STRTOLD : RuntimeLibcall;
-def STRTOLL : RuntimeLibcall;
-def STRTOUL : RuntimeLibcall;
-def STRTOULL : RuntimeLibcall;
-def STRXFRM : RuntimeLibcall;
-def SYSTEM : RuntimeLibcall;
-def TERMINATE : RuntimeLibcall;
-def TIMES : RuntimeLibcall;
-def TMPFILE : RuntimeLibcall;
-def TMPFILE64 : RuntimeLibcall;
-def TOASCII : RuntimeLibcall;
-def UNAME : RuntimeLibcall;
-def UNDER_IO_GETC : RuntimeLibcall;
-def UNDER_IO_PUTC : RuntimeLibcall;
-def UNGETC : RuntimeLibcall;
-def UNLINK : RuntimeLibcall;
-def UNSETENV : RuntimeLibcall;
-def UTIME : RuntimeLibcall;
-def UTIMES : RuntimeLibcall;
-def VALLOC : RuntimeLibcall;
-def VEC_CALLOC : RuntimeLibcall;
-def VEC_FREE : RuntimeLibcall;
-def VEC_MALLOC : RuntimeLibcall;
-def VEC_REALLOC : RuntimeLibcall;
-def VFPRINTF : RuntimeLibcall;
-def VFSCANF : RuntimeLibcall;
-def VPRINTF : RuntimeLibcall;
-def VSCANF : RuntimeLibcall;
-def VSNPRINTF : RuntimeLibcall;
-def VSNPRINTF_CHK : RuntimeLibcall;
-def VSPRINTF : RuntimeLibcall;
-def VSPRINTF_CHK : RuntimeLibcall;
-def VSSCANF : RuntimeLibcall;
-def WCSLEN : RuntimeLibcall;
-def WRITE : RuntimeLibcall;
-def ZDAPV : RuntimeLibcall;
-def ZDAPVJ : RuntimeLibcall;
-def ZDAPVJST11ALIGN_VAL_T : RuntimeLibcall;
-def ZDAPVM : RuntimeLibcall;
-def ZDAPVMST11ALIGN_VAL_T : RuntimeLibcall;
-def ZDAPVRKST9NOTHROW_T : RuntimeLibcall;
-def ZDAPVST11ALIGN_VAL_T : RuntimeLibcall;
-def ZDAPVST11ALIGN_VAL_TRKST9NOTHROW_T : RuntimeLibcall;
-def ZDLPV : RuntimeLibcall;
-def ZDLPVJ : RuntimeLibcall;
-def ZDLPVJST11ALIGN_VAL_T : RuntimeLibcall;
-def ZDLPVM : RuntimeLibcall;
-def ZDLPVMST11ALIGN_VAL_T : RuntimeLibcall;
-def ZDLPVRKST9NOTHROW_T : RuntimeLibcall;
-def ZDLPVST11ALIGN_VAL_T : RuntimeLibcall;
-def ZDLPVST11ALIGN_VAL_TRKST9NOTHROW_T : RuntimeLibcall;
-def ZNAJ : RuntimeLibcall;
-def ZNAJRKST9NOTHROW_T : RuntimeLibcall;
-def ZNAJST11ALIGN_VAL_T : RuntimeLibcall;
-def ZNAJST11ALIGN_VAL_TRKST9NOTHROW_T : RuntimeLibcall;
-def ZNAM : RuntimeLibcall;
-def ZNAM12__HOT_COLD_T : RuntimeLibcall;
-def ZNAMRKST9NOTHROW_T : RuntimeLibcall;
-def ZNAMRKST9NOTHROW_T12__HOT_COLD_T : RuntimeLibcall;
-def ZNAMST11ALIGN_VAL_T : RuntimeLibcall;
-def ZNAMST11ALIGN_VAL_T12__HOT_COLD_T : RuntimeLibcall;
-def ZNAMST11ALIGN_VAL_TRKST9NOTHROW_T : RuntimeLibcall;
-def ZNAMST11ALIGN_VAL_TRKST9NOTHROW_T12__HOT_COLD_T : RuntimeLibcall;
-def ZNWJ : RuntimeLibcall;
-def ZNWJRKST9NOTHROW_T : RuntimeLibcall;
-def ZNWJST11ALIGN_VAL_T : RuntimeLibcall;
-def ZNWJST11ALIGN_VAL_TRKST9NOTHROW_T : RuntimeLibcall;
-def ZNWM : RuntimeLibcall;
-def ZNWM12__HOT_COLD_T : RuntimeLibcall;
-def ZNWMRKST9NOTHROW_T : RuntimeLibcall;
-def ZNWMRKST9NOTHROW_T12__HOT_COLD_T : RuntimeLibcall;
-def ZNWMST11ALIGN_VAL_T : RuntimeLibcall;
-def ZNWMST11ALIGN_VAL_T12__HOT_COLD_T : RuntimeLibcall;
-def ZNWMST11ALIGN_VAL_TRKST9NOTHROW_T : RuntimeLibcall;
-def ZNWMST11ALIGN_VAL_TRKST9NOTHROW_T12__HOT_COLD_T : RuntimeLibcall;
-def KMPC_ALLOC_SHARED : RuntimeLibcall;
-def KMPC_FREE_SHARED : RuntimeLibcall;
+def EXECL : RuntimeLibcall<Int, [Ptr, Ptr, Ellip]>;
+def EXECLE : RuntimeLibcall<Int, [Ptr, Ptr, Ellip]>;
+def EXECLP : RuntimeLibcall<Int, [Ptr, Ptr, Ellip]>;
+def EXECV : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def EXECVE : RuntimeLibcall<Int, [Ptr, Ptr, Ptr]>;
+def EXECVP : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def EXECV_P : RuntimeLibcall<Int, [Ptr, Ptr, Ptr]>;
+def EXECVPE : RuntimeLibcall<Int, [Ptr, Ptr, Ptr]>;
+def EXIT : RuntimeLibcall<Void, [Int]>;
+def FCLOSE : RuntimeLibcall<Int, [Ptr]>;
+def FDOPEN : RuntimeLibcall<Ptr, [Int, Ptr]>;
+def FEOF : RuntimeLibcall<Int, [Ptr]>;
+def FERROR : RuntimeLibcall<Int, [Ptr]>;
+def FFLUSH : RuntimeLibcall<Int, [Ptr]>;
+def FFS : RuntimeLibcall<Int, [Int]>;
+def FFSL : RuntimeLibcall<Int, [Long]>;
+def FFSLL : RuntimeLibcall<Int, [LLong]>;
+def FGETC : RuntimeLibcall<Int, [Ptr]>;
+def FGETC_UNLOCKED : RuntimeLibcall<Int, [Ptr]>;
+def FGETPOS : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def FGETS : RuntimeLibcall<Ptr, [Ptr, Int, Ptr]>;
+def FGETS_UNLOCKED : RuntimeLibcall<Ptr, [Ptr, Int, Ptr]>;
+def FILENO : RuntimeLibcall<Int, [Ptr]>;
+def FIPRINTF : RuntimeLibcall<Int, [Ptr, Ptr, Ellip]>;
+def FLOCKFILE : RuntimeLibcall<Void, [Ptr]>;
+def FLS : RuntimeLibcall<Int, [Int]>;
+def FLSL : RuntimeLibcall<Int, [Long]>;
+def FLSLL : RuntimeLibcall<Int, [LLong]>;
+def FOPEN : RuntimeLibcall<Ptr, [Ptr, Ptr]>;
+def FOPEN64 : RuntimeLibcall<Ptr, [Ptr, Ptr]>;
+def FORK : RuntimeLibcall<Int, []>;
+def FPRINTF : RuntimeLibcall<Int, [Ptr, Ptr, Ellip]>;
+def FPUTC : RuntimeLibcall<Int, [Int, Ptr]>;
+def FPUTC_UNLOCKED : RuntimeLibcall<Int, [Int, Ptr]>;
+def FPUTS : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def FPUTS_UNLOCKED : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def FREAD : RuntimeLibcall<SizeT, [Ptr, SizeT, SizeT, Ptr]>;
+def FREAD_UNLOCKED : RuntimeLibcall<SizeT, [Ptr, SizeT, SizeT, Ptr]>;
+def FSCANF : RuntimeLibcall<Int, [Ptr, Ptr, Ellip]>;
+def FSEEK : RuntimeLibcall<Int, [Ptr, Long, Int]>;
+def FSEEKO : RuntimeLibcall<Int, [Ptr, IntX, Int]>;
+def FSEEKO64 : RuntimeLibcall<Int, [Ptr, Int64, Int]>;
+def FSETPOS : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def FSTAT : RuntimeLibcall<Int, [Int, Ptr]>;
+def FSTAT64 : RuntimeLibcall<Int, [Int, Ptr]>;
+def FSTATVFS : RuntimeLibcall<Int, [Int, Ptr]>;
+def FSTATVFS64 : RuntimeLibcall<Int, [Int, Ptr]>;
+def FTELL : RuntimeLibcall<Long, [Ptr]>;
+def FTELLO : RuntimeLibcall<IntPlus, [Ptr]>;
+def FTELLO64 : RuntimeLibcall<Int64, [Ptr]>;
+def FTRYLOCKFILE : RuntimeLibcall<Int, [Ptr]>;
+def FUNLOCKFILE : RuntimeLibcall<Void, [Ptr]>;
+def FWRITE : RuntimeLibcall<SizeT, [Ptr, SizeT, SizeT, Ptr]>;
+def FWRITE_UNLOCKED : RuntimeLibcall<SizeT, [Ptr, SizeT, SizeT, Ptr]>;
+def GETC : RuntimeLibcall<Int, [Ptr]>;
+def GETCHAR : RuntimeLibcall<Int, []>;
+def GETCHAR_UNLOCKED : RuntimeLibcall<Int, []>;
+def GETC_UNLOCKED : RuntimeLibcall<Int, [Ptr]>;
+def GETENV : RuntimeLibcall<Ptr, [Ptr]>;
+def GETITIMER : RuntimeLibcall<Int, [Int, Ptr]>;
+def GETLOGIN_R : RuntimeLibcall<Int, [Ptr, SizeT]>;
+def GETPWNAM : RuntimeLibcall<Ptr, [Ptr]>;
+def GETS : RuntimeLibcall<Ptr, [Ptr]>;
+def GETTIMEOFDAY : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def HTONL : RuntimeLibcall<Int32, [Int32]>;
+def HTONS : RuntimeLibcall<Int16, [Int16]>;
+def IPRINTF : RuntimeLibcall<Int, [Ptr, Ellip]>;
+def ISASCII : RuntimeLibcall<Int, [Int]>;
+def ISDIGIT : RuntimeLibcall<Int, [Int]>;
+def LABS : RuntimeLibcall<Long, [Same]>;
+def LCHOWN : RuntimeLibcall<Int, [Ptr, IntX, IntX]>;
+def LLABS : RuntimeLibcall<LLong, [LLong]>;
+def LSTAT : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def LSTAT64 : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def MEMALIGN : RuntimeLibcall<Ptr, [SizeT, SizeT]>;
+def MEMCCPY : RuntimeLibcall<Ptr, [Ptr, Ptr, Int, SizeT]>;
+def MEMCCPY_CHK : RuntimeLibcall<Ptr, [Ptr, Ptr, Int, SizeT, SizeT]>;
+def MEMCHR : RuntimeLibcall<Ptr, [Ptr, Int, SizeT]>;
+def MEMPCPY : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT]>;
+def MEMPCPY_CHK : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT, SizeT]>;
+def MEMRCHR : RuntimeLibcall<Ptr, [Ptr, Int, SizeT]>;
+def MEMSET_PATTERN16 : RuntimeLibcall<Void, [Ptr, Ptr, SizeT]>;
+def MEMSET_PATTERN4 : RuntimeLibcall<Void, [Ptr, Ptr, SizeT]>;
+def MEMSET_PATTERN8 : RuntimeLibcall<Void, [Ptr, Ptr, SizeT]>;
+def MKDIR : RuntimeLibcall<Int, [Ptr, IntX]>;
+def MKTIME : RuntimeLibcall<IntPlus, [Ptr]>;
+def MSVC_DELETE_ARRAY_PTR32 : RuntimeLibcall<Void, [Ptr]>;
+def MSVC_DELETE_ARRAY_PTR32_INT : RuntimeLibcall<Void, [Ptr, Int]>;
+def MSVC_DELETE_ARRAY_PTR32_NOTHROW : RuntimeLibcall<Void, [Ptr, Ptr]>;
+def MSVC_DELETE_ARRAY_PTR64 : RuntimeLibcall<Void, [Ptr]>;
+def MSVC_DELETE_ARRAY_PTR64_LONGLONG : RuntimeLibcall<Void, [Ptr, LLong]>;
+def MSVC_DELETE_ARRAY_PTR64_NOTHROW : RuntimeLibcall<Void, [Ptr, Ptr]>;
+def MSVC_DELETE_PTR32 : RuntimeLibcall<Void, [Ptr]>;
+def MSVC_DELETE_PTR32_INT : RuntimeLibcall<Void, [Ptr, Int]>;
+def MSVC_DELETE_PTR32_NOTHROW : RuntimeLibcall<Void, [Ptr, Ptr]>;
+def MSVC_DELETE_PTR64 : RuntimeLibcall<Void, [Ptr]>;
+def MSVC_DELETE_PTR64_LONGLONG : RuntimeLibcall<Void, [Ptr, LLong]>;
+def MSVC_DELETE_PTR64_NOTHROW : RuntimeLibcall<Void, [Ptr, Ptr]>;
+def MSVC_NEW_ARRAY_INT : RuntimeLibcall<Ptr, [Int]>;
+def MSVC_NEW_ARRAY_INT_NOTHROW : RuntimeLibcall<Ptr, [Int, Ptr]>;
+def MSVC_NEW_ARRAY_LONGLONG : RuntimeLibcall<Ptr, [LLong]>;
+def MSVC_NEW_ARRAY_LONGLONG_NOTHROW : RuntimeLibcall<Ptr, [LLong, Ptr]>;
+def MSVC_NEW_INT : RuntimeLibcall<Ptr, [Int]>;
+def MSVC_NEW_INT_NOTHROW : RuntimeLibcall<Ptr, [Int, Ptr]>;
+def MSVC_NEW_LONGLONG : RuntimeLibcall<Ptr, [LLong]>;
+def MSVC_NEW_LONGLONG_NOTHROW : RuntimeLibcall<Ptr, [LLong, Ptr]>;
+def NTOHL : RuntimeLibcall<Int32, [Int32]>;
+def NTOHS : RuntimeLibcall<Int16, [Int16]>;
+def OPEN : RuntimeLibcall<Int, [Ptr, Int, Ellip]>;
+def OPEN64 : RuntimeLibcall<Int, [Ptr, Int, Ellip]>;
+def OPENDIR : RuntimeLibcall<Ptr, [Ptr]>;
+def PCLOSE : RuntimeLibcall<Int, [Ptr]>;
+def PERROR : RuntimeLibcall<Void, [Ptr]>;
+def POPEN : RuntimeLibcall<Ptr, [Ptr, Ptr]>;
+def POSIX_MEMALIGN : RuntimeLibcall<Int, [Ptr, SizeT, SizeT]>;
+def PREAD : RuntimeLibcall<SSizeT, [Int, Ptr, SizeT, IntPlus]>;
+def PRINTF : RuntimeLibcall<Int, [Ptr, Ellip]>;
+def PUTC : RuntimeLibcall<Int, [Int, Ptr]>;
+def PUTCHAR : RuntimeLibcall<Int, [Int]>;
+def PUTCHAR_UNLOCKED : RuntimeLibcall<Int, [Int]>;
+def PUTC_UNLOCKED : RuntimeLibcall<Int, [Int, Ptr]>;
+def PUTS : RuntimeLibcall<Int, [Ptr]>;
+def PVALLOC : RuntimeLibcall<Ptr, [SizeT]>;
+def PWRITE : RuntimeLibcall<SSizeT, [Int, Ptr, SizeT, IntPlus]>;
+def QSORT : RuntimeLibcall<Void, [Ptr, SizeT, SizeT, Ptr]>;
+def READ : RuntimeLibcall<SSizeT, [Int, Ptr, SizeT]>;
+def READLINK : RuntimeLibcall<SSizeT, [Ptr, Ptr, SizeT]>;
+def REALLOC : RuntimeLibcall<Ptr, [Ptr, SizeT]>;
+def REALLOCARRAY : RuntimeLibcall<Ptr, [Ptr, SizeT, SizeT]>;
+def REALLOCF : RuntimeLibcall<Ptr, [Ptr, SizeT]>;
+def REALPATH : RuntimeLibcall<Ptr, [Ptr, Ptr]>;
+def REMOVE : RuntimeLibcall<Int, [Ptr]>;
+def RENAME : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def REWIND : RuntimeLibcall<Void, [Ptr]>;
+def RMDIR : RuntimeLibcall<Int, [Ptr]>;
+def SCANF : RuntimeLibcall<Int, [Ptr, Ellip]>;
+def SETBUF : RuntimeLibcall<Void, [Ptr, Ptr]>;
+def SETITIMER : RuntimeLibcall<Int, [Int, Ptr, Ptr]>;
+def SETVBUF : RuntimeLibcall<Int, [Ptr, Ptr, Int, SizeT]>;
+def SIPRINTF : RuntimeLibcall<Int, [Ptr, Ptr, Ellip]>;
+def SIZE_RETURNING_NEW : RuntimeLibcall<NoneType, []>;
+def SIZE_RETURNING_NEW_ALIGNED : RuntimeLibcall<NoneType, []>;
+def SIZE_RETURNING_NEW_ALIGNED_HOT_COLD : RuntimeLibcall<NoneType, []>;
+def SIZE_RETURNING_NEW_HOT_COLD : RuntimeLibcall<NoneType, []>;
+def SMALL_FPRINTF : RuntimeLibcall<Int, [Ptr, Ptr, Ellip]>;
+def SMALL_PRINTF : RuntimeLibcall<Int, [Ptr, Ellip]>;
+def SMALL_SPRINTF : RuntimeLibcall<Int, [Ptr, Ptr, Ellip]>;
+def SNPRINTF : RuntimeLibcall<Int, [Ptr, SizeT, Ptr, Ellip]>;
+def SNPRINTF_CHK : RuntimeLibcall<Int, [Ptr, SizeT, Int, SizeT, Ptr, Ellip]>;
+def SPRINTF : RuntimeLibcall<Int, [Ptr, Ptr, Ellip]>;
+def SPRINTF_CHK : RuntimeLibcall<Int, [Ptr, Int, SizeT, Ptr, Ellip]>;
+def SSCANF : RuntimeLibcall<Int, [Ptr, Ptr, Ellip]>;
+def STAT : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def STAT64 : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def STATVFS : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def STATVFS64 : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def STPCPY : RuntimeLibcall<Ptr, [Ptr, Ptr]>;
+def STPCPY_CHK : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT]>;
+def STPNCPY : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT]>;
+def STPNCPY_CHK : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT, SizeT]>;
+def STRCASECMP : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def STRCAT : RuntimeLibcall<Ptr, [Ptr, Ptr]>;
+def STRCAT_CHK : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT]>;
+def STRCHR : RuntimeLibcall<Ptr, [Ptr, Int]>;
+def STRCMP : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def STRCOLL : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def STRCPY : RuntimeLibcall<Ptr, [Ptr, Ptr]>;
+def STRCPY_CHK : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT]>;
+def STRCSPN : RuntimeLibcall<SizeT, [Ptr, Ptr]>;
+def STRDUP : RuntimeLibcall<Ptr, [Ptr]>;
+def STRLCAT : RuntimeLibcall<SizeT, [Ptr, Ptr, SizeT]>;
+def STRLCAT_CHK : RuntimeLibcall<SizeT, [Ptr, Ptr, SizeT, SizeT]>;
+def STRLCPY : RuntimeLibcall<SizeT, [Ptr, Ptr, SizeT]>;
+def STRLCPY_CHK : RuntimeLibcall<SizeT, [Ptr, Ptr, SizeT, SizeT]>;
+def STRLEN_CHK : RuntimeLibcall<SizeT, [Ptr, SizeT]>;
+def STRNCASECMP : RuntimeLibcall<Int, [Ptr, Ptr, SizeT]>;
+def STRNCAT : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT]>;
+def STRNCAT_CHK : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT, SizeT]>;
+def STRNCMP : RuntimeLibcall<Int, [Ptr, Ptr, SizeT]>;
+def STRNCPY : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT]>;
+def STRNCPY_CHK : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT, SizeT]>;
+def STRNDUP : RuntimeLibcall<Ptr, [Ptr, SizeT]>;
+def STRNLEN : RuntimeLibcall<SizeT, [Ptr, SizeT]>;
+def STRPBRK : RuntimeLibcall<Ptr, [Ptr, Ptr]>;
+def STRRCHR : RuntimeLibcall<Ptr, [Ptr, Int]>;
+def STRSPN : RuntimeLibcall<SizeT, [Ptr, Ptr]>;
+def STRSTR : RuntimeLibcall<Ptr, [Ptr, Ptr]>;
+def STRTOD : RuntimeLibcall<Dbl, [Ptr, Ptr]>;
+def STRTOF : RuntimeLibcall<Flt, [Ptr, Ptr]>;
+def STRTOK : RuntimeLibcall<Ptr, [Ptr, Ptr]>;
+def STRTOK_R : RuntimeLibcall<Ptr, [Ptr, Ptr, Ptr]>;
+def STRTOL : RuntimeLibcall<Long, [Ptr, Ptr, Int]>;
+def STRTOLD : RuntimeLibcall<LDbl, [Ptr, Ptr]>;
+def STRTOLL : RuntimeLibcall<LLong, [Ptr, Ptr, Int]>;
+def STRTOUL : RuntimeLibcall<Long, [Ptr, Ptr, Int]>;
+def STRTOULL : RuntimeLibcall<LLong, [Ptr, Ptr, Int]>;
+def STRXFRM : RuntimeLibcall<SizeT, [Ptr, Ptr, SizeT]>;
+def SYSTEM : RuntimeLibcall<Int, [Ptr]>;
+def TERMINATE : RuntimeLibcall<Void, []>;
+def TIMES : RuntimeLibcall<IntPlus, [Ptr]>;
+def TMPFILE : RuntimeLibcall<Ptr, []>;
+def TMPFILE64 : RuntimeLibcall<Ptr, []>;
+def TOASCII : RuntimeLibcall<Int, [Int]>;
+def UNAME : RuntimeLibcall<Int, [Ptr]>;
+def UNDER_IO_GETC : RuntimeLibcall<Int, [Ptr]>;
+def UNDER_IO_PUTC : RuntimeLibcall<Int, [Int, Ptr]>;
+def UNGETC : RuntimeLibcall<Int, [Int, Ptr]>;
+def UNLINK : RuntimeLibcall<Int, [Ptr]>;
+def UNSETENV : RuntimeLibcall<Int, [Ptr]>;
+def UTIME : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def UTIMES : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def VALLOC : RuntimeLibcall<Ptr, [SizeT]>;
+def VEC_CALLOC : RuntimeLibcall<Ptr, [SizeT, SizeT]>;
+def VEC_FREE : RuntimeLibcall<Void, [Ptr]>;
+def VEC_MALLOC : RuntimeLibcall<Ptr, [SizeT]>;
+def VEC_REALLOC : RuntimeLibcall<Ptr, [Ptr, SizeT]>;
+def VFPRINTF : RuntimeLibcall<Int, [Ptr, Ptr, Ptr]>;
+def VFSCANF : RuntimeLibcall<Int, [Ptr, Ptr, Ptr]>;
+def VPRINTF : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def VSCANF : RuntimeLibcall<Int, [Ptr, Ptr]>;
+def VSNPRINTF : RuntimeLibcall<Int, [Ptr, SizeT, Ptr, Ptr]>;
+def VSNPRINTF_CHK : RuntimeLibcall<Int, [Ptr, SizeT, Int, SizeT, Ptr, Ptr]>;
+def VSPRINTF : RuntimeLibcall<Int, [Ptr, Ptr, Ptr]>;
+def VSPRINTF_CHK : RuntimeLibcall<Int, [Ptr, Int, SizeT, Ptr, Ptr]>;
+def VSSCANF : RuntimeLibcall<Int, [Ptr, Ptr, Ptr]>;
+def WCSLEN : RuntimeLibcall<SizeT, [Ptr]>;
+def WRITE : RuntimeLibcall<SSizeT, [Int, Ptr, SizeT]>;
+def ZDAPV : RuntimeLibcall<Void, [Ptr]>;
+def ZDAPVJ : RuntimeLibcall<Void, [Ptr, Int]>;
+def ZDAPVJST11ALIGN_VAL_T : RuntimeLibcall<Void, [Ptr, Int, Int]>;
+def ZDAPVM : RuntimeLibcall<Void, [Ptr, Long]>;
+def ZDAPVMST11ALIGN_VAL_T : RuntimeLibcall<Void, [Ptr, Long, Long]>;
+def ZDAPVRKST9NOTHROW_T : RuntimeLibcall<Void, [Ptr, Ptr]>;
+def ZDAPVST11ALIGN_VAL_T : RuntimeLibcall<Void, [Ptr, IntPlus]>;
+def ZDAPVST11ALIGN_VAL_TRKST9NOTHROW_T : RuntimeLibcall<Void, [Ptr, IntPlus, Ptr]>;
+def ZDLPV : RuntimeLibcall<Void, [Ptr]>;
+def ZDLPVJ : RuntimeLibcall<Void, [Ptr, Int]>;
+def ZDLPVJST11ALIGN_VAL_T : RuntimeLibcall<Void, [Ptr, Int, Int]>;
+def ZDLPVM : RuntimeLibcall<Void, [Ptr, Long]>;
+def ZDLPVMST11ALIGN_VAL_T : RuntimeLibcall<Void, [Ptr, Long, Long]>;
+def ZDLPVRKST9NOTHROW_T : RuntimeLibcall<Void, [Ptr, Ptr]>;
+def ZDLPVST11ALIGN_VAL_T : RuntimeLibcall<Void, [Ptr, IntPlus]>;
+def ZDLPVST11ALIGN_VAL_TRKST9NOTHROW_T : RuntimeLibcall<Void, [Ptr, IntPlus, Ptr]>;
+def ZNAJ : RuntimeLibcall<Ptr, [Int]>;
+def ZNAJRKST9NOTHROW_T : RuntimeLibcall<Ptr, [Int, Ptr]>;
+def ZNAJST11ALIGN_VAL_T : RuntimeLibcall<Ptr, [Int, Int]>;
+def ZNAJST11ALIGN_VAL_TRKST9NOTHROW_T : RuntimeLibcall<Ptr, [Int, Int, Ptr]>;
+def ZNAM : RuntimeLibcall<Ptr, [Long]>;
+def ZNAM12__HOT_COLD_T : RuntimeLibcall<Ptr, [Long, Bool]>;
+def ZNAMRKST9NOTHROW_T : RuntimeLibcall<Ptr, [Long, Ptr]>;
+def ZNAMRKST9NOTHROW_T12__HOT_COLD_T : RuntimeLibcall<Ptr, [Long, Ptr, Bool]>;
+def ZNAMST11ALIGN_VAL_T : RuntimeLibcall<Ptr, [Long, Long]>;
+def ZNAMST11ALIGN_VAL_T12__HOT_COLD_T : RuntimeLibcall<Ptr, [Long, Long, Bool]>;
+def ZNAMST11ALIGN_VAL_TRKST9NOTHROW_T : RuntimeLibcall<Ptr, [Long, Long, Ptr]>;
+def ZNAMST11ALIGN_VAL_TRKST9NOTHROW_T12__HOT_COLD_T : RuntimeLibcall<Ptr, [Long, Long, Ptr, Bool]>;
+def ZNWJ : RuntimeLibcall<Ptr, [Int]>;
+def ZNWJRKST9NOTHROW_T : RuntimeLibcall<Ptr, [Int, Ptr]>;
+def ZNWJST11ALIGN_VAL_T : RuntimeLibcall<Ptr, [Int, Int]>;
+def ZNWJST11ALIGN_VAL_TRKST9NOTHROW_T : RuntimeLibcall<Ptr, [Int, Int, Ptr]>;
+def ZNWM : RuntimeLibcall<Ptr, [Long]>;
+def ZNWM12__HOT_COLD_T : RuntimeLibcall<Ptr, [Long, Bool]>;
+def ZNWMRKST9NOTHROW_T : RuntimeLibcall<Ptr, [Long, Ptr]>;
+def ZNWMRKST9NOTHROW_T12__HOT_COLD_T : RuntimeLibcall<Ptr, [Long, Ptr, Bool]>;
+def ZNWMST11ALIGN_VAL_T : RuntimeLibcall<Ptr, [Long, Long]>;
+def ZNWMST11ALIGN_VAL_T12__HOT_COLD_T : RuntimeLibcall<Ptr, [Long, Long, Bool]>;
+def ZNWMST11ALIGN_VAL_TRKST9NOTHROW_T : RuntimeLibcall<Ptr, [Long, Long, Ptr]>;
+def ZNWMST11ALIGN_VAL_TRKST9NOTHROW_T12__HOT_COLD_T : RuntimeLibcall<Ptr, [Long, Long, Ptr, Bool]>;
+def KMPC_ALLOC_SHARED : RuntimeLibcall<Ptr, [SizeT]>;
+def KMPC_FREE_SHARED : RuntimeLibcall<Void, [Ptr, SizeT]>;
+
+def NVVM_REFLECT : RuntimeLibcall<Int, [Ptr]>;
 
 //--------------------------------------------------------------------
 // Global variable references
@@ -1646,7 +1690,7 @@ def execl : RuntimeLibcallImpl<EXECL>;
 def execle : RuntimeLibcallImpl<EXECLE>;
 def execlp : RuntimeLibcallImpl<EXECLP>;
 def execv : RuntimeLibcallImpl<EXECV>;
-def execvP : RuntimeLibcallImpl<EXECVP>;
+def execvP : RuntimeLibcallImpl<EXECV_P>;
 def execve : RuntimeLibcallImpl<EXECVE>;
 def execvp : RuntimeLibcallImpl<EXECVP>;
 def execvpe : RuntimeLibcallImpl<EXECVPE>;
@@ -1826,6 +1870,34 @@ def vsscanf : RuntimeLibcallImpl<VSSCANF>;
 def wcslen : RuntimeLibcallImpl<WCSLEN>;
 def write : RuntimeLibcallImpl<WRITE>;
 
+defm __acos_finite : LibmLibcallImpls<"ACOS_FINITE", "__acos<typesuffix>_finite">;
+defm __acosh_finite : LibmLibcallImpls<"ACOSH_FINITE", "__acosh<typesuffix>_finite">;
+defm __asin_finite : LibmLibcallImpls<"ASIN_FINITE", "__asin<typesuffix>_finite">;
+defm __atan2_finite : LibmLibcallImpls<"ATAN2_FINITE", "__atan2<typesuffix>_finite">;
+defm __atanh_finite : LibmLibcallImpls<"ATANH_FINITE", "__atanh<typesuffix>_finite">;
+defm __cosh_finite : LibmLibcallImpls<"COSH_FINITE", "__cosh<typesuffix>_finite">;
+defm __sinh_finite : LibmLibcallImpls<"SINH_FINITE", "__sinh<typesuffix>_finite">;
+defm __exp10_finite : LibmLibcallImpls<"EXP10_FINITE", "__exp10<typesuffix>_finite">;
+defm __sqrt_finite : LibmLibcallImpls<"SQRT_FINITE", "__sqrt<typesuffix>_finite">;
+defm __cospi : LibmLibcallImpls<"COSPI">;
+defm __sinpi : LibmLibcallImpls<"SINPI">;
+defm acosh : LibmLibcallImpls;
+defm asinh : LibmLibcallImpls;
+defm atanh : LibmLibcallImpls;
+defm erf : LibmLibcallImpls;
+defm expm1 : LibmLibcallImpls;
+defm fabs : LibmLibcallImpls;
+defm hypot : LibmLibcallImpls;
+defm log1p : LibmLibcallImpls;
+defm ilogb : LibmLibcallImpls;
+defm logb : LibmLibcallImpls;
+defm nextafter : LibmLibcallImpls;
+
+def __nvvm_reflect : RuntimeLibcallImpl<NVVM_REFLECT>;
+
+def __sincospif_stret : RuntimeLibcallImpl<SINCOSPI_STRET_F32>;
+def __sincospi_stret : RuntimeLibcallImpl<SINCOSPI_STRET_F64>;
+
 //--------------------------------------------------------------------
 // compiler-rt/libgcc but 64-bit only, not available by default
 //--------------------------------------------------------------------
diff --git a/llvm/include/llvm/IR/RuntimeLibcallsImpl.td b/llvm/include/llvm/IR/RuntimeLibcallsImpl.td
index 516cf0515a103..14e8bf1ffa0ac 100644
--- a/llvm/include/llvm/IR/RuntimeLibcallsImpl.td
+++ b/llvm/include/llvm/IR/RuntimeLibcallsImpl.td
@@ -56,6 +56,35 @@ def SMEABI_PreserveMost_From_X0 : LibcallCallingConv<[{CallingConv::AArch64_SME_
 def SMEABI_PreserveMost_From_X1 : LibcallCallingConv<[{CallingConv::AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1}]>;
 def SMEABI_PreserveMost_From_X2 : LibcallCallingConv<[{CallingConv::AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2}]>;
 
+
+// Return type or argument type of library calls.
+class FuncArgType {
+  string Name = NAME;
+}
+
+// Recognized types of library call arguments and return types.
+def NoneType : FuncArgType; // dummy
+def Void : FuncArgType;
+def Bool : FuncArgType;     // 8 bits on all targets
+def Int16 : FuncArgType;
+def Int32 : FuncArgType;
+def Int : FuncArgType;
+def IntPlus : FuncArgType;  // Int or bigger.
+def Long : FuncArgType;     // Either 32 or 64 bits.
+def IntX : FuncArgType;     // Any integer type.
+def Int64 : FuncArgType;
+def LLong : FuncArgType;    // 64 bits on all targets.
+def SizeT : FuncArgType;    // size_t.
+def SSizeT : FuncArgType;   // POSIX ssize_t.
+def Flt : FuncArgType;      // IEEE float.
+def Dbl : FuncArgType;      // IEEE double.
+def LDbl : FuncArgType;     // Any floating type (TODO: tighten this up).
+def Floating : FuncArgType; // Any floating type.
+def Ptr : FuncArgType;      // Any pointer type.
+def Struct : FuncArgType;   // Any struct type.
+def Ellip : FuncArgType;    // The ellipsis (...).
+def Same : FuncArgType;     // Same argument type as the previous one.
+
 /// Abstract definition for functionality the compiler may need to
 /// emit a call to. Emits the RTLIB::Libcall enum - This enum defines
 /// all of the runtime library calls the backend can emit. The various
@@ -65,10 +94,13 @@ def SMEABI_PreserveMost_From_X2 : LibcallCallingConv<[{CallingConv::AArch64_SME_
 /// When adding PPCF128 functions here, note that their names generally need
 /// to be overridden for Darwin with the xxx$LDBL128 form.  See
 /// PPCISelLowering.cpp.
-class RuntimeLibcall {
+class RuntimeLibcall<FuncArgType RetType = NoneType,
+                     list<FuncArgType> ArgTypes = []> {
   string Name = NAME;
+  FuncArgType ReturnType = RetType;
+  list<FuncArgType> ArgumentTypes = ArgTypes;
 
-  // TODO: Record type signature and attributes
+  // TODO: Record attributes
 }
 
 // Concrete implementation of a libcall, which may have a different
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index d55d1c4ac5883..f4d345b8a568b 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -21,6 +21,7 @@ using namespace RTLIB;
 
 #define GET_RUNTIME_LIBCALLS_INFO
 #define GET_INIT_RUNTIME_LIBCALL_NAMES
+#define GET_INIT_RUNTIME_LIBCALL_SIGNATURES
 #define GET_SET_TARGET_RUNTIME_LIBCALL_SETS
 #define DEFINE_GET_LOOKUP_LIBCALL_IMPL_NAME
 #define GET_RUNTIME_LIBCALL_INTRINSIC_TO_LIBCALL
@@ -154,6 +155,46 @@ static IntegerType *getSizeTType(LLVMContext &Ctx, const DataLayout &DL) {
   return DL.getIndexType(Ctx, /*AddressSpace=*/0);
 }
 
+static Type *convertToIRType(FuncArgTypeID ID, LLVMContext &Ctx,
+                             const Triple &TT, const DataLayout &DL) {
+
+  unsigned IntBits = TT.isArch16Bit() ? 16 : 32;
+
+  switch (ID) {
+  case Void:
+    return Type::getVoidTy(Ctx);
+  case Bool:
+    return IntegerType::get(Ctx, 8);
+  case Int16:
+    return IntegerType::get(Ctx, 16);
+  case Int32:
+    return IntegerType::get(Ctx, 32);
+  case Int:
+  case IntPlus:
+  case Long:
+  case IntX:
+    return IntegerType::get(Ctx, IntBits);
+  case LLong:
+    return IntegerType::get(Ctx, 64);
+  case SizeT:
+  case SSizeT:
+    return getSizeTType(Ctx, DL);
+  case Flt:
+  case Floating:
+    return Type::getFloatTy(Ctx);
+  case Dbl:
+    return Type::getDoubleTy(Ctx);
+  case LDbl:
+    return Type::getDoubleTy(Ctx);
+  case Ptr:
+    return PointerType::get(Ctx, 0);
+  case Struct:
+    return nullptr; // This typy is not used.
+  default:
+    return nullptr;
+  }
+}
+
 std::pair<FunctionType *, AttributeList>
 RuntimeLibcallsInfo::getFunctionTy(LLVMContext &Ctx, const Triple &TT,
                                    const DataLayout &DL,
@@ -462,6 +503,37 @@ RuntimeLibcallsInfo::getFunctionTy(LLVMContext &Ctx, const Triple &TT,
     return {FunctionType::get(Type::getVoidTy(Ctx), ArgTys, false), Attrs};
   }
   default:
+    // Get C-type function signature of the Libcall if provided,
+    // and convert it to IR FunctionType.
+    Libcall LC = getLibcallFromImpl(LibcallImpl);
+    const FuncArgTypeID *ProtoTypes = &SignatureTable[SignatureOffset[LC]];
+
+    if (ProtoTypes[0] != NoFuncArgType) {
+      Type *RetTy = convertToIRType(ProtoTypes[0], Ctx, TT, DL);
+      Type *LastTy = RetTy, *ArgTy;
+      SmallVector<Type *, 4> ArgTys;
+      bool IsVarArg(false);
+      unsigned Idx = 1;
+      for (FuncArgTypeID TyID = ProtoTypes[Idx]; TyID != NoFuncArgType;
+           TyID = ProtoTypes[++Idx]) {
+        if (TyID == Ellip) {
+          // The ellipsis ends the protoype list so it must be followed by
+          // NoFuncArgType.
+          assert(ProtoTypes[Idx + 1] == NoFuncArgType);
+          IsVarArg = true;
+          break;
+        }
+        if (TyID == Same) {
+          ArgTy = LastTy;
+        } else {
+          ArgTy = convertToIRType(ProtoTypes[Idx], Ctx, TT, DL);
+          LastTy = ArgTy;
+        }
+        ArgTys.push_back(ArgTy);
+      }
+      return {FunctionType::get(RetTy, ArgTys, IsVarArg), AttributeList()};
+    }
+
     return {};
   }
 
diff --git a/llvm/test/TableGen/RuntimeLibcallEmitter.td b/llvm/test/TableGen/RuntimeLibcallEmitter.td
index edff4d4224a2a..38259f67a9cb6 100644
--- a/llvm/test/TableGen/RuntimeLibcallEmitter.td
+++ b/llvm/test/TableGen/RuntimeLibcallEmitter.td
@@ -6,12 +6,12 @@ include "llvm/IR/RuntimeLibcallsImpl.td"
 def SHL_I32 : RuntimeLibcall;
 def SRL_I64 : RuntimeLibcall;
 
-def SQRT_F128 : RuntimeLibcall;
+def SQRT_F128 : RuntimeLibcall<LDbl, [LDbl]>;
 def SQRT_F80 : RuntimeLibcall;
-def BZERO : RuntimeLibcall;
-def MEMCPY : RuntimeLibcall;
-def MEMSET : RuntimeLibcall;
-def CALLOC : RuntimeLibcall;
+def BZERO : RuntimeLibcall<Void, [Ptr, SizeT]>;
+def MEMCPY : RuntimeLibcall<Ptr, [Ptr, Ptr, SizeT]>;
+def MEMSET : RuntimeLibcall<Ptr, [Ptr, Int, SizeT]>;
+def CALLOC : RuntimeLibcall<Ptr, [SizeT, SizeT]>;
 
 def __ashlsi3 : RuntimeLibcallImpl<SHL_I32>;
 def __lshrdi3 : RuntimeLibcallImpl<SRL_I64>;
@@ -109,6 +109,30 @@ def BlahLibrary : SystemRuntimeLibrary<isBlahArch, (add calloc, LibraryWithCondi
 // CHECK-NEXT:  sqrtl_f80 = 8, // sqrtl
 // CHECK-NEXT: };
 // CHECK-NEXT: constexpr size_t NumLibcallImpls = 9;
+// CHECK-EMPTY:
+// CHECK-NEXT:enum FuncArgTypeID : char {
+// CHECK-NEXT:  NoFuncArgType = 0,
+// CHECK-NEXT:  Bool,
+// CHECK-NEXT:  Dbl,
+// CHECK-NEXT:  Ellip,
+// CHECK-NEXT:  Floating,
+// CHECK-NEXT:  Flt,
+// CHECK-NEXT:  Int,
+// CHECK-NEXT:  Int16,
+// CHECK-NEXT:  Int32,
+// CHECK-NEXT:  Int64,
+// CHECK-NEXT:  IntPlus,
+// CHECK-NEXT:  IntX,
+// CHECK-NEXT:  LDbl,
+// CHECK-NEXT:  LLong,
+// CHECK-NEXT:  Long,
+// CHECK-NEXT:  Ptr,
+// CHECK-NEXT:  SSizeT,
+// CHECK-NEXT:  Same,
+// CHECK-NEXT:  SizeT,
+// CHECK-NEXT:  Struct,
+// CHECK-NEXT:  Void,
+// CHECK-NEXT:};
 // CHECK-NEXT: } // End namespace RTLIB
 // CHECK-NEXT: } // End namespace llvm
 // CHECK-EMPTY:
@@ -207,6 +231,31 @@ def BlahLibrary : SystemRuntimeLibrary<isBlahArch, (add calloc, LibraryWithCondi
 // CHECK: return enum_seq(RTLIB::Unsupported, RTLIB::Unsupported);
 // CHECK-NEXT: }
 
+// CHECK:#ifdef GET_INIT_RUNTIME_LIBCALL_SIGNATURES
+// CHECK-NEXT:#undef GET_INIT_RUNTIME_LIBCALL_SIGNATURES
+// CHECK-EMPTY:
+// CHECK-EMPTY:
+// CHECK-NEXT:const FuncArgTypeID RTLIB::RuntimeLibcallsInfo::SignatureTable[] = {
+// CHECK-NEXT:  /* 0 */ LDbl, LDbl, NoFuncArgType,
+// CHECK-NEXT:  /* 3 */ Ptr, Ptr, Int, SizeT, NoFuncArgType,
+// CHECK-NEXT:  /* 8 */ Ptr, Ptr, Ptr, SizeT, NoFuncArgType,
+// CHECK-NEXT:  /* 13 */ Void, Ptr, SizeT, NoFuncArgType,
+// CHECK-NEXT:  /* 17 */ Ptr, SizeT, SizeT, NoFuncArgType,
+// CHECK-NEXT:};
+// CHECK-EMPTY:
+// CHECK-NEXT:const uint16_t RTLIB::RuntimeLibcallsInfo::SignatureOffset[] = {
+// CHECK-NEXT:  13, // BZERO
+// CHECK-NEXT:  17, // CALLOC
+// CHECK-NEXT:  8, // MEMCPY
+// CHECK-NEXT:  3, // MEMSET
+// CHECK-NEXT:  2, // SHL_I32
+// CHECK-NEXT:  2, // SQRT_F80
+// CHECK-NEXT:  0, // SQRT_F128
+// CHECK-NEXT:  2, // SRL_I64
+// CHECK-NEXT:};
+// CHECK-EMPTY:
+// CHECK-NEXT:#endif // GET_INIT_RUNTIME_LIBCALL_SIGNATURES
+
 // CHECK: void llvm::RTLIB::RuntimeLibcallsInfo::setTargetRuntimeLibcallSets(const llvm::Triple &TT, ExceptionHandling ExceptionModel, FloatABI::ABIType FloatABI, StringRef ABIName, LongDoubleFormat LongDoubleFormat) {
 // CHECK-EMPTY:
 // CHECK-NEXT: if (TT.getArch() == Triple::blah) {
diff --git a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/aix.ll b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/aix.ll
index 97a3d487ad0ee..7bd763b829dda 100644
--- a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/aix.ll
+++ b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/aix.ll
@@ -1,7 +1,7 @@
 ; REQUIRES: webassembly-registered-target
 ; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=powerpc64-ibm-aix < %s | FileCheck %s
 
-; CHECK: declare void @vec_calloc(...)
-; CHECK: declare void @vec_free(...)
-; CHECK: declare void @vec_malloc(...)
-; CHECK: declare void @vec_realloc(...)
+; CHECK: declare ptr @vec_calloc(i64, i64)
+; CHECK: declare void @vec_free(ptr)
+; CHECK: declare ptr @vec_malloc(i64)
+; CHECK: declare ptr @vec_realloc(ptr, i64)
diff --git a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/basic.ll b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/basic.ll
index 33ac172d77beb..7f2a75f232ef9 100644
--- a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/basic.ll
+++ b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/basic.ll
@@ -13,57 +13,57 @@ define float @sinf(float %x) {
 
 ; CHECK: declare void @_Unwind_Resume(...)
 
-; CHECK: declare void @__memcpy_chk(...)
-; CHECK: declare void @__memmove_chk(...)
-; CHECK: declare void @__memset_chk(...)
+; CHECK: declare ptr @__memcpy_chk(ptr, ptr, i64, i64)
+; CHECK: declare ptr @__memmove_chk(ptr, ptr, i64, i64)
+; CHECK: declare ptr @__memset_chk(ptr, i32, i64, i64)
 
 ; CHECK: declare void @__umodti3(...)
 
-; CHECK: declare void @acosf(...)
+; CHECK: declare float @acosf(float)
 
 ; CHECK: declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) [[CALLOC_ATTRS:#[0-9]+]]
 
-; CHECK: declare void @fdim(...)
-; CHECK: declare void @fdimf(...)
-; CHECK: declare void @fdiml(...)
+; CHECK: declare double @fdim(double, double)
+; CHECK: declare float @fdimf(float, float)
+; CHECK: declare double @fdiml(double, double)
 
 ; CHECK: declare void @free(ptr allocptr noundef captures(none)) [[FREE_ATTRS:#[0-9]+]]
 
 ; CHECK: declare noalias noundef ptr @malloc(i64 noundef) [[MALLOC_ATTRS:#[0-9]+]]
 
-; CHECK: declare void @nan(...)
-; CHECK: declare void @nanf(...)
-; CHECK: declare void @nanl(...)
+; CHECK: declare double @nan(ptr)
+; CHECK: declare float @nanf(ptr)
+; CHECK: declare double @nanl(ptr)
 
-; CHECK: declare void @nexttoward(...)
-; CHECK: declare void @nexttowardf(...)
-; CHECK: declare void @nexttowardl(...)
+; CHECK: declare double @nexttoward(double, double)
+; CHECK: declare float @nexttowardf(float, double)
+; CHECK: declare double @nexttowardl(double, double)
 
-; CHECK: declare void @remainder(...)
-; CHECK: declare void @remainderf(...)
-; CHECK: declare void @remainderl(...)
+; CHECK: declare double @remainder(double, double)
+; CHECK: declare float @remainderf(float, float)
+; CHECK: declare double @remainderl(double, double)
 
-; CHECK: declare void @remquo(...)
-; CHECK: declare void @remquof(...)
-; CHECK: declare void @remquol(...)
+; CHECK: declare double @remquo(double, double, ptr)
+; CHECK: declare float @remquof(float, float, ptr)
+; CHECK: declare double @remquol(double, double, ptr)
 
-; CHECK: declare void @scalbln(...)
-; CHECK: declare void @scalblnf(...)
-; CHECK: declare void @scalblnl(...)
+; CHECK: declare double @scalbln(double, i32)
+; CHECK: declare float @scalblnf(float, i32)
+; CHECK: declare double @scalblnl(double, i32)
 
-; CHECK: declare void @scalbn(...)
-; CHECK: declare void @scalbnf(...)
-; CHECK: declare void @scalbnl(...)
+; CHECK: declare double @scalbn(double, i32)
+; CHECK: declare float @scalbnf(float, i32)
+; CHECK: declare double @scalbnl(double, i32)
 
 ; CHECK: declare nofpclass(ninf nsub nnorm) double @sqrt(double) [[SQRT_ATTRS:#[0-9]+]]
 
 ; CHECK: declare nofpclass(ninf nsub nnorm) float @sqrtf(float) [[SQRT_ATTRS:#[0-9]+]]
 
-; CHECK: declare void @tgamma(...)
-; CHECK: declare void @tgammaf(...)
-; CHECK: declare void @tgammal(...)
+; CHECK: declare double @tgamma(double)
+; CHECK: declare float @tgammaf(float)
+; CHECK: declare double @tgammal(double)
 
-; CHECK: declare void @truncl(...)
+; CHECK: declare double @truncl(double)
 
 ; CHECK: attributes [[CALLOC_ATTRS]] = { nofree nounwind willreturn allockind("alloc") allocsize(0,1) "alloc-family"="malloc" }
 ; CHECK: attributes [[FREE_ATTRS]] = { nounwind willreturn allockind("free") "alloc-family"="malloc" }
diff --git a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/darwin.ll b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/darwin.ll
index f2226e8149b2c..e8c2f0abcbf1b 100644
--- a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/darwin.ll
+++ b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/darwin.ll
@@ -1,29 +1,32 @@
 ; REQUIRES: aarch64-registered-target, arm-registered-target, x86-registered-target
 
-; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=i386-apple-macosx10.5 < %s | FileCheck -check-prefixes=HAS-MEMSET-PATTERN,MACOS %s
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=i386-apple-macosx10.5 < %s | FileCheck -check-prefixes=HAS-MEMSET-PATTERN-32,MACOS %s
 ; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=i386-apple-macosx10.4 < %s | FileCheck -check-prefixes=NO-MEMSET-PATTERN,MACOS %s
 
-; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=x86_64-apple-macosx10.5 < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=x86_64-apple-macosx10.5 < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN-64 %s
 ; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=x86_64-apple-macosx10.4 < %s | FileCheck -check-prefix=NO-MEMSET-PATTERN %s
 
-; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=arm64-apple-macos10.5 < %s | FileCheck -check-prefixes=HAS-MEMSET-PATTERN,MACOS %s
-; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=arm64-apple-ios3 < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=arm64-apple-macos10.5 < %s | FileCheck -check-prefixes=HAS-MEMSET-PATTERN-64,MACOS %s
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=arm64-apple-ios3 < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN-64 %s
 ; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=arm64-apple-ios2 < %s | FileCheck -check-prefix=NO-MEMSET-PATTERN %s
 
-; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=thumbv7-apple-ios3 < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=thumbv7-apple-ios3 < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN-32 %s
 ; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=thumbv7-apple-ios2 < %s | FileCheck -check-prefix=NO-MEMSET-PATTERN %s
 
-; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=arm64_32-apple-watchos < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
-; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=armv7k-apple-watchos < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=arm64_32-apple-watchos < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN-32 %s
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=armv7k-apple-watchos < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN-32 %s
 
-; MACOS: declare void @getc_unlocked(...)
-; MACOS: declare void @getchar_unlocked(...)
+; MACOS: declare i32 @getc_unlocked(ptr)
+; MACOS: declare i32 @getchar_unlocked()
 
-; HAS-MEMSET-PATTERN: declare void @memset_pattern16(...)
-; HAS-MEMSET-PATTERN: declare void @memset_pattern4(...)
-; HAS-MEMSET-PATTERN: declare void @memset_pattern8(...)
+; HAS-MEMSET-PATTERN-32: declare void @memset_pattern16(ptr, ptr, i32)
+; HAS-MEMSET-PATTERN-32: declare void @memset_pattern4(ptr, ptr, i32)
+; HAS-MEMSET-PATTERN-32: declare void @memset_pattern8(ptr, ptr, i32)
+; HAS-MEMSET-PATTERN-64: declare void @memset_pattern16(ptr, ptr, i64)
+; HAS-MEMSET-PATTERN-64: declare void @memset_pattern4(ptr, ptr, i64)
+; HAS-MEMSET-PATTERN-64: declare void @memset_pattern8(ptr, ptr, i64)
 
-; MACOS: declare void @putc_unlocked(...)
-; MACOS: declare void @putchar_unlocked(...)
+; MACOS: declare i32 @putc_unlocked(i32, ptr)
+; MACOS: declare i32 @putchar_unlocked(i32)
 
 ; NO-MEMSET-PATTERN-NOT: memset_pattern
diff --git a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/emscripten.ll b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/emscripten.ll
index f92f0fe2a189f..b04a6d958d396 100644
--- a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/emscripten.ll
+++ b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/emscripten.ll
@@ -1,6 +1,6 @@
 ; REQUIRES: webassembly-registered-target
 ; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=wasm64-unknown-emscripten < %s | FileCheck %s
 
-; CHECK: declare void @__small_fprintf(...)
-; CHECK: declare void @__small_printf(...)
-; CHECK: declare void @__small_sprintf(...)
+; CHECK: declare i32 @__small_fprintf(ptr, ptr, ...)
+; CHECK: declare i32 @__small_printf(ptr, ...)
+; CHECK: declare i32 @__small_sprintf(ptr, ptr, ...)
diff --git a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/xcore.ll b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/xcore.ll
index c1326ac980f4b..8fe3aa8629026 100644
--- a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/xcore.ll
+++ b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/xcore.ll
@@ -1,6 +1,6 @@
 ; REQUIRES: webassembly-registered-target
 ; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=xcore < %s | FileCheck %s
 
-; CHECK: declare void @fiprintf(...)
-; CHECK: declare void @iprintf(...)
-; CHECK: declare void @siprintf(...)
+; CHECK: declare i32 @fiprintf(ptr, ptr, ...)
+; CHECK: declare i32 @iprintf(ptr, ...)
+; CHECK: declare i32 @siprintf(ptr, ptr, ...)
diff --git a/llvm/utils/TableGen/Basic/RuntimeLibcalls.cpp b/llvm/utils/TableGen/Basic/RuntimeLibcalls.cpp
index dfccfca5dbb4d..4262135693238 100644
--- a/llvm/utils/TableGen/Basic/RuntimeLibcalls.cpp
+++ b/llvm/utils/TableGen/Basic/RuntimeLibcalls.cpp
@@ -70,6 +70,8 @@ RuntimeLibcalls::RuntimeLibcalls(const RecordKeeper &Records) {
     const RuntimeLibcallImpl &LibCallImpl = RuntimeLibcallImplDefList.back();
     Def2RuntimeLibcallImpl[LibCallImplDef] = &LibCallImpl;
   }
+
+  FuncArgTypeList = Records.getAllDerivedDefinitions("FuncArgType");
 }
 
 void LibcallPredicateExpander::expand(SetTheory &ST, const Record *Def,
diff --git a/llvm/utils/TableGen/Basic/RuntimeLibcalls.h b/llvm/utils/TableGen/Basic/RuntimeLibcalls.h
index b296c86ffd111..5225a34eb7120 100644
--- a/llvm/utils/TableGen/Basic/RuntimeLibcalls.h
+++ b/llvm/utils/TableGen/Basic/RuntimeLibcalls.h
@@ -171,6 +171,8 @@ class RuntimeLibcalls {
   std::vector<RuntimeLibcall> RuntimeLibcallDefList;
   std::vector<RuntimeLibcallImpl> RuntimeLibcallImplDefList;
 
+  std::vector<const Record *> FuncArgTypeList;
+
 public:
   RuntimeLibcalls(const RecordKeeper &Records);
 
@@ -189,6 +191,10 @@ class RuntimeLibcalls {
   const RuntimeLibcallImpl *getRuntimeLibcallImpl(const Record *Def) const {
     return Def2RuntimeLibcallImpl.lookup(Def);
   }
+
+  ArrayRef<const Record *> getFuncArgTypeList() const {
+    return FuncArgTypeList;
+  }
 };
 
 } // namespace llvm
diff --git a/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp b/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
index 55d29a9238bd2..34158d934fc44 100644
--- a/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
+++ b/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
@@ -10,6 +10,7 @@
 
 #include "RuntimeLibcalls.h"
 
+#include "SequenceToOffsetTable.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/StringExtras.h"
@@ -87,6 +88,7 @@ class RuntimeLibcallEmitter {
                               StringToOffsetTable &OffsetTable) const;
 
   void emitGetInitRuntimeLibcallNames(raw_ostream &OS) const;
+  void emitGetInitRuntimeLibcallSignatures(raw_ostream &OS) const;
 
   // Emit the sorted per-predicate `setAvailable` tables/loops. The
   // always-available bucket emits at \p BaseIndent; each predicated bucket is
@@ -190,7 +192,17 @@ void RuntimeLibcallEmitter::emitGetRuntimeLibcallEnum(raw_ostream &OS) const {
   OS << "};\n"
      << "constexpr size_t NumLibcallImpls = "
      << Libcalls.getRuntimeLibcallImplDefList().size() + 1
-     << ";\n"
+     << ";\n\n"
+        "enum FuncArgTypeID : char {\n"
+        "  NoFuncArgType = 0,\n";
+
+  for (const auto *R : Libcalls.getFuncArgTypeList()) {
+    if (R->getName() == "NoneType")
+      continue;
+    OS << "  " << R->getName() << ",\n";
+  }
+
+  OS << "};\n"
         "} // End namespace RTLIB\n"
         "} // End namespace llvm\n";
 }
@@ -421,6 +433,49 @@ const uint8_t RTLIB::RuntimeLibcallsInfo::RuntimeLibcallNameSizeTable[] = {
   emitNameMatchHashTable(OS, Table);
 }
 
+void RuntimeLibcallEmitter::emitGetInitRuntimeLibcallSignatures(
+    raw_ostream &OS) const {
+      
+  using Signature = std::vector<StringRef>;
+  SequenceToOffsetTable<Signature> SignatureTable("NoFuncArgType");
+
+  auto GetSignature = [](const Record *R) -> Signature {
+    const auto *Tys = R->getValueAsListInit("ArgumentTypes");
+    Signature Sig;
+    Sig.reserve(Tys->size() + 1);
+    const Record *RetType = R->getValueAsOptionalDef("ReturnType");
+    if (RetType && (RetType->getName() != "NoneType"))
+      Sig.push_back(RetType->getName());
+    for (unsigned I = 0, E = Tys->size(); I < E; ++I) {
+      Sig.push_back(Tys->getElementAsRecord(I)->getName());
+    }
+    return Sig;
+  };
+
+  for (const RuntimeLibcall &LC : Libcalls.getRuntimeLibcallDefList())
+    SignatureTable.add(GetSignature(LC.getDef()));
+  SignatureTable.layout();
+
+  IfDefEmitter IfDef(OS, "GET_INIT_RUNTIME_LIBCALL_SIGNATURES");
+
+  OS << R"(
+const FuncArgTypeID RTLIB::RuntimeLibcallsInfo::SignatureTable[] = {
+)";
+  SignatureTable.emit(OS, [](raw_ostream &OS, StringRef E) { OS << E; });
+  OS << "};\n";
+
+  OS << R"(
+const uint16_t RTLIB::RuntimeLibcallsInfo::SignatureOffset[] = {
+)";
+  for (const RuntimeLibcall &LC : Libcalls.getRuntimeLibcallDefList()) {
+    const Record *LibcallDef = LC.getDef();
+    OS << formatv("  {}, // {}\n",
+                  SignatureTable.get(GetSignature(LibcallDef)),
+                  LibcallDef->getName());
+  }
+  OS << "};\n";
+}
+
 void RuntimeLibcallEmitter::emitPredicateGroups(
     raw_ostream &OS, const Record *R,
     DenseMap<PredicateWithCC, LibcallsWithCC> &Pred2Funcs,
@@ -1068,6 +1123,7 @@ void RuntimeLibcallEmitter::run(raw_ostream &OS) {
   emitGetRuntimeLibcallEnum(OS);
 
   emitGetInitRuntimeLibcallNames(OS);
+  emitGetInitRuntimeLibcallSignatures(OS);
 
   emitRuntimeLibcallsInfoMemberDecls(OS);
 

>From 4756327f1d46d52e62bed4685ae6a41a4acaf939 Mon Sep 17 00:00:00 2001
From: Jian Su <jian.su at ibm.com>
Date: Thu, 24 Sep 2026 18:46:52 +0000
Subject: [PATCH 2/2] Fix format.

---
 llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp b/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
index 34158d934fc44..3f00b86546404 100644
--- a/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
+++ b/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
@@ -435,7 +435,7 @@ const uint8_t RTLIB::RuntimeLibcallsInfo::RuntimeLibcallNameSizeTable[] = {
 
 void RuntimeLibcallEmitter::emitGetInitRuntimeLibcallSignatures(
     raw_ostream &OS) const {
-      
+
   using Signature = std::vector<StringRef>;
   SequenceToOffsetTable<Signature> SignatureTable("NoFuncArgType");
 
@@ -469,8 +469,7 @@ const uint16_t RTLIB::RuntimeLibcallsInfo::SignatureOffset[] = {
 )";
   for (const RuntimeLibcall &LC : Libcalls.getRuntimeLibcallDefList()) {
     const Record *LibcallDef = LC.getDef();
-    OS << formatv("  {}, // {}\n",
-                  SignatureTable.get(GetSignature(LibcallDef)),
+    OS << formatv("  {}, // {}\n", SignatureTable.get(GetSignature(LibcallDef)),
                   LibcallDef->getName());
   }
   OS << "};\n";



More information about the llvm-commits mailing list