Skip to content

Letstmt analysis bug fix#6

Merged
silentCoder-dev merged 1 commit into
silentCoder-dev:auto-schedulefrom
Denverjin:auto-schedule
Apr 1, 2026
Merged

Letstmt analysis bug fix#6
silentCoder-dev merged 1 commit into
silentCoder-dev:auto-schedulefrom
Denverjin:auto-schedule

Conversation

@Denverjin

@Denverjin Denverjin commented Apr 1, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

Release Notes

  • Refactor
    • Updated internal memory management in the scheduling system to enhance consistency and safety during recursive IR structure operations.

@coderabbitai

coderabbitai Bot commented Apr 1, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

ScheduleUnitBuilder refactored to use std::shared_ptr<IRStructure> references instead of raw pointers during recursive scheduling operations. The Build method and ScheduleRecursive function now accept and pass shared_ptr references, with appropriate conversions for type casts and node rebinding. Task gathering expanded to include both wrapper task and child elements.

Changes

Cohort / File(s) Summary
Smart Pointer Refactoring
src/transform/auto_schedule.cc
Updated ScheduleUnitBuilder to accept std::shared_ptr<IRStructure> references in Build and ScheduleRecursive instead of raw pointers. Recursion calls now pass shared_ptr references; node handling uses pointer dereferencing for casts while preserving rebinding capability. Task gathering expanded to include both wrapper->task and wrapper->child. AutoSchedule pass updated to pass shared_ptr directly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 With pointers shared, not raw and bare,
Our trees now dance with loving care,
Each node rebound with grace and might,
The memory flows just right, just right!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'Letstmt analysis bug fix' does not align with the actual changes, which involve refactoring ScheduleUnitBuilder to use shared_ptr references in the auto_schedule.cc file. Update the title to accurately reflect the main change, such as 'Refactor ScheduleUnitBuilder to use shared_ptr references' or 'Use shared_ptr instead of raw pointers in ScheduleUnitBuilder'.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/transform/auto_schedule.cc`:
- Line 1288: The call to GatherTaskNodes({wrapper->task, wrapper->child},
origin_children) can pass a null shared_ptr from WrapperNode::child and lead to
a crash; replace it with the wrapper-aware helper GatherTaskNodesSingle so null
children are handled safely (e.g., call GatherTaskNodesSingle(wrapper->task,
wrapper->child, origin_children)), and make the same replacement for the other
occurrence that mirrors this pattern (the second call around the later
occurrence).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: be73319b-5f2d-41c3-945d-2575636e0443

📥 Commits

Reviewing files that changed from the base of the PR and between 06c8e7e and a013c72.

📒 Files selected for processing (1)
  • src/transform/auto_schedule.cc

auto wrapper = static_cast<WrapperNode *>(ctrl->child.get());
std::vector<std::shared_ptr<IRStructure>> origin_children;
GatherTaskNodes({wrapper->child}, origin_children);
GatherTaskNodes({wrapper->task, wrapper->child}, origin_children);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Use the wrapper-aware gather helper here.

GatherTaskNodes assumes every input entry is non-null, but WrapperNode::child is optional in this file's builder (see Lines 1508-1511 and 1526-1529). Constructing {wrapper->task, wrapper->child} can therefore feed a null shared_ptr into GatherTaskNodes and crash on the first dereference. Reusing GatherTaskNodesSingle(...) keeps the existing wrapper/null handling intact.

🛠️ Suggested fix
-        GatherTaskNodes({wrapper->task, wrapper->child}, origin_children);
+        GatherTaskNodesSingle(ctrl->child, origin_children);
-    GatherTaskNodes({wrapper->task, wrapper->child}, origin_children);
+    GatherTaskNodesSingle(node, origin_children);

Also applies to: 1312-1312

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/transform/auto_schedule.cc` at line 1288, The call to
GatherTaskNodes({wrapper->task, wrapper->child}, origin_children) can pass a
null shared_ptr from WrapperNode::child and lead to a crash; replace it with the
wrapper-aware helper GatherTaskNodesSingle so null children are handled safely
(e.g., call GatherTaskNodesSingle(wrapper->task, wrapper->child,
origin_children)), and make the same replacement for the other occurrence that
mirrors this pattern (the second call around the later occurrence).

@silentCoder-dev silentCoder-dev merged commit d10b9dc into silentCoder-dev:auto-schedule Apr 1, 2026
4 checks passed
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.

2 participants