Skip to content

Commit ae6729f

Browse files
vext01ptersilie
authored andcommitted
In debug builds, verify the IR after the control point pass.
Sometimes we were letting through invalid IR, which may or may not be detected at runtime. (Oddly `parseIR()` doesn't always detect invalid IR, even with assertions on!)
1 parent 976f2d0 commit ae6729f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

llvm/lib/Transforms/Yk/ControlPoint.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,14 @@ class YkControlPoint : public ModulePass {
376376
Builder.SetInsertPoint(BB);
377377
Builder.CreateCondBr(NewCtrlPointCallInst, ExitBB, ContBB);
378378

379-
// Generate new control point logic.
379+
#ifndef NDEBUG
380+
// Our pass runs after LLVM normally does its verify pass. In debug builds
381+
// we run it again to check that our pass is generating valid IR.
382+
if (verifyModule(M, &errs())) {
383+
Context.emitError("Control point pass generated invalid IR!");
384+
return false;
385+
}
386+
#endif
380387
return true;
381388
}
382389
};

0 commit comments

Comments
 (0)