[clang] [llvm] [CodeGen][LLVM] Make the `va_list` related intrinsics generic. (PR #85460)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 21 12:22:49 PDT 2024


================
@@ -700,10 +700,13 @@ class MSBuiltin<string name> {
 //===--------------- Variable Argument Handling Intrinsics ----------------===//
 //
 
-def int_vastart : DefaultAttrsIntrinsic<[], [llvm_ptr_ty], [], "llvm.va_start">;
-def int_vacopy  : DefaultAttrsIntrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], [],
-                            "llvm.va_copy">;
-def int_vaend   : DefaultAttrsIntrinsic<[], [llvm_ptr_ty], [], "llvm.va_end">;
+def int_vastart : DefaultAttrsIntrinsic<[],
+                                        [llvm_anyptr_ty], [], "llvm.va_start">;
+def int_vacopy  : DefaultAttrsIntrinsic<[],
+                                        [llvm_anyptr_ty, llvm_anyptr_ty], [],
+                                        "llvm.va_copy">;
----------------
efriedma-quic wrote:

clang semantic analysis currently forces both the source and destination of va_copy to the type __builtin_va_list_ref, whatever that is.  So clang would never emit va_copy with different pointer types.  (Some other frontend could theoretically emit such operations, but it's hard for me to imagine it being useful.)

In theory, you could try to optimize the address-spaces involved in a va_copy operation... but there's not really much point to trying to optimize va_copy before you lower it.

https://github.com/llvm/llvm-project/pull/85460


More information about the cfe-commits mailing list