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, 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/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/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/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(),