Posts

Showing posts from December, 2024

Project Stage 3 - Tidy up

Image
 Unfortunately I have been unable to complete this section of the project as I have wanted. During the compiling of my new code I came across so many errors and was tinkering around in files outside of the four provided in the sample  gcc/passes.def gcc/Makefile.in gcc/tree-ctyler.cc gcc/tree-pass.h I ended up getting some very wonky errors that I don't quite understand and couldn't find reliable resources on the internet to help me out. Below is an example of one: From what I could make of this bug out of many that I tried to wrestle away there was some sort of error in the gcc pass_manager.h where it is missing specific declarations for files, I was left very confused as some of these files I did not even interact with.  Below is what my final attempt at creating a somewhat resemblance of a GCC pass that prunes functions: #include "config.h" #include "system.h" #include "coretypes.h" #include "tree.h" #include "tree-pass.h" #i...

Project Stage 2: Testing

Image
 To test my custom pass I first extracted the spo600-test-clone files into my gcc-test-001 directory and simply compiled and ran the program with -fdump-tree-ctyler. I ran it on the vol1.c file, the contents of vol1.c are as following: [dpark39@aarch64-002 test-clone]$ cat vol1.c // vol1.c - fixed-point volume scaling algorithm // Chris Tyler 2017.11.29-2021.11.16 - Licensed under GPLv3. // For the Seneca College SPO600 Course #include <stdlib.h> #include <stdio.h> #include <stdint.h> #include <stdbool.h> #include "vol.h" int16_t scale_sample(int16_t sample, int volume) {         return ((((int32_t) sample) * ((int32_t) (32767 * volume / 100) <<1) ) >> 16); } int main() {         int             x;         int             ttl=0; // ---- Create in[] and out[] arrays         int16_t*    ...

Project Stage 2: Custom Implementation

For this stage of the project I had to implement my own custom GCC pass to iterate through the code in the program that was being compiled. Below is my code. #include "config.h" #include "system.h" #include "coretypes.h" #include "tree.h" #include "tree-pass.h" #include "context.h" #include "function.h" #include "basic-block.h"   #include "cfg.h"           #include "gimple.h"       #include "gimple-iterator.h" #include "gimple-pretty-print.h" namespace {     const pass_data pass_data_ctyler = {         GIMPLE_PASS,       // Type         "ctyler",          // Name         OPTGROUP_NONE,     // Option group         TV_NONE,           // TV identifier         PROP_cfg,          // Properties required   ...

Project Stage 2-1

Image
 With the successful build of GCC from my previous blog, we can now move on to the next step in this project which is to add our own custom GCC compiler pass that will analyze a program during its compilation and identify cloned functions, and determine if they are similar or different. It will also create messages determining if the clones should be pruned or retained. This is a very big portion of the AFMV feature for GCC.  In this blog post I will discuss how I extracted the demo files provided by my professor and used it to create dumps and analyze a simple testing program. First, my home directory is divided into three main directories consisting of 1.GCC     The source code for my GCC compiler. It contains the newly extracted source files from the sample tarball. 2.  GCC-build-001     This is the build directory for GCC, this is where I use my make command to build GCC after configuration. 3. GCC-test-001     Installation for the custom...