Bài đăng

Đang hiển thị bài đăng từ Tháng 12, 2024

Project Stage 2 (Part 4): Testing and Results

   Testing the Pass With the logic in place, I tested the pass using the provided test cases. 1. Extracting the Test Cases cp /public/spo600-test-clone.tgz ~/test-clone cd ~/test-clone tar -xvf spo600-test-clone.tgz 2. Compiling the Test Programs Then I used the modified GCC, I compiled the test programs: ~/gcc-install/bin/gcc -fdump-tree-ctyler test-clone-arch-prune.c -o prune-test ~/gcc-install/bin/gcc -fdump-tree-ctyler test-clone-arch-noprune.c -o noprune-test 3. Results With test case : test-clone-arch-prune. This test involved two functions that were equivalent after optimizations. The expectiation was for the pass to emit the message: PRUNE: test_function indicating that the clone could be safely removed. The .ctytler dump file showed: PRUNE: test_function And to the test case  test-clone-arch-noprune. The expected diagnostic message was  NOPRUNE: test_function Unfortunately, this test did not pass as expected Challenges Gimple Variations : The pass misint...

Project Stage 2 (Part 3): Implementing the Clone-Pruning Logic

Building the Heart of the Pass Once I had GCC built and the demo pass working, it was time to dive into the real challenge: implementing the clone-pruning logic in tree-ctyler.cc . How I Tackled It 1. Understanding Gimple IR GCC represents programs using intermediate representations, and my pass needed to analyze the Gimple IR. At first, Gimple seemed overwhelming, but once I found examples of basic block and statement iteration, it started making sense. 2. Comparing Functions The goal was to check if two cloned functions were equivalent. I wrote a function to compare Gimple statements: That I added the following logic to tree-ctyler.cc: bool compare_gimple_statements (gimple *stmt1, gimple *stmt2) { if ( gimple_code (stmt1) != gimple_code (stmt2)) return false ; // Different types of statements return true ; } Then, I added a loop to iterate through the basic blocks and statements of two functions: bool are_functions_equivalent (tree f1, tree f2) { basic_b...

Project Stage 2 (Part 2): Set Up GCC for My Clone-Pruning Pass

A Journey Into GCC When I started this project, I knew it was going to be a challenge. The GCC compiler is a massive and complex system, and diving into its internals felt daunting. My task was to build GCC from source, integrate a custom pass to analyze function clones, and test everything on the SPO600 AArch64 server. Setting Up the Environment 1. Cloning the Source Code The first step was to clone the GCC source code into my home directory. Thankfully, the repository was straightforward to access: git clone git://gcc.gnu.org/git/gcc.git ~/gcc-src Once the clone was complete, I checked for the configure script in ~/gcc-src , which confirmed that the source was ready for building. 2. Preparing the Build I created separate directories to keep everything organized: one for building GCC and another for installing it locally: mkdir ~/gcc-build ~/gcc-install 3. Adding the Demo Pass To save time, I copied and extracted the demo files provided in /public/spo600-gcc-pass-demo.tgz into ...

Project Stage 2 (Part 1): Troubleshooting SSH Key Issues for Server Access

Introduction As part of my SPO600 course, I recently encountered an issue accessing a server due to problems with my SSH authentication. This experience was both a learning opportunity and a chance to understand the importance of managing SSH keys effectively. In this blog, I’ll walk you through the problem, how I identified the issue, and the steps I took to resolve it. The Problem The trouble began when I attempted to log into the SPO600 server using SSH: ssh tnguyen279@x86-001.spo600.cdot.systems Instead of connecting, I was greeted with the dreaded message: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). This error indicated that the server couldn’t authenticate me, likely because my SSH key or password was incorrect. Identifying the Root Cause To diagnose the issue, I used the verbose mode of SSH: ssh -vvv tnguyen279@x86-001.spo600.cdot.systems The debug output revealed that: My SSH client was trying to use my private key, but authentication fai...