Posts

SPO600 Project Stage 3 - Identify clones of multiple functions and compare them

Image
 In the previous parts, I created a GCC pass to identify function clones and compare them.  Now, I would like to modify the pass so that it could handle program that has multiple functions which are cloned. Moreover, I personally want to organize the static variables. Instead of using parallel vectors/multiples map to store the characteristics of the clone variant1, I would like to use a struct to store that of clone of variant 1 of every cloned function. Step 1. Revise the code to handle program with multiple functions cloned in x86 server Here is the revised pass. The pass and critical files are also uploaded to GitHub . /* Test Pass Jeff Yau, Seneca Polytechnic College Student ID :142466234 Modelled on tree-nrv.cc and tree-ctyler.cc by Chris Tyler, Seneca Polytechnic College, 2024-11 This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Sof...

SPO600 Project Stage 2 (Pt.6) - Testing in AArch64 and Reflection

Image
In the previous parts, I created a GCC pass on an x86-64 server to identify function clones and compare them.  Testing in AArch64 Server Source code is the same as the one posted in part 5. Source code and critical files for both servers are also available in GitHub. When I compile, there is a warning " Function Multi Versioning support is experimental."  That's exactly what I am doing. [jyau11@aarch64-002 test-clone]$  make CC=/home/jyau11/spo600/lab4/gcc-test-003/bin/gcc DUMP_ALL=1 /home/jyau11/spo600/lab4/gcc-test-003/bin/gcc -c  vol_createsample.c -o vol_createsample.o /home/jyau11/spo600/lab4/gcc-test-003/bin/gcc -D 'CLONE_ATTRIBUTE=__attribute__((target_clones("default","rng") ))'\         -march=armv8-a -g -O3 -fno-lto  -ftree-vectorize  -fdump-tree-all -fdump-ipa-all -fdump-rtl-all \         clone-test-core.c vol_createsample.o -o clone-test-aarch64-prune clone-test-core.c:28:6:  warning: Function Multi V...

SPO600 Project Stage 2 (Pt.5) - gcc pass to identify clone functions and comparing them

Image
In the previous parts, I created a GCC pass on an x86-64 server to identify function clones and compare them.  It will compare the number of GIMPLE statements and basic blocks of two clone. Also, I used a vector to store the GIMPLE Type and compare it afterward. Target:  Compare  operands type  and  the number of operands  for assignment GIMPLE statements. For the assignment operation, we check the right-hand operands to determine whether the statement structures are identical. The new version will also use a vector to store the number of operands and the types of the right-hand operands. New version code: /* Test Pass Jeff Yau, Seneca Polytechnic College Student ID :142466234 Modelled on tree-nrv.cc and tree-ctyler.cc by Chris Tyler, Seneca Polytechnic College, 2024-11 This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free ...

SPO600 Project Stage 2 (Pt.4) - rewrite GCC pass to identify clone functions and comparing them

Image
In the previous phase, I created a GCC pass on an x86-64 server to identify function clones and compare them. However, it did not work perfectly, as I was unable to retrieve the function pointer using the node pointer stored from the previous execution. As a result, I decided to rewrite the pass using a different approach. Target:  Identify clones and compare the number of basic blocks and GIMPLE statements. The new version will first use for_each_function to locate the resolver’s base name. Then, in the main body of the execute function, it will check whether the current function has the same name as the resolver. If they match, it will compare the number of GIMPLE statements and basic blocks. New version code: /* Test Pass Jeff Yau, Seneca Polytechnic College Student ID :142466234 Modelled on tree-nrv.cc and tree-ctyler.cc by Chris Tyler, Seneca Polytechnic College, 2024-11 This file is part of GCC. GCC is free software; you can redistribute it and/or mo...

SPO600 Project Stage 2 (Pt.3) - GCC pass comparing two clone functions

Image
In project stage 1, I created a GCC pass in both x86-64 server and AARCH64 server to print the functions' name and counting number of block. In stage 2 pt2, I successfully locate the clones. Mission:    compare the number of block number and number of gimple statement.  Trial 1: Now, I am trying to modified the code to compare the block number and statement number.  Modified code: /* Test Pass Jeff Yau, Seneca Polytechnic College Student ID :142466234 Modelled on tree-nrv.cc and tree-ctyler.cc by Chris Tyler, Seneca Polytechnic College, 2024-11 This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTI...

SPO600 Project Stage 2 (Pt.2) - GCC pass locating clone function -modified version

Image
In project stage 1, I created a GCC pass in both x86-64 server and AARCH64 server to print the functions' name and counting number of block. In stage 2 pt.1, I was trying to modify the code to locate the clone but in vain. I sought advice from my professor, Chris Tyler and note that for the default version of the clone, the node->name() function will return function name without any .variant, i.e. without .default . That's why the previous version does not work. As a result, I revised the code accordingly and it works now. revised code: /* Test Pass Jeff Yau, Seneca Polytechnic College Student ID :142466234 Modelled on tree-nrv.cc and tree-ctyler.cc by Chris Tyler, Seneca Polytechnic College, 2024-11 This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is dis...

SPO600 Project Stage 2 (Pt.1) - GCC pass locating clone function

Image
In project stage 1, I created a GCC pass in both x86-64 server and AARCH64 server to print the functions' name and counting number of block. Now, I would like to revise the pass again and increase it's functionality. Step 1. Modify the pass First, I would like to detect if the function is a clone. When a clone is detected, loop will be broken. Meanwhile, just ignore the count of statement and blocks first. They will be useful for later part. revised code: /* Test Pass Jeff Yau, Seneca Polytechnic College Student ID :142466234 Modelled on tree-nrv.cc and tree-ctyler.cc by Chris Tyler, Seneca Polytechnic College, 2024-11 This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even th...

SPO600 Project Stage 1 (Pt.2) - Revise the GCC Pass

Image
In part 1 , I created a GCC pass in x86-64 server to print the functions' name. Now, I would like to revise the pass and increase it's functionality. Revised GCC pass code: /* Test Pass Jeff Yau, Seneca Polytechnic College Modelled on tree-nrv.cc and tree-ctyler.cc by Chris Tyler, Seneca Polytechnic College, 2024-11 This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ //#define INCLUDE_MEMORY #...