This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rGebe530ef7a49: [CodeGen][AArch64] Fix AArch64ABIInfo::EmitAAPCSVAArg crash with empty record… (authored by yronglin).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138511/new/ https://reviews.llvm.org/D138511 Files: clang/lib/CodeGen/TargetInfo.cpp clang/test/CodeGen/aarch64-varargs.c Index: clang/test/CodeGen/aarch64-varargs.c =================================================================== --- clang/test/CodeGen/aarch64-varargs.c +++ clang/test/CodeGen/aarch64-varargs.c @@ -894,4 +894,10 @@ // CHECK: call void @llvm.va_start(i8* [[VOIDP_THE_LIST]]) } - +typedef struct {} empty; +empty empty_record_test(void) { +// CHECK-LABEL: define{{.*}} void @empty_record_test() + return va_arg(the_list, empty); +// CHECK: [[GR_OFFS:%[a-z_0-9]+]] = load i8*, i8** getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 0) +// CHECK: [[ADDR:%[a-z._0-9]+]] = bitcast i8* [[GR_OFFS]] to %struct.empty* +} Index: clang/lib/CodeGen/TargetInfo.cpp =================================================================== --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -5998,6 +5998,16 @@ CodeGenFunction &CGF) const { ABIArgInfo AI = classifyArgumentType(Ty, /*IsVariadic=*/true, CGF.CurFnInfo->getCallingConvention()); + // Empty records are ignored for parameter passing purposes. + if (AI.isIgnore()) { + uint64_t PointerSize = getTarget().getPointerWidth(LangAS::Default) / 8; + CharUnits SlotSize = CharUnits::fromQuantity(PointerSize); + VAListAddr = CGF.Builder.CreateElementBitCast(VAListAddr, CGF.Int8PtrTy); + auto *Load = CGF.Builder.CreateLoad(VAListAddr); + Address Addr = Address(Load, CGF.Int8Ty, SlotSize); + return CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty)); + } + bool IsIndirect = AI.isIndirect(); llvm::Type *BaseTy = CGF.ConvertType(Ty);
Index: clang/test/CodeGen/aarch64-varargs.c =================================================================== --- clang/test/CodeGen/aarch64-varargs.c +++ clang/test/CodeGen/aarch64-varargs.c @@ -894,4 +894,10 @@ // CHECK: call void @llvm.va_start(i8* [[VOIDP_THE_LIST]]) } - +typedef struct {} empty; +empty empty_record_test(void) { +// CHECK-LABEL: define{{.*}} void @empty_record_test() + return va_arg(the_list, empty); +// CHECK: [[GR_OFFS:%[a-z_0-9]+]] = load i8*, i8** getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 0) +// CHECK: [[ADDR:%[a-z._0-9]+]] = bitcast i8* [[GR_OFFS]] to %struct.empty* +} Index: clang/lib/CodeGen/TargetInfo.cpp =================================================================== --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -5998,6 +5998,16 @@ CodeGenFunction &CGF) const { ABIArgInfo AI = classifyArgumentType(Ty, /*IsVariadic=*/true, CGF.CurFnInfo->getCallingConvention()); + // Empty records are ignored for parameter passing purposes. + if (AI.isIgnore()) { + uint64_t PointerSize = getTarget().getPointerWidth(LangAS::Default) / 8; + CharUnits SlotSize = CharUnits::fromQuantity(PointerSize); + VAListAddr = CGF.Builder.CreateElementBitCast(VAListAddr, CGF.Int8PtrTy); + auto *Load = CGF.Builder.CreateLoad(VAListAddr); + Address Addr = Address(Load, CGF.Int8Ty, SlotSize); + return CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty)); + } + bool IsIndirect = AI.isIndirect(); llvm::Type *BaseTy = CGF.ConvertType(Ty);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits