Skip to content

Commit

Permalink
Fix crash in dominator tree construction used by DiagnoseRaytracingPa…
Browse files Browse the repository at this point in the history
…yloadAccess (microsoft#5605)

Fix crash if a RayGen shader contains a `while(true)` loop, caused by
dominator tree construction not ignoring `nullptr` successor AST nodes
which occur in this case.

Also add regression test case.

Fixes microsoft#5035.

Co-authored-by: Jannik Silvanus <[email protected]>
  • Loading branch information
jasilvanus and jasilvanus authored Feb 21, 2024
1 parent 22bb078 commit 16d43a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/llvm/Support/GenericDomTreeConstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ unsigned DFSPass(DominatorTreeBase<typename GraphT::NodeType>& DT,
// Visit the successor next, if it isn't already visited.
typename GraphT::NodeType* Succ = *NextSucc;

// For clang, CFG successors can be optimized-out nullptrs. Skip those.
if (!Succ)
continue;

typename DominatorTreeBase<typename GraphT::NodeType>::InfoRec &SuccVInfo =
DT.Info[Succ];
if (SuccVInfo.Semi == 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %dxc -E RayGen -T lib_6_7 %s | FileCheck %s

// Regression test for crashing in DiagnoseRaytracingPayloadAccess
// due to a trivial while(true) loop.

// CHECK: define void @"\01?RayGen@@YAXXZ"()
[shader("raygeneration")] void RayGen() {
while (true) {
break;
}
}

0 comments on commit 16d43a5

Please sign in to comment.