[PATCH] D75423: [OpenCL] Mark pointers to constant address space as invariant
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 1 21:51:18 PST 2020
rjmccall added inline comments.
================
Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:172
+ if (llvm::Constant *C = dyn_cast<llvm::Constant>(Addr))
+ Cast = llvm::ConstantExpr::getBitCast(C, ObjectPtr[0]);
+ else
----------------
This check is already done by `CreateBitCast`.
================
Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:176
+ llvm::Value *Args[2] = {llvm::ConstantInt::getSigned(Int64Ty, Width), Cast};
Builder.CreateCall(InvariantStart, Args);
}
----------------
I know this is a pre-existing code pattern, but there's an overload of `CreateCall` that just takes two arguments directly; please switch the code to use that.
================
Comment at: clang/lib/CodeGen/CGExpr.cpp:1255
ApplyDebugLocation DL(*this, E);
+ LValue Ret;
switch (E->getStmtClass()) {
----------------
This is not the way to do this, but fortunately it's unnecessary anyway. You can just put the invariant-load metadata on any loads from the constant address space in the functions called by `EmitLoadOfLValue`.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75423/new/
https://reviews.llvm.org/D75423
More information about the cfe-commits
mailing list