Skip to content

[LAB6] 313554033 #434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: 313554033
Choose a base branch
from
Open

Conversation

Chun-Ching-Hsu
Copy link

Description

SQLab/112-spring-software-testing#2

I implemented a custom LLVM pass that, at the very start of the compilation pipeline, rewrites both the argc and argv[1] values in the main function so that:

debug(48763) is injected immediately at the top of main.

I grab the argc and argv arguments from main’s entry block.

I build a global constant string "hayaku... motohayaku!" and then:

Store its pointer directly into the argv[1] slot (so that any subsequent printf(argv[1]) sees the new value).

Scan through every instruction, replacing any use of the original argc SSA value with the constant 48763.

I also locate all LoadInst operations loading argv[1] (using a stripped‐cast GEP check) and strcmp calls, and replace their operands or uses with my constant string pointer, then erase the old loads.

Finally, I register this pass via the registerPipelineStartEPCallback so it runs unconditionally on every build configuration (O0 through O2).

  • A clear title (name your PR "[LAB{lab_number}] {your_student_id}")
  • A meaningful message for PR, as well as its commits
  • From your specific branch (not main or other's branch) merging to your branch
  • Excluding any irrelevant files, such as binaries, text files, or dot files
  • Passing all CI (You should check it first to pass one of the validations in CI. However, you need to make sure your PR passes all CI after you submit it.)

@YingMuo YingMuo added the lab6 label May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants