[clang] 51ba13b - [CGStmtOpenMP] Remove uses of deprecated Address constructor

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 22 03:00:15 PDT 2022


Author: Nikita Popov
Date: 2022-03-22T11:00:08+01:00
New Revision: 51ba13b1aea3d6e04310b80b6bcfc641049b9890

URL: https://github.com/llvm/llvm-project/commit/51ba13b1aea3d6e04310b80b6bcfc641049b9890
DIFF: https://github.com/llvm/llvm-project/commit/51ba13b1aea3d6e04310b80b6bcfc641049b9890.diff

LOG: [CGStmtOpenMP] Remove uses of deprecated Address constructor

Added: 
    

Modified: 
    clang/lib/CodeGen/CGStmtOpenMP.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 7ce3cd99c1b76..a5ee7abc655bd 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -153,13 +153,13 @@ class OMPLoopScope : public CodeGenFunction::RunCleanupsScope {
           const auto *OrigVD =
               cast<VarDecl>(cast<DeclRefExpr>(IRef)->getDecl());
           if (EmittedAsPrivate.insert(OrigVD->getCanonicalDecl()).second) {
+            QualType OrigVDTy = OrigVD->getType().getNonReferenceType();
             (void)PreCondVars.setVarAddr(
                 CGF, OrigVD,
-                Address::deprecated(
-                    llvm::UndefValue::get(
-                        CGF.ConvertTypeForMem(CGF.getContext().getPointerType(
-                            OrigVD->getType().getNonReferenceType()))),
-                    CGF.getContext().getDeclAlign(OrigVD)));
+                Address(llvm::UndefValue::get(CGF.ConvertTypeForMem(
+                            CGF.getContext().getPointerType(OrigVDTy))),
+                        CGF.ConvertTypeForMem(OrigVDTy),
+                        CGF.getContext().getDeclAlign(OrigVD)));
           }
         }
       }
@@ -991,10 +991,11 @@ bool CodeGenFunction::EmitOMPCopyinClause(const OMPExecutableDirective &D) {
           MasterAddr = EmitLValue(&DRE).getAddress(*this);
           LocalDeclMap.erase(VD);
         } else {
-          MasterAddr = Address::deprecated(
-              VD->isStaticLocal() ? CGM.getStaticLocalDeclAddress(VD)
-                                  : CGM.GetAddrOfGlobal(VD),
-              getContext().getDeclAlign(VD));
+          MasterAddr =
+              Address(VD->isStaticLocal() ? CGM.getStaticLocalDeclAddress(VD)
+                                          : CGM.GetAddrOfGlobal(VD),
+                      CGM.getTypes().ConvertTypeForMem(VD->getType()),
+                      getContext().getDeclAlign(VD));
         }
         // Get the address of the threadprivate variable.
         Address PrivateAddr = EmitLValue(*IRef).getAddress(*this);
@@ -1162,8 +1163,9 @@ void CodeGenFunction::EmitOMPLastprivateClauseFinal(
         // Get the address of the private variable.
         Address PrivateAddr = GetAddrOfLocalVar(PrivateVD);
         if (const auto *RefTy = PrivateVD->getType()->getAs<ReferenceType>())
-          PrivateAddr = Address::deprecated(
+          PrivateAddr = Address(
               Builder.CreateLoad(PrivateAddr),
+              CGM.getTypes().ConvertTypeForMem(RefTy->getPointeeType()),
               CGM.getNaturalTypeAlignment(RefTy->getPointeeType()));
         // Store the last value to the private copy in the last iteration.
         if (C->getKind() == OMPC_LASTPRIVATE_conditional)
@@ -1634,7 +1636,7 @@ Address CodeGenFunction::OMPBuilderCBHelpers::getAddressOfLocalVariable(
       Addr,
       CGF.ConvertTypeForMem(CGM.getContext().getPointerType(CVD->getType())),
       getNameWithSeparators({CVD->getName(), ".addr"}, ".", "."));
-  return Address::deprecated(Addr, Align);
+  return Address(Addr, CGF.ConvertTypeForMem(CVD->getType()), Align);
 }
 
 Address CodeGenFunction::OMPBuilderCBHelpers::getAddrOfThreadPrivate(
@@ -1657,7 +1659,7 @@ Address CodeGenFunction::OMPBuilderCBHelpers::getAddrOfThreadPrivate(
   llvm::CallInst *ThreadPrivateCacheCall =
       OMPBuilder.createCachedThreadPrivate(CGF.Builder, Data, Size, CacheName);
 
-  return Address::deprecated(ThreadPrivateCacheCall, VDAddr.getAlignment());
+  return Address(ThreadPrivateCacheCall, CGM.Int8Ty, VDAddr.getAlignment());
 }
 
 std::string CodeGenFunction::OMPBuilderCBHelpers::getNameWithSeparators(
@@ -4634,9 +4636,10 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
         Scope.addPrivate(Pair.first, CGF.EmitLValue(&DRE).getAddress(CGF));
       }
       for (const auto &Pair : PrivatePtrs) {
-        Address Replacement =
-            Address::deprecated(CGF.Builder.CreateLoad(Pair.second),
-                                CGF.getContext().getDeclAlign(Pair.first));
+        Address Replacement = Address(
+            CGF.Builder.CreateLoad(Pair.second),
+            CGF.ConvertTypeForMem(Pair.first->getType().getNonReferenceType()),
+            CGF.getContext().getDeclAlign(Pair.first));
         Scope.addPrivate(Pair.first, Replacement);
         if (auto *DI = CGF.getDebugInfo())
           if (CGF.CGM.getCodeGenOpts().hasReducedDebugInfo())
@@ -4647,18 +4650,22 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
       // Adjust mapping for internal locals by mapping actual memory instead of
       // a pointer to this memory.
       for (auto &Pair : UntiedLocalVars) {
+        QualType VDType = Pair.first->getType().getNonReferenceType();
         if (isAllocatableDecl(Pair.first)) {
           llvm::Value *Ptr = CGF.Builder.CreateLoad(Pair.second.first);
-          Address Replacement = Address::deprecated(Ptr, CGF.getPointerAlign());
+          Address Replacement(
+              Ptr,
+              CGF.ConvertTypeForMem(CGF.getContext().getPointerType(VDType)),
+              CGF.getPointerAlign());
           Pair.second.first = Replacement;
           Ptr = CGF.Builder.CreateLoad(Replacement);
-          Replacement = Address::deprecated(
-              Ptr, CGF.getContext().getDeclAlign(Pair.first));
+          Replacement = Address(Ptr, CGF.ConvertTypeForMem(VDType),
+                                CGF.getContext().getDeclAlign(Pair.first));
           Pair.second.second = Replacement;
         } else {
           llvm::Value *Ptr = CGF.Builder.CreateLoad(Pair.second.first);
-          Address Replacement = Address::deprecated(
-              Ptr, CGF.getContext().getDeclAlign(Pair.first));
+          Address Replacement(Ptr, CGF.ConvertTypeForMem(VDType),
+                              CGF.getContext().getDeclAlign(Pair.first));
           Pair.second.first = Replacement;
         }
       }
@@ -4666,9 +4673,10 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
     if (Data.Reductions) {
       OMPPrivateScope FirstprivateScope(CGF);
       for (const auto &Pair : FirstprivatePtrs) {
-        Address Replacement =
-            Address::deprecated(CGF.Builder.CreateLoad(Pair.second),
-                                CGF.getContext().getDeclAlign(Pair.first));
+        Address Replacement(
+            CGF.Builder.CreateLoad(Pair.second),
+            CGF.ConvertTypeForMem(Pair.first->getType().getNonReferenceType()),
+            CGF.getContext().getDeclAlign(Pair.first));
         FirstprivateScope.addPrivate(Pair.first, Replacement);
       }
       (void)FirstprivateScope.Privatize();
@@ -4687,13 +4695,14 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
                                                            RedCG, Cnt);
         Address Replacement = CGF.CGM.getOpenMPRuntime().getTaskReductionItem(
             CGF, S.getBeginLoc(), ReductionsPtr, RedCG.getSharedLValue(Cnt));
-        Replacement = Address::deprecated(
-            CGF.EmitScalarConversion(Replacement.getPointer(),
-                                     CGF.getContext().VoidPtrTy,
-                                     CGF.getContext().getPointerType(
-                                         Data.ReductionCopies[Cnt]->getType()),
-                                     Data.ReductionCopies[Cnt]->getExprLoc()),
-            Replacement.getAlignment());
+        Replacement =
+            Address(CGF.EmitScalarConversion(
+                        Replacement.getPointer(), CGF.getContext().VoidPtrTy,
+                        CGF.getContext().getPointerType(
+                            Data.ReductionCopies[Cnt]->getType()),
+                        Data.ReductionCopies[Cnt]->getExprLoc()),
+                    CGF.ConvertTypeForMem(Data.ReductionCopies[Cnt]->getType()),
+                    Replacement.getAlignment());
         Replacement = RedCG.adjustPrivateAddress(CGF, Cnt, Replacement);
         Scope.addPrivate(RedCG.getBaseDecl(Cnt), Replacement);
       }
@@ -4742,11 +4751,12 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
         }
         Address Replacement = CGF.CGM.getOpenMPRuntime().getTaskReductionItem(
             CGF, S.getBeginLoc(), ReductionsPtr, RedCG.getSharedLValue(Cnt));
-        Replacement = Address::deprecated(
+        Replacement = Address(
             CGF.EmitScalarConversion(
                 Replacement.getPointer(), CGF.getContext().VoidPtrTy,
                 CGF.getContext().getPointerType(InRedPrivs[Cnt]->getType()),
                 InRedPrivs[Cnt]->getExprLoc()),
+            CGF.ConvertTypeForMem(InRedPrivs[Cnt]->getType()),
             Replacement.getAlignment());
         Replacement = RedCG.adjustPrivateAddress(CGF, Cnt, Replacement);
         InRedScope.addPrivate(RedCG.getBaseDecl(Cnt), Replacement);
@@ -4896,9 +4906,10 @@ void CodeGenFunction::EmitOMPTargetTaskBasedDirective(
       CGF.CGM.getOpenMPRuntime().emitOutlinedFunctionCall(
           CGF, S.getBeginLoc(), {CopyFnTy, CopyFn}, CallArgs);
       for (const auto &Pair : PrivatePtrs) {
-        Address Replacement =
-            Address::deprecated(CGF.Builder.CreateLoad(Pair.second),
-                                CGF.getContext().getDeclAlign(Pair.first));
+        Address Replacement(
+            CGF.Builder.CreateLoad(Pair.second),
+            CGF.ConvertTypeForMem(Pair.first->getType().getNonReferenceType()),
+            CGF.getContext().getDeclAlign(Pair.first));
         Scope.addPrivate(Pair.first, Replacement);
       }
     }


        


More information about the cfe-commits mailing list