[clang] [clang] fix emitvaarg when struct is null (PR #72624)

via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 17 00:43:51 PST 2023


https://github.com/Jolyon0202 created https://github.com/llvm/llvm-project/pull/72624

Fix bug when emit null struct with attribute aligned(16) and ICE of debugbuild.

>From f0245b42534f423edaba45c2b3b2dffeb86e3074 Mon Sep 17 00:00:00 2001
From: Jian Yang <yangjian86 at huawei.com>
Date: Wed, 15 Nov 2023 15:44:35 +0800
Subject: [PATCH] [clang] fix emitvaarg when struct is null

Fix bug when emit null struct with attribute aligned(16) and ICE of debugbuild.
---
 clang/lib/CodeGen/Targets/AArch64.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/Targets/AArch64.cpp b/clang/lib/CodeGen/Targets/AArch64.cpp
index be5145daa00b7f5..49dff102b7d554a 100644
--- a/clang/lib/CodeGen/Targets/AArch64.cpp
+++ b/clang/lib/CodeGen/Targets/AArch64.cpp
@@ -526,7 +526,7 @@ Address AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, QualType Ty,
   llvm::Type *BaseTy = CGF.ConvertType(Ty);
   if (IsIndirect)
     BaseTy = llvm::PointerType::getUnqual(BaseTy);
-  else if (AI.getCoerceToType())
+  else if (AI.canHaveCoerceToType() && AI.getCoerceToType())
     BaseTy = AI.getCoerceToType();
 
   unsigned NumRegs = 1;
@@ -594,7 +594,7 @@ Address AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, QualType Ty,
   // Integer arguments may need to correct register alignment (for example a
   // "struct { __int128 a; };" gets passed in x_2N, x_{2N+1}). In this case we
   // align __gr_offs to calculate the potential address.
-  if (!IsFPR && !IsIndirect && TyAlign.getQuantity() > 8) {
+  if (!IsFPR && !IsIndirect && TyAlign.getQuantity() > 8 && !TySize.isZero()) {
     int Align = TyAlign.getQuantity();
 
     reg_offs = CGF.Builder.CreateAdd(



More information about the cfe-commits mailing list