[PATCH] llvm.noalias - Add IRBuilder support
Philip Reames
listmail at philipreames.com
Tue May 12 15:41:19 PDT 2015
================
Comment at: include/llvm/IR/IRBuilder.h:449
@@ +448,3 @@
+ /// \brief Create an noalias intrinsic.
+ Instruction *CreateNoAlias(Value *Ptr, MDNode *ScopeTag);
+
----------------
CreateNoAlias sounds confusing. Maybe, CreateNoAliasMarker? CreateNoAliasIntrinsic?
================
Comment at: lib/IR/IRBuilder.cpp:190
@@ +189,3 @@
+Instruction *IRBuilderBase::CreateNoAlias(Value *Ptr, MDNode *ScopeTag) {
+ // FIXME: We can currently mangle just about everything, but not literal
+ // structs (for those, bitcast to i8*).
----------------
I would rather see you just bitcast everything. Having one weird special case when we're moving to unified pointers anyways seems unjustified.
Very minor preference here; feel free to ignore.
================
Comment at: lib/IR/IRBuilder.cpp:201
@@ +200,3 @@
+ Value *Ops[] = { CPtr, MetadataAsValue::get(Context, ScopeTag) };
+ Module *M = BB->getParent()->getParent();
+ Value *FnNoAlias = Intrinsic::getDeclaration(M, Intrinsic::noalias, Types);
----------------
Use getModule
================
Comment at: lib/IR/IRBuilder.cpp:204
@@ +203,3 @@
+ Instruction *Ret = createCallHelper(FnNoAlias, Ops, this);
+ cast<CallInst>(Ret)->setDoesNotThrow();
+
----------------
If the original pointer is noalias, should the return also be noalias? I note that this is a different noalias per discussion on another thread. Slightly confusing to say the least.
Other attributes: nonnull, dereferenceable, etc..? I'd be fine with instcombine rules instead.
================
Comment at: lib/IR/IRBuilder.cpp:208
@@ +207,3 @@
+ BitCastInst *BCI = new BitCastInst(Ret, Ptr->getType(), "");
+ BB->getInstList().insert(InsertPt, BCI);
+ SetInstDebugLocation(BCI);
----------------
Using BitCastInst::Create might simplify these two lines.
http://reviews.llvm.org/D9378
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list