[PATCH] D22189: llvm.noalias - Clang CodeGen - check restrict variable map only for restrict-qualified lvalues

Hal Finkel via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 3 14:47:55 PDT 2016


hfinkel updated this revision to Diff 73345.
hfinkel added a comment.

Rebased


https://reviews.llvm.org/D22189

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


Index: lib/CodeGen/CodeGenFunction.h
===================================================================
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2749,7 +2749,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,
                          AlignmentSource AlignSource = AlignmentSource::Type,
                          llvm::MDNode *TBAAInfo = nullptr, bool isInit = false,
                          QualType TBAABaseTy = QualType(),
Index: lib/CodeGen/CGStmtOpenMP.cpp
===================================================================
--- lib/CodeGen/CGStmtOpenMP.cpp
+++ lib/CodeGen/CGStmtOpenMP.cpp
@@ -271,7 +271,7 @@
         Address RefAddr = CreateMemTemp(CurVD->getType(), getPointerAlign(),
                                         ".materialized_ref");
         EmitStoreOfScalar(LocalAddr.getPointer(), RefAddr, /*Volatile=*/false,
-                          CurVD->getType());
+                          /*Restrict=*/false, CurVD->getType());
         LocalAddr = RefAddr;
       }
       setAddrOfLocalVar(CurVD, LocalAddr);
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===================================================================
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6762,7 +6762,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
@@ -1372,9 +1372,9 @@
 }
 
 void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr,
-                                        bool Volatile, QualType Ty,
-                                        AlignmentSource AlignSource,
-                                        llvm::MDNode *TBAAInfo,
+                                        bool Volatile, bool Restrict,
+                                        QualType Ty, AlignmentSource
+                                        AlignSource, llvm::MDNode *TBAAInfo,
                                         bool isInit, QualType TBAABaseType,
                                         uint64_t TBAAOffset,
                                         bool isNontemporal) {
@@ -1405,9 +1405,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(), AlignSource, TBAAInfo);
@@ -1436,9 +1438,10 @@
 void CodeGenFunction::EmitStoreOfScalar(llvm::Value *value, LValue lvalue,
                                         bool isInit) {
   EmitStoreOfScalar(value, lvalue.getAddress(), lvalue.isVolatile(),
-                    lvalue.getType(), lvalue.getAlignmentSource(),
-                    lvalue.getTBAAInfo(), isInit, lvalue.getTBAABaseType(),
-                    lvalue.getTBAAOffset(), lvalue.isNontemporal());
+                    lvalue.isRestrictQualified(), lvalue.getType(),
+                    lvalue.getAlignmentSource(), 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
@@ -188,7 +188,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,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22189.73345.patch
Type: text/x-patch
Size: 4956 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161003/3dec0621/attachment.bin>


More information about the cfe-commits mailing list