Posts

Project Stage 3: Enhancing GCC Pass for Multiple Function Clone Handling: Progress Update

In my earlier work, I developed a basic GCC pass for identifying and comparing function clones. For this latest phase, I focused on improving the pass to handle programs containing multiple cloned functions. Additionally, I wanted to enhance code organization by consolidating data storage, replacing multiple parallel vectors and maps with a structured approach using a dedicated struct to store characteristics of clone variants. Implementation Process Phase 1: Code Revision for Multi-Function Support I modified the pass to properly handle programs with multiple cloned functions in x86 server environments. The updated code includes all critical support files. The revised implementation's core is a specialized pass that processes GIMPLE representation data. This pass systematically identifies resolver functions and creates appropriate tracking structures for each function being cloned. The implementation uses maps and vectors to store function characteristics, including basic block co...

Project Stage 3 - Function Multi-Versioning Enhancement Project

This term, our team has been focused on extending the GCC compiler's capabilities by implementing Automatic Function Multi-Versioning (AFMV) cloning functionality. This technology enables the compiler to generate multiple optimized variants of functions specifically tailored to different CPU architectures, enhancing performance without requiring developers to manually add attributes in their code. Our research investigated two potential implementation strategies: Core Compiler Modification: Altering GCC's fundamental processing to natively support automatic function multi-versioning. Automated Attribute Implementation: Developing a compilation pass that would automatically insert target_clones attributes into functions early in the compilation process. After significant investigation into the first approach with guidance from our professor, we encountered substantial technical hurdles—particularly segmentation faults triggered by specific edge cases (like non-local got...

Project Stage 2: Project Update & Comparing Cloned Functions

Image
 Hi there! I've returned with further project progress. I'll demonstrate my method for comparing cloned functions and deciding whether to prune them today. A Helpful Time-Saving Tip Instead of repeatedly typing the full path to our custom GCC or running the lengthy export command, I created a simple alias: I opened the bash configuration file:  nano ~/.bashrc Added this line at the end:  alias addgcc="export PATH=\"$HOME/gcc-test-001/bin:\$PATH\"" Activated the changes:  source ~/.bashrc Now I can just type  addgcc  Whenever I need to switch to my custom compiler Verify it worked with  which gcc This small change saved me tons of time during development! Implementing Function Comparison Now, let's discuss how I implemented the comparison functionality. Phase 1: Getting the Cloned Functions In my previous article, I showed how I identify variant cloned functions. I used a map data structure where: The key is the base function name (like "foo") T...