[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
Sat Jul 9 13:38:12 PDT 2016
hfinkel created this revision.
hfinkel added reviewers: rjmccall, chandlerc, rsmith, dberlin.
hfinkel added a subscriber: cfe-commits.
Herald added a subscriber: mcrosier.
As part of D9403, John McCall asked to avoid making a DenseMap query per emitted store instruction. This can be done by restricting the query to stores to restrict-qualified LValues. I'm posting this as a separate enhancement patch to D9403 to avoid cluttering it.
http://reviews.llvm.org/D22189
Files:
lib/CodeGen/CGDeclCXX.cpp
lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGOpenMPRuntime.cpp
lib/CodeGen/CodeGenFunction.h
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(),
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/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/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,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22189.63399.patch
Type: text/x-patch
Size: 4210 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160709/f5288b24/attachment-0001.bin>
More information about the cfe-commits
mailing list