From 27f6cee12d2ab52e44e78d26733ab92ced730f13 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 23 Mar 2022 10:22:14 +0100 Subject: [PATCH] Revert "[CodeGen] Avoid deprecated Address ctor in EmitLoadOfPointer()" This reverts commit 767ec883e37510a247ea5695921876ef67cf5b3f. This results in a some incorrect alignments which are not covered by existing tests. --- clang/lib/CodeGen/CGExpr.cpp | 8 ++++---- clang/lib/CodeGen/CGOpenMPRuntime.cpp | 15 ++++++++++----- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 3 ++- clang/lib/CodeGen/CodeGenFunction.h | 3 --- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 2ee62f97399acf..b0eeddd98fce66 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -2547,10 +2547,10 @@ Address CodeGenFunction::EmitLoadOfPointer(Address Ptr, LValueBaseInfo *BaseInfo, TBAAAccessInfo *TBAAInfo) { llvm::Value *Addr = Builder.CreateLoad(Ptr); - return Address(Addr, ConvertTypeForMem(PtrTy->getPointeeType()), - CGM.getNaturalTypeAlignment(PtrTy->getPointeeType(), BaseInfo, - TBAAInfo, - /*forPointeeType=*/true)); + return Address::deprecated( + Addr, + CGM.getNaturalTypeAlignment(PtrTy->getPointeeType(), BaseInfo, TBAAInfo, + /*forPointeeType=*/true)); } LValue CodeGenFunction::EmitLoadOfPointerLValue(Address PtrAddr, diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 24cd78a64cfd4d..b7ee9ce10e02bb 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -4652,7 +4652,8 @@ CGOpenMPRuntime::getDepobjElements(CodeGenFunction &CGF, LValue DepobjLVal, RecordDecl *KmpDependInfoRD = cast(KmpDependInfoTy->getAsTagDecl()); LValue Base = CGF.EmitLoadOfPointerLValue( - DepobjLVal.getAddress(CGF), C.VoidPtrTy.castAs()); + DepobjLVal.getAddress(CGF), + C.getPointerType(C.VoidPtrTy).castAs()); QualType KmpDependInfoPtrTy = C.getPointerType(KmpDependInfoTy); Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast( Base.getAddress(CGF), CGF.ConvertTypeForMem(KmpDependInfoPtrTy), @@ -4749,7 +4750,8 @@ emitDepobjElementsSizes(CodeGenFunction &CGF, QualType &KmpDependInfoTy, for (const Expr *E : Data.DepExprs) { LValue DepobjLVal = CGF.EmitLValue(E->IgnoreParenImpCasts()); LValue Base = CGF.EmitLoadOfPointerLValue( - DepobjLVal.getAddress(CGF), C.VoidPtrTy.castAs()); + DepobjLVal.getAddress(CGF), + C.getPointerType(C.VoidPtrTy).castAs()); Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast( Base.getAddress(CGF), KmpDependInfoPtrT, CGF.ConvertTypeForMem(KmpDependInfoTy)); @@ -4806,7 +4808,8 @@ static void emitDepobjElements(CodeGenFunction &CGF, QualType &KmpDependInfoTy, const Expr *E = Data.DepExprs[I]; LValue DepobjLVal = CGF.EmitLValue(E->IgnoreParenImpCasts()); LValue Base = CGF.EmitLoadOfPointerLValue( - DepobjLVal.getAddress(CGF), C.VoidPtrTy.castAs()); + DepobjLVal.getAddress(CGF), + C.getPointerType(C.VoidPtrTy).castAs()); Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast( Base.getAddress(CGF), KmpDependInfoPtrT, CGF.ConvertTypeForMem(KmpDependInfoTy)); @@ -5055,7 +5058,8 @@ void CGOpenMPRuntime::emitDestroyClause(CodeGenFunction &CGF, LValue DepobjLVal, QualType FlagsTy; getDependTypes(C, KmpDependInfoTy, FlagsTy); LValue Base = CGF.EmitLoadOfPointerLValue( - DepobjLVal.getAddress(CGF), C.VoidPtrTy.castAs()); + DepobjLVal.getAddress(CGF), + C.getPointerType(C.VoidPtrTy).castAs()); QualType KmpDependInfoPtrTy = C.getPointerType(KmpDependInfoTy); Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast( Base.getAddress(CGF), CGF.ConvertTypeForMem(KmpDependInfoPtrTy), @@ -6037,7 +6041,8 @@ static llvm::Value *emitReduceFiniFunction(CodeGenModule &CGM, CodeGenFunction CGF(CGM); CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args, Loc, Loc); Address PrivateAddr = CGF.EmitLoadOfPointer( - CGF.GetAddrOfLocalVar(&Param), C.VoidPtrTy.castAs()); + CGF.GetAddrOfLocalVar(&Param), + C.getPointerType(C.VoidPtrTy).castAs()); llvm::Value *Size = nullptr; // If the size of the reduction item is non-constant, load it from global // threadprivate variable. diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp index f4228cfb3086e1..1814102f749af3 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp @@ -3558,7 +3558,8 @@ llvm::Function *CGOpenMPRuntimeGPU::createParallelDataSharingWrapper( isOpenMPLoopBoundSharingDirective(D.getDirectiveKind())) { SharedArgListAddress = CGF.EmitLoadOfPointer( GlobalArgs, CGF.getContext() - .getPointerType(CGF.getContext().VoidPtrTy) + .getPointerType(CGF.getContext().getPointerType( + CGF.getContext().VoidPtrTy)) .castAs()); } unsigned Idx = 0; diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index bda447339d42d5..24000b99608f7b 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -2527,9 +2527,6 @@ class CodeGenFunction : public CodeGenTypeCache { return EmitLoadOfReferenceLValue(RefLVal); } - /// Load a pointer with type \p PtrTy stored at address \p Ptr. - /// Note that \p PtrTy is the type of the loaded pointer, not the addresses - /// it is loaded from. Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy, LValueBaseInfo *BaseInfo = nullptr, TBAAAccessInfo *TBAAInfo = nullptr);