File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 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"
49
50
#include " llvm/IR/Function.h"
50
51
#include " llvm/IR/Instructions.h"
@@ -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 (
You can’t perform that action at this time.
0 commit comments