Index: lib/CodeGen/CGDeclCXX.cpp =================================================================== --- lib/CodeGen/CGDeclCXX.cpp +++ lib/CodeGen/CGDeclCXX.cpp @@ -186,7 +186,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) { @@ -1402,9 +1402,11 @@ Value = EmitToMemory(Value, Ty); - 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); @@ -1433,9 +1435,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 @@ -6579,7 +6579,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/CodeGenFunction.h =================================================================== --- lib/CodeGen/CodeGenFunction.h +++ lib/CodeGen/CodeGenFunction.h @@ -2722,7 +2722,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(),