Skip to content

Conversation

@River41
Copy link
Collaborator

@River41 River41 commented Jan 26, 2026

Refs #29

@River41 River41 requested a review from h313 January 26, 2026 03:23
@River41
Copy link
Collaborator Author

River41 commented Jan 28, 2026

I've refined the logic to ensure the partitioning correctly handles nested control flow structures. To verify this, I tested the CFG construction against matmul.o, which contains nested loops. I also integrated Mermaid into the output to visualize the resulting graph.
截屏2026-01-28 14 39 58


While verifying the partitioning logic, I noticed some unreachable instructions in the test files. For example, in kalman.o, instruction 47 (79 a1 a8 ff...) appears to be dead code:

  • Line 46 is 05 00 17 00 00 00 00 00 (ja +23), which jumps to Line 70 ($46 + 23 + 1$).
  • Line 13 is 05 00 22 00 00 00 00 00 (ja +34), which jumps to Line 48.
  • No other lines jump to line 47.

Is this kind of unreachable code common?

@h313
Copy link
Contributor

h313 commented Jan 28, 2026

Yes, we can safely ignore unreachable code. This seems to be more of an issue with the Clang output making things weird and forgetting to remove unused code.

@River41
Copy link
Collaborator Author

River41 commented Jan 29, 2026

Additionally, here are the reasons why this algorithm can handle nested loops.

  • Leader Identification: During the pre-scan phase, the algorithm marks all jump targets as Leaders. In the case of nested loops, both inner and outer loop entry points are identified, ensuring each loop starts as a distinct Basic Block.
  • Recursive Exploration: The recursive structure allows the algorithm to follow Jump Edges deep into the control flow. When encountering nested loops, it fully processes all inner loop paths before returning to resolve the remaining execution paths of the outer loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants