Bài đăng

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...

Project Stage 1: Building and Exploring GCC on AArch64: A Deep Dive into the Build Process and Compilation Dumps

  Introduction The goal of this blog is to document my process of building the current development version of GCC on an AArch64 platform, with a particular emphasis on understanding the compilation stages via intermediate representation (IR) dumps. This journey has given me valuable insights into the GCC build system, compilation passes, and optimisation techniques. Section 1: Preparing the Environment for GCC Build Objective : Set up the necessary environment and dependencies to build GCC from source on an AArch64 platform. Steps and Detailed Commands Install Essential Dependencies : To ensure a successful build, I installed essential libraries and tools required by GCC: sudo apt update sudo apt install build-essential libgmp-dev libmpfr-dev libmpc-dev git texinfo bison flex Each library supports a specific function: GMP : For arbitrary precision arithmetic. MPFR : For floating-point computations with precise control. MPC : For complex number arithmetic. Having these dependencies ...

SPO600 - Lab 3: 6502 Program Lab: Inches to Feet Converter

Hình ảnh
 In this lab, I used the 6502 assembly language to build a simple inches-to-foot converter. This project allowed me to experiment with arithmetic operations, keyboard input handling, and direct screen output without relying on ROM routines. This hands-on experience also helped me prepare for more advanced assembly languages like x86_64 and AArch64. Resources During the lab, I used a variety of resources, including: 6502 documentation provides detailed information about the 6502 architecture and instruction set. 6502 Emulator: For testing and debugging code. 6502 Math and Procedures: A reference book for arithmetic operations and control flow. Sample code demonstrates graphical output and keyboard input handling. Project Concept My project is a simple calculator that converts a specified number of inches to feet. In this program, the user enters an inch number, and when they press Enter, the program calculates and displays the corresponding number of feet. This simple conversion nec...

SP600 - Lab 2: 6502 Math Lab

Hình ảnh
In this post, I'll go into the world of 6502 assembly language, which is one of the most fundamental low-level languages in computing. This lab focusses on using assembly to control the movement of a simple graphic on a bitmapped display, simulating basic animation with a set of programmed instructions. The goal of this lab is to create a graphic that moves across the screen and "bounces" off the edges, changing direction whenever it encounters a boundary. As part of the lab, I used the 6502 emulator to write and test the assembly code, as well as experiment with various movement increments and behaviours. This project provides an introduction to low-level programming concepts that are required for understanding more complex architectures such as x86_64 and AArch64. Set Up 1. I haved open the 6502 Emulator. Initial Code 2. Then copied and pasted for the code  ; ; draw-image-subroutine.6502 ; ; This is a routine that can place an arbitrary ; rectangular image on to the sc...