forked from OSchip/llvm-project
[IR] Add NoAliasScopeDeclInst (NFC)
Add an intrinsic type class to represent the llvm.experimental.noalias.scope.decl intrinsic, to make code working with it a bit nicer by hiding the metadata extraction from view.
This commit is contained in:
parent
c37dd3b6d5
commit
c83cff45c7
|
@ -989,6 +989,24 @@ public:
|
|||
return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
|
||||
}
|
||||
};
|
||||
|
||||
class NoAliasScopeDeclInst : public IntrinsicInst {
|
||||
public:
|
||||
static bool classof(const IntrinsicInst *I) {
|
||||
return I->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl;
|
||||
}
|
||||
|
||||
static bool classof(const Value *V) {
|
||||
return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
|
||||
}
|
||||
|
||||
MDNode *getScopeList() const {
|
||||
auto *MV =
|
||||
cast<MetadataAsValue>(getOperand(Intrinsic::NoAliasScopeDeclScopeArg));
|
||||
return cast<MDNode>(MV->getMetadata());
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_IR_INTRINSICINST_H
|
||||
|
|
|
@ -859,13 +859,8 @@ ScopedAliasMetadataDeepCloner::ScopedAliasMetadataDeepCloner(
|
|||
MD.insert(M);
|
||||
|
||||
// We also need to clone the metadata in noalias intrinsics.
|
||||
if (const auto *II = dyn_cast<IntrinsicInst>(&I))
|
||||
if (II->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl)
|
||||
if (const auto *M = dyn_cast<MDNode>(
|
||||
cast<MetadataAsValue>(
|
||||
II->getOperand(Intrinsic::NoAliasScopeDeclScopeArg))
|
||||
->getMetadata()))
|
||||
MD.insert(M);
|
||||
if (const auto *Decl = dyn_cast<NoAliasScopeDeclInst>(&I))
|
||||
MD.insert(Decl->getScopeList());
|
||||
}
|
||||
}
|
||||
addRecursiveMetadataUses();
|
||||
|
@ -932,14 +927,11 @@ void ScopedAliasMetadataDeepCloner::remap(ValueToValueMapTy &VMap) {
|
|||
if (MDNode *M = I->getMetadata(LLVMContext::MD_noalias))
|
||||
I->setMetadata(LLVMContext::MD_noalias, MDMap[M]);
|
||||
|
||||
if (auto *II = dyn_cast<IntrinsicInst>(I))
|
||||
if (II->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl) {
|
||||
auto *MV = cast<MetadataAsValue>(
|
||||
II->getOperand(Intrinsic::NoAliasScopeDeclScopeArg));
|
||||
auto *NewMV = MetadataAsValue::get(
|
||||
II->getContext(), MDMap[cast<MDNode>(MV->getMetadata())]);
|
||||
II->setOperand(Intrinsic::NoAliasScopeDeclScopeArg, NewMV);
|
||||
}
|
||||
if (auto *Decl = dyn_cast<NoAliasScopeDeclInst>(I)) {
|
||||
auto *NewMV =
|
||||
MetadataAsValue::get(Decl->getContext(), MDMap[Decl->getScopeList()]);
|
||||
Decl->setOperand(Intrinsic::NoAliasScopeDeclScopeArg, NewMV);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -947,9 +947,8 @@ bool LoopVectorizationLegality::blockCanBePredicated(
|
|||
// Do not let llvm.experimental.noalias.scope.decl block the vectorization.
|
||||
// TODO: there might be cases that it should block the vectorization. Let's
|
||||
// ignore those for now.
|
||||
if (match(&I, m_Intrinsic<Intrinsic::experimental_noalias_scope_decl>())) {
|
||||
if (isa<NoAliasScopeDeclInst>(&I))
|
||||
continue;
|
||||
}
|
||||
|
||||
// We might be able to hoist the load.
|
||||
if (I.mayReadFromMemory()) {
|
||||
|
|
|
@ -2882,10 +2882,9 @@ void InnerLoopVectorizer::scalarizeInstruction(Instruction *Instr, VPUser &User,
|
|||
|
||||
// llvm.experimental.noalias.scope.decl intrinsics must only be duplicated for
|
||||
// the first lane and part.
|
||||
if (auto *II = dyn_cast<IntrinsicInst>(Instr))
|
||||
if (isa<NoAliasScopeDeclInst>(Instr))
|
||||
if (Instance.Lane != 0 || Instance.Part != 0)
|
||||
if (II->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl)
|
||||
return;
|
||||
return;
|
||||
|
||||
setDebugLocFromInst(Builder, Instr);
|
||||
|
||||
|
|
Loading…
Reference in New Issue