forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd74adf
commit 71f1973
Showing
1 changed file
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Sorry, something went wrong. |
||
// | ||
// - **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.
Sorry, something went wrong.
vext01
|
||
// 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" | ||
|
@@ -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" | ||
|
||
|
@@ -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); | ||
|
At squash time, please captialise the "t" in "the".