hfinkel updated this revision to Diff 111130.
hfinkel added a comment.
Herald added a subscriber: jholewinski.

Rebased.


https://reviews.llvm.org/D22189

Files:
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h

Index: lib/CodeGen/CodeGenFunction.h
===================================================================
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3150,7 +3150,7 @@
   /// care to appropriately convert from the memory representation to
   /// the LLVM value representation.
   void EmitStoreOfScalar(llvm::Value *Value, Address Addr,
-                         bool Volatile, QualType Ty,
+                         bool Volatile, bool Restrict, QualType Ty,
                          LValueBaseInfo BaseInfo =
                              LValueBaseInfo(AlignmentSource::Type),
                          llvm::MDNode *TBAAInfo = nullptr, bool isInit = false,
Index: lib/CodeGen/CGStmtOpenMP.cpp
===================================================================
--- lib/CodeGen/CGStmtOpenMP.cpp
+++ lib/CodeGen/CGStmtOpenMP.cpp
@@ -364,7 +364,8 @@
         Address RefAddr = CGF.CreateMemTemp(
             CurVD->getType(), CGM.getPointerAlign(), ".materialized_ref");
         CGF.EmitStoreOfScalar(LocalAddr.getPointer(), RefAddr,
-                              /*Volatile=*/false, CurVD->getType());
+                              /*Volatile=*/false, /*Restrict=*/false,
+                              CurVD->getType());
         LocalAddr = RefAddr;
       }
       if (!FO.RegisterCastedArgsOnly)
@@ -2964,7 +2965,8 @@
       const auto *VD = cast<VarDecl>(cast<DeclRefExpr>(E)->getDecl());
       CGF.EmitVarDecl(*VD);
       CGF.EmitStoreOfScalar(ReductionDesc, CGF.GetAddrOfLocalVar(VD),
-                            /*Volatile=*/false, E->getType());
+                            /*Volatile=*/false, /*Restrict=*/false,
+                            E->getType());
     }
     CGF.EmitStmt(cast<CapturedStmt>(S.getAssociatedStmt())->getCapturedStmt());
   };
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===================================================================
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -1180,7 +1180,7 @@
 
     // Store the source element value to the dest element address.
     CGF.EmitStoreOfScalar(Elem, DestElementAddr, /*Volatile=*/false,
-                          Private->getType());
+                          /*Restrict=*/false, Private->getType());
 
     // Step 3.1: Modify reference in dest Reduce list as needed.
     // Modifying the reference in Reduce list to point to the newly
@@ -1191,7 +1191,7 @@
       CGF.EmitStoreOfScalar(Bld.CreatePointerBitCastOrAddrSpaceCast(
                                 DestElementAddr.getPointer(), CGF.VoidPtrTy),
                             DestElementPtrAddr, /*Volatile=*/false,
-                            C.VoidPtrTy);
+                            /*Restrict=*/false, C.VoidPtrTy);
     }
 
     // Step 4.1: Increment SrcBase/DestBase so that it points to the starting
@@ -1618,7 +1618,7 @@
 
     // *TargetElemPtr = SrcMediumVal;
     CGF.EmitStoreOfScalar(SrcMediumValue, TargetElemPtr, /*Volatile=*/false,
-                          Private->getType());
+                          /*Restrict=*/false, Private->getType());
     Bld.CreateBr(W0MergeBB);
 
     CGF.EmitBlock(W0ElseBB);
@@ -2287,7 +2287,7 @@
                       NativePointeeAddrSpace));
   Address NativeParamAddr = CGF.CreateMemTemp(NativeParamType);
   CGF.EmitStoreOfScalar(TargetAddr, NativeParamAddr, /*Volatile=*/false,
-                        NativeParam->getType());
+                        /*Restrict=*/false, NativeParam->getType());
   return NativeParamAddr;
 }
 
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===================================================================
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7741,7 +7741,8 @@
                                                  CounterVal->getType(), Int64Ty,
                                                  CounterVal->getExprLoc());
   Address CntAddr = CGF.CreateMemTemp(Int64Ty, ".cnt.addr");
-  CGF.EmitStoreOfScalar(CntVal, CntAddr, /*Volatile=*/false, Int64Ty);
+  CGF.EmitStoreOfScalar(CntVal, CntAddr, /*Volatile=*/false, /*Restrict=*/false,
+                        Int64Ty);
   llvm::Value *Args[] = {emitUpdateLocation(CGF, C->getLocStart()),
                          getThreadID(CGF, C->getLocStart()),
                          CntAddr.getPointer()};
Index: lib/CodeGen/CGExpr.cpp
===================================================================
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -1540,8 +1540,8 @@
 }
 
 void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr,
-                                        bool Volatile, QualType Ty,
-                                        LValueBaseInfo BaseInfo,
+                                        bool Volatile, bool Restrict,
+                                        QualType Ty, LValueBaseInfo BaseInfo,
                                         llvm::MDNode *TBAAInfo,
                                         bool isInit, QualType TBAABaseType,
                                         uint64_t TBAAOffset,
@@ -1574,9 +1574,11 @@
   // If this is an assignment to a restrict-qualified local variable, then we
   // have pointer aliasing assumptions that can be applied to the pointer value
   // being stored.
-  auto NAI = NoAliasAddrMap.find(Addr.getPointer());
-  if (NAI != NoAliasAddrMap.end())
-    Value = Builder.CreateNoAliasPointer(Value, NAI->second);
+  if (Restrict) {
+    auto NAI = NoAliasAddrMap.find(Addr.getPointer());
+    if (NAI != NoAliasAddrMap.end())
+      Value = Builder.CreateNoAliasPointer(Value, NAI->second);
+  }
 
   LValue AtomicLValue =
       LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo);
@@ -1606,9 +1608,10 @@
 void CodeGenFunction::EmitStoreOfScalar(llvm::Value *value, LValue lvalue,
                                         bool isInit) {
   EmitStoreOfScalar(value, lvalue.getAddress(), lvalue.isVolatile(),
-                    lvalue.getType(), lvalue.getBaseInfo(),
-                    lvalue.getTBAAInfo(), isInit, lvalue.getTBAABaseType(),
-                    lvalue.getTBAAOffset(), lvalue.isNontemporal());
+                    lvalue.isRestrictQualified(), lvalue.getType(),
+                    lvalue.getBaseInfo(), lvalue.getTBAAInfo(), isInit,
+                    lvalue.getTBAABaseType(), lvalue.getTBAAOffset(),
+                    lvalue.isNontemporal());
 }
 
 /// EmitLoadOfLValue - Given an expression that represents a value lvalue, this
Index: lib/CodeGen/CGDeclCXX.cpp
===================================================================
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -189,7 +189,7 @@
   assert(PerformInit && "cannot have constant initializer which needs "
          "destruction for reference");
   RValue RV = EmitReferenceBindingToExpr(Init);
-  EmitStoreOfScalar(RV.getScalarVal(), DeclAddr, false, T);
+  EmitStoreOfScalar(RV.getScalarVal(), DeclAddr, false, false, T);
 }
 
 /// Create a stub function, suitable for being passed to atexit,
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to