Project Stage III: Multi-Clone Analysis in GCC Pass
Introduction In Stage III, I enhanced my GCC pass to analyze programs with multiple cloned functions simultaneously, making individual PRUNE/NOPRUNE decisions for each clone. This involved refining GIMPLE code comparisons, handling compiler optimization challenges, and validating results on both x86_64 and aarch64 architectures. Implementation Core Logic (Key Code Snippets) 1. Data Structure for Clones // Stores GIMPLE statements and operand types for each function struct GimpleStmtInfo { int code; std::vector<tree> operands; }; std::map<std::string, std::vector<GimpleStmtInfo>> function_map; 2. Clone Detection // Identify cloned functions by name (e.g., "func.clone1") if (func_name.find(base_name + ".") == 0 && func_name.find(".resolver") == std::string::npos) { // Compare GIMPLE sequences bool is_same = (base_gimple == cloned_gimple); fprintf(dump_file, "Result: %s\n", is...