Skip to content

Commit 1b29b69

Browse files
committed
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 7fcca27 commit 1b29b69

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
@@ -257,7 +257,14 @@ class YkControlPoint : public ModulePass {
257257
Builder.SetInsertPoint(BB);
258258
Builder.CreateCondBr(NewCtrlPointCallInst, ExitBB, ContBB);
259259

260-
// Generate new control point logic.
260+
#ifndef NDEBUG
261+
// Our pass runs after LLVM normally does its verify pass. In debug builds
262+
// we run it again to check that our pass is generating valid IR.
263+
if (verifyModule(M, &errs())) {
264+
Context.emitError("Control point pass generated invalid IR!");
265+
return false;
266+
}
267+
#endif
261268
return true;
262269
}
263270
};

0 commit comments

Comments
 (0)