================
@@ -535,6 +557,96 @@ struct InstructionIO : public InstrumentationOpportunity {
}
};
+/// The instrumentation opportunity for functions.
+struct FunctionIO : public InstrumentationOpportunity {
+ FunctionIO(bool IsPRE)
+ : InstrumentationOpportunity(
+ InstrumentationLocation(InstrumentationLocation(
+ IsPRE ? InstrumentationLocation::FUNCTION_PRE
+ : InstrumentationLocation::FUNCTION_POST))) {}
+ virtual ~FunctionIO() {};
+
+ enum ConfigKind {
+ PassAddress = 0,
+ PassName,
+ PassNumArguments,
+ PassArguments,
+ ReplaceArguments,
+ PassIsMain,
+ PassId,
+ NumConfig,
+ };
+
+ struct ConfigTy final : public BaseConfigTy<ConfigKind> {
+ std::function<bool(Argument &)> ArgFilter;
+
+ ConfigTy(bool Enable = true) : BaseConfigTy(Enable) {}
+ } Config;
+
+ StringRef getName() const override { return "function"; }
+
+ void init(InstrumentationConfig &IConf, LLVMContext &Ctx,
+ ConfigTy *UserConfig = nullptr);
+
+ static Value *getFunctionAddress(Value &V, Type &Ty,
+ InstrumentationConfig &IConf,
+ InstrumentorIRBuilderTy &IIRB);
+ static Value *getFunctionName(Value &V, Type &Ty,
+ InstrumentationConfig &IConf,
+ InstrumentorIRBuilderTy &IIRB);
+ Value *getNumArguments(Value &V, Type &Ty, InstrumentationConfig &IConf,
+ InstrumentorIRBuilderTy &IIRB);
+ Value *getArguments(Value &V, Type &Ty, InstrumentationConfig &IConf,
+ InstrumentorIRBuilderTy &IIRB);
+ Value *setArguments(Value &V, Value &NewV, InstrumentationConfig &IConf,
+ InstrumentorIRBuilderTy &IIRB);
+ static Value *isMainFunction(Value &V, Type &Ty, InstrumentationConfig
&IConf,
+ InstrumentorIRBuilderTy &IIRB);
+
+ static void populate(InstrumentationConfig &IConf, LLVMContext &Ctx) {
+ for (auto IsPRE : {true, false}) {
+ auto *AIC = IConf.allocate<FunctionIO>(IsPRE);
+ AIC->init(IConf, Ctx);
+ }
+ }
+};
+
+/// The instrumentation opportunity for alloca instructions.
+struct AllocaIO : public InstructionIO<Instruction::Alloca> {
----------------
arsenm wrote:
final?
https://github.com/llvm/llvm-project/pull/195378
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits