Skip to content

Commit b857755

Browse files
authored
Merge pull request rust-lang#180 from ptersilie/frameaddr_notlive
Fold stackmaps into control point during lowering.
2 parents 811ea90 + 4ceb7eb commit b857755

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

llvm/lib/Transforms/Yk/StackMaps.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "llvm/IR/Function.h"
1212
#include "llvm/IR/IRBuilder.h"
1313
#include "llvm/IR/Instructions.h"
14+
#include "llvm/IR/IntrinsicInst.h"
1415
#include "llvm/IR/Module.h"
1516
#include "llvm/IR/Verifier.h"
1617
#include "llvm/InitializePasses.h"
@@ -99,6 +100,16 @@ class YkStackmaps : public ModulePass {
99100
// the offset of the stackmap entry will record the instruction after
100101
// the call, which is where we want to continue after deoptimisation.
101102
Bldr.SetInsertPoint(I->getNextNode());
103+
CallInst &CI = cast<CallInst>(*I);
104+
if (!CI.isIndirectCall() &&
105+
CI.getCalledFunction()->getName() == YK_NEW_CONTROL_POINT) {
106+
assert(isa<IntrinsicInst>(Args.back()) &&
107+
cast<IntrinsicInst>(Args.back())->getIntrinsicID() ==
108+
Intrinsic::frameaddress);
109+
// Remove the last live argument which is the frameaddr which we have
110+
// no use for and is difficult to remove during tracing.
111+
Args.pop_back();
112+
}
102113
}
103114
Bldr.CreateCall(SMFunc->getFunctionType(), SMFunc,
104115
ArrayRef<Value *>(Args));

llvm/lib/YkIR/YkIRWriter.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//
55
//===-------------------------------------------------------------------===//
66

7+
#include "llvm/Analysis/ConstantFolding.h"
78
#include "llvm/BinaryFormat/ELF.h"
89
#include "llvm/IR/Constant.h"
910
#include "llvm/IR/Constants.h"
@@ -18,6 +19,7 @@
1819
#include "llvm/MC/MCSectionELF.h"
1920
#include "llvm/MC/MCStreamer.h"
2021
#include "llvm/Support/ErrorHandling.h"
22+
#include "llvm/Transforms/Yk/ControlPoint.h"
2123

2224
using namespace llvm;
2325
using namespace std;
@@ -693,7 +695,9 @@ class YkIRWriter {
693695
for (unsigned OI = 0; OI < I->arg_size(); OI++) {
694696
serialiseOperand(I, FLCtxt, I->getOperand(OI));
695697
}
696-
if (!I->getCalledFunction()->isDeclaration()) {
698+
bool IsCtrlPointCall =
699+
I->getCalledFunction()->getName() == YK_NEW_CONTROL_POINT;
700+
if (!I->getCalledFunction()->isDeclaration() || IsCtrlPointCall) {
697701
// The next instruction will be the stackmap entry
698702
// has_safepoint = 1:
699703
OutStreamer.emitInt8(1);

0 commit comments

Comments
 (0)