[PATCH] D118904: [clang][CodeGen] Use memory type representation in `va_arg`

Jan Svoboda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 3 07:52:44 PST 2022


jansvoboda11 updated this revision to Diff 405644.
jansvoboda11 added a comment.

Add proper check


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118904/new/

https://reviews.llvm.org/D118904

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/arm64-arguments.c


Index: clang/test/CodeGen/arm64-arguments.c
===================================================================
--- clang/test/CodeGen/arm64-arguments.c
+++ clang/test/CodeGen/arm64-arguments.c
@@ -196,6 +196,15 @@
     __builtin_va_end(ap);
     return ll;
 }
+_Bool t3(int i, ...) {
+  // CHECK: t3
+  __builtin_va_list ap;
+  __builtin_va_start(ap, i);
+  // CHECK: va_arg {{.*}}* %ap, i8
+  _Bool b = __builtin_va_arg(ap, _Bool);
+  __builtin_va_end(ap);
+  return b;
+}
 
 #include <arm_neon.h>
 
Index: clang/lib/CodeGen/TargetInfo.cpp
===================================================================
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -709,7 +709,8 @@
            "Unexpected CoerceToType seen in arginfo in generic VAArg emitter!");
 
     Address Temp = CGF.CreateMemTemp(Ty, "varet");
-    Val = CGF.Builder.CreateVAArg(VAListAddr.getPointer(), CGF.ConvertType(Ty));
+    Val = CGF.Builder.CreateVAArg(VAListAddr.getPointer(),
+                                  CGF.ConvertTypeForMem(Ty));
     CGF.Builder.CreateStore(Val, Temp);
     return Temp;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118904.405644.patch
Type: text/x-patch
Size: 1109 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220203/53a92536/attachment-0001.bin>


More information about the cfe-commits mailing list