Skip to content

Commit d32ff9f

Browse files
committed
Implement rudimentary trace stitching.
Currently when JITted code runs an iteration of a user loop, we unconditionally fall back to the interpreter afterwards. This change makes the control point call the JITted code repeatedly so that consecutive iterations of a user loop can run JITted code. This is could (and should) be more performant. See: ykjit/yk#442
1 parent 0ee4d69 commit d32ff9f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

llvm/lib/Transforms/Yk/ControlPoint.cpp

+8-7
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@
6363
// value that indicates if we should start/stop tracing, or jump to machine
6464
// code etc.
6565
//
66-
// - Because we haven't yet implemented guards or trace stitching, a machine
67-
// code trace will always return to the interpreter after one full run of
68-
// the traced interpreter loop. This means that the JIT doesn't yet
69-
// correctly implement the right program semantics. When we have trace
70-
// stitching, a machine code trace will only return upon a guard failure.
66+
// - Guards are currently assumed to abort the program.
67+
// https://github.com/ykjit/yk/issues/443
7168
//
69+
// - The block that performs the call to JITted code branches back to itself
70+
// to achieve rudimentary trace stitching. The looping should really be
71+
// implemented in the JITted code itself so that it isn't necessary to
72+
// repeatedly enter and exit the JITted code.
73+
// https://github.com/ykjit/yk/issues/442
7274
//===----------------------------------------------------------------------===//
7375

7476
#include "llvm/Transforms/Yk/ControlPoint.h"
@@ -214,7 +216,7 @@ void createControlPoint(Module &Mod, Function *F, std::vector<Value *> LiveVars,
214216
CallInst *CTResult = Builder.CreateCall(FType, CastTrace, F->getArg(1));
215217
createJITStatePrint(Builder, &Mod, "exit-jit-code");
216218
CTResult->setTailCall(true);
217-
Builder.CreateBr(BBReturn);
219+
Builder.CreateBr(BBExecuteTrace);
218220

219221
// Create block that decides when to stop tracing.
220222
Builder.SetInsertPoint(BBTracing);
@@ -243,7 +245,6 @@ void createControlPoint(Module &Mod, Function *F, std::vector<Value *> LiveVars,
243245
Value *YkCtrlPointVars = F->getArg(1);
244246
PHINode *Phi = Builder.CreatePHI(YkCtrlPointStruct, 3);
245247
Phi->addIncoming(YkCtrlPointVars, BBHasTrace);
246-
Phi->addIncoming(CTResult, BBExecuteTrace);
247248
Phi->addIncoming(YkCtrlPointVars, BBTracing);
248249
Phi->addIncoming(YkCtrlPointVars, BBHasNoTrace);
249250
Phi->addIncoming(YkCtrlPointVars, BBStopTracing);

0 commit comments

Comments
 (0)