[llvm] [IR] Composable and Extensible Memory Cache Control Hints (PR #181612)
Fei Peng via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 23 20:20:36 PDT 2026
================
@@ -5576,6 +5577,72 @@ void Verifier::visitAllocTokenMetadata(Instruction &I, MDNode *MD) {
"expected integer constant", MD);
}
+void Verifier::visitMemCacheHintMetadata(Instruction &I, MDNode *MD) {
+ Check(I.mayReadOrWriteMemory(),
+ "!mem.cache_hint is only valid on memory operations", &I);
+
+ Check(MD->getNumOperands() % 2 == 0,
+ "!mem.cache_hint must have even number of operands "
+ "(operand_no, hint_node pairs)",
+ MD);
+
+ auto IsMemoryObjectOperand = [](const Value *V) {
+ return V->getType()->isPtrOrPtrVectorTy();
+ };
+
+ unsigned NumMemoryObjectOperands = 0;
+ if (const auto *CB = dyn_cast<CallBase>(&I))
+ NumMemoryObjectOperands = count_if(CB->args(), [&](const Use &Arg) {
+ return IsMemoryObjectOperand(Arg.get());
+ });
+ else
+ NumMemoryObjectOperands = count_if(I.operands(), [&](const Use &Op) {
+ return IsMemoryObjectOperand(Op.get());
+ });
+
+ SmallVector<unsigned, 4> SeenOperandNos;
----------------
fiigii wrote:
Fixed
https://github.com/llvm/llvm-project/pull/181612
More information about the llvm-commits
mailing list