Skip to content

[PIX] Instrument DebugBreak() calls for PIX#8349

Open
henchhinglimbu wants to merge 2 commits intomicrosoft:mainfrom
henchhinglimbu:pix-debugbreak-hit-instrumentation
Open

[PIX] Instrument DebugBreak() calls for PIX#8349
henchhinglimbu wants to merge 2 commits intomicrosoft:mainfrom
henchhinglimbu:pix-debugbreak-hit-instrumentation

Conversation

@henchhinglimbu
Copy link
Copy Markdown

@henchhinglimbu henchhinglimbu commented Apr 7, 2026

Changes:

  • Add a PIX DXIL pass that replaces DebugBreak() calls with UAV atomic writes so PIX can detect hit locations without halting execution.
  • Wire the new pass into pass registration and the build.
  • Add unit tests and FileCheck coverage for basic, no DebugBreak(), and multiple DebugBreak() cases.

Testing:

  • Built dxcompiler, ClangHLSLTests, and check-all
  • check-all passed locally

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

✅ With the latest revision this PR passed the C/C++ code formatter.

@henchhinglimbu
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Microsoft"

@henchhinglimbu henchhinglimbu marked this pull request as ready for review April 8, 2026 19:53
Copy link
Copy Markdown
Collaborator

@jeffnn jeffnn left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Member

@damyanp damyanp left a comment

Choose a reason for hiding this comment

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

Some comments / questions...

Comment on lines +60 to +64
for (auto UI = DebugBreakFunc->use_begin();
UI != DebugBreakFunc->use_end();) {
auto &Use = *UI++;
DebugBreakCalls.push_back(cast<CallInst>(Use.getUser()));
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have a few issues with this loop (excessive autos, not storing the "end" iterator, unnecessary *UI++ pattern when it's all const).

Would something like this work instead (untested suggestion)?

Suggested change
for (auto UI = DebugBreakFunc->use_begin();
UI != DebugBreakFunc->use_end();) {
auto &Use = *UI++;
DebugBreakCalls.push_back(cast<CallInst>(Use.getUser()));
}
for (const Use &U: DebugBreakFunc->uses())
DebugBreakCalls.push_back(cast<CallInst>(U.getUser()));

Comment on lines +67 to +70
if (!PixUAVResource) {
PixUAVResource =
PIXPassHelpers::CreateGlobalUAVResource(DM, 0, "PixUAVResource");
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (!PixUAVResource) {
PixUAVResource =
PIXPassHelpers::CreateGlobalUAVResource(DM, 0, "PixUAVResource");
}
if (!PixUAVResource)
PixUAVResource =
PIXPassHelpers::CreateGlobalUAVResource(DM, 0, "PixUAVResource");

LLVM coding conventions omit braces for single statement bodies.


uint32_t InstructionNumber = 0;
if (!pix_dxil::PixDxilInstNum::FromInst(CI, &InstructionNumber)) {
DXASSERT_NOMSG(false);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What does it mean if this assert fires?


// Remove the now-unused dx.op.debugBreak function declaration so the
// DebugBreak operation is fully eliminated from the module.
if (DebugBreakFunc->use_empty())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If there are still uses of this, does this mean that something actually went wrong with our attempt to remove all uses? Is this something we'd want to know about via an assert or failure condition/

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

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

3 participants