[llvm] [Instrumentor] Add comparison instrumentation opportunity (PR #204069)
Kevin Sala Penades via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 17 22:43:18 PDT 2026
================
@@ -903,6 +905,42 @@ static void readValuePack(const Range &R, Value &Pack,
}
}
+template <unsigned... Opcodes>
+Value *InstructionIO<Opcodes...>::getOpcode(Value &V, Type &Ty,
+ InstrumentationConfig &IConf,
+ InstrumentorIRBuilderTy &IIRB) {
+ auto &I = cast<Instruction>(V);
+ return getCI(&Ty, I.getOpcode());
+}
----------------
kevinsala wrote:
I just remembered `InstructionIO` is a template class, so having the template definitions in the source file will be highly problematic and will end up with undefined references. I still think it's good to have these functions within the "common" class. Two possible solutions for that:
1. Move the definition also to the header file.
2. If the previous is not possible for some reason, we can have a `InstructionBaseIO` class (non-template) and have the functions there. So the inheritance chain is: _InstrumentationOpportunity_ <- _InstructionBaseIO_ (non-template) <- _InstructionIO_ (template) <- _CompareIO_.
Makes sense?
https://github.com/llvm/llvm-project/pull/204069
More information about the llvm-commits
mailing list