[clang] 42afaf7 - [clang][CodeGen] Use memory type representation in `va_arg`
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 4 03:11:09 PST 2022
Author: Jan Svoboda
Date: 2022-02-04T12:10:57+01:00
New Revision: 42afaf7f472ce8ae14f1aa3858f1a8f3abc4ac67
URL: https://github.com/llvm/llvm-project/commit/42afaf7f472ce8ae14f1aa3858f1a8f3abc4ac67
DIFF: https://github.com/llvm/llvm-project/commit/42afaf7f472ce8ae14f1aa3858f1a8f3abc4ac67.diff
LOG: [clang][CodeGen] Use memory type representation in `va_arg`
Some types (e.g. `_Bool`) have different scalar and memory representations. CodeGen for `va_arg` didn't take this into account, leading to an assertion failures with different types.
This patch makes sure we use memory representation for `va_arg`.
Reviewed By: ahatanak
Differential Revision: https://reviews.llvm.org/D118904
Added:
Modified:
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/arm64-arguments.c
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 9af3004ebcc5b..18967237280f8 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -709,7 +709,8 @@ Address EmitVAArgInstr(CodeGenFunction &CGF, Address VAListAddr, QualType Ty,
"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;
}
diff --git a/clang/test/CodeGen/arm64-arguments.c b/clang/test/CodeGen/arm64-arguments.c
index 9b1046269375d..16997cae573de 100644
--- a/clang/test/CodeGen/arm64-arguments.c
+++ b/clang/test/CodeGen/arm64-arguments.c
@@ -196,6 +196,16 @@ double t2(int i, ...) {
__builtin_va_end(ap);
return ll;
}
+_Bool t3(int i, ...) {
+ // CHECK: t3
+ __builtin_va_list ap;
+ __builtin_va_start(ap, i);
+ // CHECK: %0 = va_arg {{.*}}* %ap, i8
+ // CHECK-NEXT: store i8 %0, i8* %varet, align 1
+ _Bool b = __builtin_va_arg(ap, _Bool);
+ __builtin_va_end(ap);
+ return b;
+}
#include <arm_neon.h>
More information about the cfe-commits
mailing list