Skip to content

Commit 88f9da1

Browse files
committed
s/patchoptions/instrumentationoptions/g to make a little more logical space to have both patches and contracts
1 parent 98e27ce commit 88f9da1

3 files changed

Lines changed: 29 additions & 29 deletions

File tree

include/patchestry/Passes/InstrumentationPass.hpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace mlir {
3434

3535
namespace patchestry::passes { // NOLINT
3636

37-
struct PatchOptions;
37+
struct InstrumentationOptions;
3838

3939
/**
4040
* @brief Registers instrumentation passes with the MLIR pass registry.
@@ -45,7 +45,7 @@ namespace patchestry::passes { // NOLINT
4545
* instrumentation rules.
4646
*
4747
* @param configuration_file Path to the YAML Patchestry configuration file containing
48-
* instrumentation rules
48+
* instrumentation rules for applying patches, contracts, or both
4949
*/
5050
void registerInstrumentationPasses(std::string configuration_file);
5151

@@ -56,18 +56,18 @@ namespace patchestry::passes { // NOLINT
5656
* instance.
5757
*
5858
* @param configuration_file Path to the YAML configuration file
59-
* @param patch_options Configuration options for controlling function inlining behavior
59+
* @param options Configuration options for controlling how instrumentation is generally applied
6060
* @return std::unique_ptr<mlir::Pass> A unique pointer to the created InstrumentationPass
6161
*/
6262
std::unique_ptr< mlir::Pass >
63-
createInstrumentationPass(const std::string &configuration_file, const PatchOptions &patch_options);
63+
createInstrumentationPass(const std::string &configuration_file, const InstrumentationOptions &options);
6464

6565
/**
66-
* @brief Configuration options for controlling patching behavior.
66+
* @brief Configuration options for controlling instrumentation behavior.
6767
*/
68-
struct PatchOptions
68+
struct InstrumentationOptions
6969
{
70-
/** @brief Flag to enable or disable function inlining of patch functions */
70+
/** @brief Flag to enable or disable function inlining of instrumentation functions */
7171
bool enable_inlining;
7272
};
7373

@@ -81,9 +81,9 @@ namespace patchestry::passes { // NOLINT
8181
* @brief MLIR pass that applies code instrumentation based on configuration.
8282
*
8383
* The InstrumentationPass is an MLIR transformation pass that modifies MLIR modules
84-
* by applying patches according to specifications defined in a YAML configuration file.
85-
* It can instrument function calls and operations by inserting patch code before, after,
86-
* or replacing the original operations entirely.
84+
* by instrumenting according to specifications defined in a YAML configuration file.
85+
* It can instrument function calls and operations by inserting patch or contract code
86+
* before or after, or by replacing an original operation entirely with a patch.
8787
*
8888
* The pass supports three main instrumentation modes:
8989
* - APPLY_BEFORE: Insert patch code before the matched operation
@@ -100,28 +100,28 @@ namespace patchestry::passes { // NOLINT
100100
/** @brief Path to the YAML Patchestry configuration file */
101101
std::string configuration_file;
102102

103-
/** @brief Parsed patch configuration from the file */
103+
/** @brief Parsed patch- or contract-specific configuration from the file */
104104
std::optional< Configuration > config;
105105

106106
/** @brief List of operations to be inlined after instrumentation */
107107
std::vector< mlir::Operation * > inline_worklists;
108108

109109
/** @brief Reference to inlining configuration options */
110-
const PatchOptions &patch_options;
110+
const InstrumentationOptions &options;
111111

112112
public:
113113
/**
114114
* @brief Constructs an InstrumentationPass with the given configuration file and
115115
* options.
116116
*
117-
* The constructor loads and parses the configuration YAML file, validates patch files,
118-
* and prepares the pass for execution. If a file cannot be loaded or
119-
* parsed, appropriate error messages are logged.
117+
* The constructor loads and parses the configuration YAML file, validates the indicated
118+
* patches and/or contracts, and prepares the pass for execution. If a file cannot be
119+
* loaded or parsed, appropriate error messages are logged.
120120
*
121121
* @param configuration_file Path to the YAML configuration file
122122
* @param inline_options Reference to inlining configuration options
123123
*/
124-
explicit InstrumentationPass(std::string configuration_file, const PatchOptions &patch_options);
124+
explicit InstrumentationPass(std::string configuration_file, const InstrumentationOptions &options);
125125

126126
/**
127127
* @brief Main entry point for the pass execution.

lib/patchestry/Passes/InstrumentationPass.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,12 @@ namespace patchestry::passes {
265265
* configuration_file, and use the given inline options for controlling inlining behavior.
266266
*
267267
* @param configuration_file Path to the YAML patch specification file
268-
* @param inline_options Configuration options for controlling function inlining behavior
268+
* @param ∂options Configuration options for controlling how instrumentation is generally applied
269269
* @return std::unique_ptr<mlir::Pass> A unique pointer to the created InstrumentationPass
270270
*/
271271
std::unique_ptr< mlir::Pass >
272-
createInstrumentationPass(const std::string &configuration_file, const PatchOptions &patch_options) {
273-
return std::make_unique< InstrumentationPass >(configuration_file, patch_options);
272+
createInstrumentationPass(const std::string &configuration_file, const InstrumentationOptions &options) {
273+
return std::make_unique< InstrumentationPass >(configuration_file, options);
274274
}
275275

276276
template< typename T >
@@ -311,20 +311,20 @@ namespace patchestry::passes {
311311
* @param patch_options Reference to inlining configuration options
312312
*/
313313
InstrumentationPass::InstrumentationPass(
314-
std::string spec_, const PatchOptions &patch_options_
314+
std::string spec_, const InstrumentationOptions &options_
315315
)
316-
: configuration_file(std::move(spec_)), patch_options(patch_options_) {
316+
: configuration_file(std::move(spec_)), options(options_) {
317317
patchestry::yaml::YAMLParser parser;
318318
ConfigurationFile::getInstance().set_file_path(configuration_file);
319319
if (!parser.validate_yaml_file< patchestry::passes::Configuration >(configuration_file)) {
320-
LOG(ERROR) << "Error: Failed to parse patch specification file: " << configuration_file
320+
LOG(ERROR) << "Error: Failed to parse Patchestry configuration file: " << configuration_file
321321
<< "\n";
322322
return;
323323
}
324324

325325
auto buffer_or_err = llvm::MemoryBuffer::getFile(configuration_file);
326326
if (!buffer_or_err) {
327-
LOG(ERROR) << "Error: Failed to read patch specification file: " << configuration_file
327+
LOG(ERROR) << "Error: Failed to read Patchestry configuration file: " << configuration_file
328328
<< "\n";
329329
return;
330330
}
@@ -333,7 +333,7 @@ namespace patchestry::passes {
333333
llvm::sys::path::filename(configuration_file).str()
334334
);
335335
if (!config_or_err) {
336-
LOG(ERROR) << "Error: Failed to parse patch specification file: " << configuration_file
336+
LOG(ERROR) << "Error: Failed to parse Patchestry configuration file: " << configuration_file
337337
<< "\n";
338338
return;
339339
}
@@ -355,7 +355,7 @@ namespace patchestry::passes {
355355
continue;
356356
}
357357
}
358-
(void) patch_options;
358+
(void) options;
359359
}
360360

361361
/**
@@ -373,7 +373,7 @@ namespace patchestry::passes {
373373

374374
// check if the configuration is loaded; if not, return
375375
if (!config) {
376-
LOG(ERROR) << "No patch configuration loaded. Skipping instrumentation.\n";
376+
LOG(ERROR) << "No Patchestry configuration loaded. Skipping instrumentation.\n";
377377
return;
378378
}
379379

@@ -867,7 +867,7 @@ namespace patchestry::passes {
867867
*/
868868
void InstrumentationPass::apply_before_patch(
869869
mlir::Operation *target_op, const PatchInformation &patch, mlir::ModuleOp patch_module,
870-
bool inline_patches
870+
bool should_inline
871871
) {
872872
if (target_op == nullptr) {
873873
LOG(ERROR) << "Patch before: Operation is null";
@@ -923,7 +923,7 @@ namespace patchestry::passes {
923923
// Set appropriate attributes based on operation type
924924
set_patch_call_attributes(patch_call_op, target_op);
925925

926-
if (inline_patches) {
926+
if (should_inline) {
927927
inline_worklists.push_back(patch_call_op);
928928
}
929929
}

tools/patchir-transform/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ namespace patchestry::instrumentation {
7878
}
7979

8080
if (enable_instrumentation.getValue()) {
81-
patchestry::passes::PatchOptions inline_options = { enable_inlining.getValue() };
81+
patchestry::passes::InstrumentationOptions inline_options = { enable_inlining.getValue() };
8282
mlir::PassManager pm(&context);
8383
pm.addPass(patchestry::passes::createInstrumentationPass(
8484
spec_filename.getValue(), inline_options

0 commit comments

Comments
 (0)