Skip to content

Commit

Permalink
Add ModuleClone doc comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel-Durov committed Oct 11, 2024
1 parent bd74adf commit 71f1973
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions llvm/lib/Transforms/Yk/ModuleClone.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
//===- ModuleClone.cpp - Yk Module Cloning Pass ---------------------------===//
//
// This pass duplicates functions within the module, producing both the original
// and new versions of functions. the process is as follows:

This comment has been minimized.

Copy link
@vext01

vext01 Oct 14, 2024

At squash time, please captialise the "t" in "the".

//
// - **Cloning Criteria:**
// - Functions **without** their address taken are cloned. This results in two
// versions of such functions in the module: the original and the cloned
// version.
// - Functions **with** their address taken remain only in their original form
// and are not cloned.
//
// - **Cloned Function Naming:**
// - The cloned functions are renamed by adding the prefix `__yk_clone_` to
// their
// original names. This distinguishes them from the original functions.
//
// - **Clone Process:**
// - 1. The orignal model is cloned, creating two copies of the module.
// - 2. The functions in the cloned module that satisfy the cloning
// criteria are renamed.
// - 3. The cloned module is linked back into the original module.
//
// - **Optimisation Intent:**
// - The **cloned functions** (those with the `__yk_clone_` prefix) are

This comment has been minimized.

Copy link
@vext01

vext01 Oct 14, 2024

And also at squash time, if you could sort out the indent here.

Other than that, this comment helps. Thanks!

// intended
// to be the **optimised versions** of the functions.
// - The **original functions** remain **unoptimised**.
//
//===----------------------------------------------------------------------===//

#include "llvm/Transforms/Yk/ModuleClone.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/BasicBlock.h"
Expand All @@ -7,11 +38,11 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Verifier.h"
#include "llvm/InitializePasses.h"
#include "llvm/Linker/Linker.h"
#include "llvm/Pass.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/IR/Verifier.h"

#define DEBUG_TYPE "yk-module-clone-pass"

Expand Down Expand Up @@ -42,9 +73,9 @@ struct YkModuleClone : public ModulePass {

// This pass duplicates functions within the module:
// the original and the cloned version.
// - If a function's address is not taken, it is cloned, resulting in
// - If a function's address is not taken, it is cloned, resulting in
// two versions of that function in the module.
// - If a function's address is taken, the function remains in its
// - If a function's address is taken, the function remains in its
// original form.
bool runOnModule(Module &M) override {
std::unique_ptr<Module> Cloned = CloneModule(M);
Expand Down

0 comments on commit 71f1973

Please sign in to comment.