|
45 | 45 | // is shown as C code for easy comprehension.
|
46 | 46 |
|
47 | 47 | #include "llvm/Transforms/Yk/ControlPoint.h"
|
| 48 | +#include "llvm/Analysis/LoopInfo.h" |
48 | 49 | #include "llvm/IR/BasicBlock.h"
|
| 50 | +#include "llvm/IR/Dominators.h" |
49 | 51 | #include "llvm/IR/Function.h"
|
| 52 | +#include "llvm/IR/IRBuilder.h" |
50 | 53 | #include "llvm/IR/Instructions.h"
|
51 | 54 | #include "llvm/IR/Module.h"
|
| 55 | +#include "llvm/IR/Verifier.h" |
52 | 56 | #include "llvm/InitializePasses.h"
|
53 | 57 | #include "llvm/Pass.h"
|
54 |
| -#include <llvm/IR/Dominators.h> |
55 |
| -#include <llvm/IR/IRBuilder.h> |
56 |
| -#include <llvm/IR/Verifier.h> |
57 | 58 |
|
58 | 59 | #define DEBUG_TYPE "yk-control-point"
|
59 | 60 | #define JIT_STATE_PREFIX "jit-state: "
|
@@ -121,8 +122,18 @@ class YkControlPoint : public ModulePass {
|
121 | 122 | // Get function containing the control point.
|
122 | 123 | Function *Caller = OldCtrlPointCall->getFunction();
|
123 | 124 |
|
124 |
| - // Find all live variables just before the call to the control point. |
| 125 | + // Check that the control point is inside a loop. |
125 | 126 | DominatorTree DT(*Caller);
|
| 127 | + const LoopInfo Loops(DT); |
| 128 | + if (!std::any_of(Loops.begin(), Loops.end(), [OldCtrlPointCall](Loop *L) { |
| 129 | + return L->contains(OldCtrlPointCall); |
| 130 | + })) { |
| 131 | + ; |
| 132 | + Context.emitError("yk_control_point() must be called inside a loop."); |
| 133 | + return false; |
| 134 | + } |
| 135 | + |
| 136 | + // Find all live variables just before the call to the control point. |
126 | 137 | std::vector<Value *> LiveVals = getLiveVars(DT, OldCtrlPointCall);
|
127 | 138 | if (LiveVals.size() == 0) {
|
128 | 139 | Context.emitError(
|
|
0 commit comments