Skip to content

Commit 767ec88

Browse files
committed
[CodeGen] Avoid deprecated Address ctor in EmitLoadOfPointer()
This requires some adjustment in caller code, because there was a confusion regarding the meaning of the PtrTy argument: This argument is the type of the pointer being loaded, not the addresses being loaded from.
1 parent a9656bd commit 767ec88

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,10 +2547,10 @@ Address CodeGenFunction::EmitLoadOfPointer(Address Ptr,
25472547
LValueBaseInfo *BaseInfo,
25482548
TBAAAccessInfo *TBAAInfo) {
25492549
llvm::Value *Addr = Builder.CreateLoad(Ptr);
2550-
return Address::deprecated(
2551-
Addr,
2552-
CGM.getNaturalTypeAlignment(PtrTy->getPointeeType(), BaseInfo, TBAAInfo,
2553-
/*forPointeeType=*/true));
2550+
return Address(Addr, ConvertTypeForMem(PtrTy->getPointeeType()),
2551+
CGM.getNaturalTypeAlignment(PtrTy->getPointeeType(), BaseInfo,
2552+
TBAAInfo,
2553+
/*forPointeeType=*/true));
25542554
}
25552555

25562556
LValue CodeGenFunction::EmitLoadOfPointerLValue(Address PtrAddr,

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4650,8 +4650,7 @@ CGOpenMPRuntime::getDepobjElements(CodeGenFunction &CGF, LValue DepobjLVal,
46504650
RecordDecl *KmpDependInfoRD =
46514651
cast<RecordDecl>(KmpDependInfoTy->getAsTagDecl());
46524652
LValue Base = CGF.EmitLoadOfPointerLValue(
4653-
DepobjLVal.getAddress(CGF),
4654-
C.getPointerType(C.VoidPtrTy).castAs<PointerType>());
4653+
DepobjLVal.getAddress(CGF), C.VoidPtrTy.castAs<PointerType>());
46554654
QualType KmpDependInfoPtrTy = C.getPointerType(KmpDependInfoTy);
46564655
Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
46574656
Base.getAddress(CGF), CGF.ConvertTypeForMem(KmpDependInfoPtrTy),
@@ -4748,8 +4747,7 @@ emitDepobjElementsSizes(CodeGenFunction &CGF, QualType &KmpDependInfoTy,
47484747
for (const Expr *E : Data.DepExprs) {
47494748
LValue DepobjLVal = CGF.EmitLValue(E->IgnoreParenImpCasts());
47504749
LValue Base = CGF.EmitLoadOfPointerLValue(
4751-
DepobjLVal.getAddress(CGF),
4752-
C.getPointerType(C.VoidPtrTy).castAs<PointerType>());
4750+
DepobjLVal.getAddress(CGF), C.VoidPtrTy.castAs<PointerType>());
47534751
Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
47544752
Base.getAddress(CGF), KmpDependInfoPtrT,
47554753
CGF.ConvertTypeForMem(KmpDependInfoTy));
@@ -4806,8 +4804,7 @@ static void emitDepobjElements(CodeGenFunction &CGF, QualType &KmpDependInfoTy,
48064804
const Expr *E = Data.DepExprs[I];
48074805
LValue DepobjLVal = CGF.EmitLValue(E->IgnoreParenImpCasts());
48084806
LValue Base = CGF.EmitLoadOfPointerLValue(
4809-
DepobjLVal.getAddress(CGF),
4810-
C.getPointerType(C.VoidPtrTy).castAs<PointerType>());
4807+
DepobjLVal.getAddress(CGF), C.VoidPtrTy.castAs<PointerType>());
48114808
Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
48124809
Base.getAddress(CGF), KmpDependInfoPtrT,
48134810
CGF.ConvertTypeForMem(KmpDependInfoTy));
@@ -5055,8 +5052,7 @@ void CGOpenMPRuntime::emitDestroyClause(CodeGenFunction &CGF, LValue DepobjLVal,
50555052
QualType FlagsTy;
50565053
getDependTypes(C, KmpDependInfoTy, FlagsTy);
50575054
LValue Base = CGF.EmitLoadOfPointerLValue(
5058-
DepobjLVal.getAddress(CGF),
5059-
C.getPointerType(C.VoidPtrTy).castAs<PointerType>());
5055+
DepobjLVal.getAddress(CGF), C.VoidPtrTy.castAs<PointerType>());
50605056
QualType KmpDependInfoPtrTy = C.getPointerType(KmpDependInfoTy);
50615057
Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
50625058
Base.getAddress(CGF), CGF.ConvertTypeForMem(KmpDependInfoPtrTy),
@@ -6038,8 +6034,7 @@ static llvm::Value *emitReduceFiniFunction(CodeGenModule &CGM,
60386034
CodeGenFunction CGF(CGM);
60396035
CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args, Loc, Loc);
60406036
Address PrivateAddr = CGF.EmitLoadOfPointer(
6041-
CGF.GetAddrOfLocalVar(&Param),
6042-
C.getPointerType(C.VoidPtrTy).castAs<PointerType>());
6037+
CGF.GetAddrOfLocalVar(&Param), C.VoidPtrTy.castAs<PointerType>());
60436038
llvm::Value *Size = nullptr;
60446039
// If the size of the reduction item is non-constant, load it from global
60456040
// threadprivate variable.

clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3545,8 +3545,7 @@ llvm::Function *CGOpenMPRuntimeGPU::createParallelDataSharingWrapper(
35453545
isOpenMPLoopBoundSharingDirective(D.getDirectiveKind())) {
35463546
SharedArgListAddress = CGF.EmitLoadOfPointer(
35473547
GlobalArgs, CGF.getContext()
3548-
.getPointerType(CGF.getContext().getPointerType(
3549-
CGF.getContext().VoidPtrTy))
3548+
.getPointerType(CGF.getContext().VoidPtrTy)
35503549
.castAs<PointerType>());
35513550
}
35523551
unsigned Idx = 0;

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,6 +2527,9 @@ class CodeGenFunction : public CodeGenTypeCache {
25272527
return EmitLoadOfReferenceLValue(RefLVal);
25282528
}
25292529

2530+
/// Load a pointer with type \p PtrTy stored at address \p Ptr.
2531+
/// Note that \p PtrTy is the type of the loaded pointer, not the addresses
2532+
/// it is loaded from.
25302533
Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy,
25312534
LValueBaseInfo *BaseInfo = nullptr,
25322535
TBAAAccessInfo *TBAAInfo = nullptr);

0 commit comments

Comments
 (0)