# Project - Stage 2 : Initialised

For project stage 2, We have to create a pass for the GCC compiler which analyzes the program being compiled. This project built upon my earlier work from Stage 1, where I created a basic GCC pass that counted basic blocks and gimple statements within each function.

### Objectives are:

To identify one or more functions that have been cloned, having the name function.variant where the function portion is the same, and there will be a resolver too: function.resolver.

To examine if it same or different keeping in. mind the exception: “Substantially the same” means that they are identical, with the possible exception of identifiers such as tem.porary and single static assignment (SSA) variable names, labels, and basic block numbers

To emit a message in the dump file to show if it is pruned or not pruned

**Before that we should understand what is cloned function?**

Cloned functions in GCC are duplicates of original functions created during optimization, typically specialized for specific use-cases like constant arguments or improved caching.

For example, a function named `compute` might be cloned as `compute.constprop.0`, specialized for a specific constant parameter scenario.

## Clone Detection Strategy

To detect cloned functions, We can use name-based and signature-based detection methods:

* **Name-based detection**: Checking for GCC’s known clone suffixes (`.constprop`, `.clone`, `.isra`) to identify possible clones.
    
* **Signature-based detection**: Genrerating a simplified hash signature of each function’s GIMPLE representation. Functions sharing an identical signature indicated identical behavior, thus marking one as a candidate for pruning.
