Skip to content

Commit

Permalink
Merge pull request llvm#180 from ptersilie/frameaddr_notlive
Browse files Browse the repository at this point in the history
Fold stackmaps into control point during lowering.
  • Loading branch information
ltratt authored Jul 5, 2024
2 parents 811ea90 + 4ceb7eb commit b857755
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions llvm/lib/Transforms/Yk/StackMaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Verifier.h"
#include "llvm/InitializePasses.h"
Expand Down Expand Up @@ -99,6 +100,16 @@ class YkStackmaps : public ModulePass {
// the offset of the stackmap entry will record the instruction after
// the call, which is where we want to continue after deoptimisation.
Bldr.SetInsertPoint(I->getNextNode());
CallInst &CI = cast<CallInst>(*I);
if (!CI.isIndirectCall() &&
CI.getCalledFunction()->getName() == YK_NEW_CONTROL_POINT) {
assert(isa<IntrinsicInst>(Args.back()) &&
cast<IntrinsicInst>(Args.back())->getIntrinsicID() ==
Intrinsic::frameaddress);
// Remove the last live argument which is the frameaddr which we have
// no use for and is difficult to remove during tracing.
Args.pop_back();
}
}
Bldr.CreateCall(SMFunc->getFunctionType(), SMFunc,
ArrayRef<Value *>(Args));
Expand Down
6 changes: 5 additions & 1 deletion llvm/lib/YkIR/YkIRWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//
//===-------------------------------------------------------------------===//

#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
Expand All @@ -18,6 +19,7 @@
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Transforms/Yk/ControlPoint.h"

using namespace llvm;
using namespace std;
Expand Down Expand Up @@ -693,7 +695,9 @@ class YkIRWriter {
for (unsigned OI = 0; OI < I->arg_size(); OI++) {
serialiseOperand(I, FLCtxt, I->getOperand(OI));
}
if (!I->getCalledFunction()->isDeclaration()) {
bool IsCtrlPointCall =
I->getCalledFunction()->getName() == YK_NEW_CONTROL_POINT;
if (!I->getCalledFunction()->isDeclaration() || IsCtrlPointCall) {
// The next instruction will be the stackmap entry
// has_safepoint = 1:
OutStreamer.emitInt8(1);
Expand Down

0 comments on commit b857755

Please sign in to comment.