mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-04 06:09:05 +00:00
9bb9615e1f
This option caused LowerInvoke to generate code using SJLJ-based exception handling, but there is no code left that interprets the jmp_buf stack that the resulting code maintained (llvm.sjljeh.jblist). This option has been obsolete for a while, and replaced by SjLjEHPrepare. This leaves the default behaviour of LowerInvoke, which is to convert invokes to calls. Differential Revision: http://llvm-reviews.chandlerc.com/D3136 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204388 91177308-0d34-0410-b5e6-96231b3b80d8
80 lines
2.8 KiB
C++
80 lines
2.8 KiB
C++
//===- LowerInvoke.cpp - Eliminate Invoke instructions --------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This transformation is designed for use by code generators which do not yet
|
|
// support stack unwinding. This pass converts 'invoke' instructions to 'call'
|
|
// instructions, so that any exception-handling 'landingpad' blocks become dead
|
|
// code (which can be removed by running the '-simplifycfg' pass afterwards).
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#define DEBUG_TYPE "lowerinvoke"
|
|
#include "llvm/Transforms/Scalar.h"
|
|
#include "llvm/ADT/SmallVector.h"
|
|
#include "llvm/ADT/Statistic.h"
|
|
#include "llvm/IR/Instructions.h"
|
|
#include "llvm/IR/LLVMContext.h"
|
|
#include "llvm/IR/Module.h"
|
|
#include "llvm/Pass.h"
|
|
#include "llvm/Support/CommandLine.h"
|
|
using namespace llvm;
|
|
|
|
STATISTIC(NumInvokes, "Number of invokes replaced");
|
|
|
|
namespace {
|
|
class LowerInvoke : public FunctionPass {
|
|
public:
|
|
static char ID; // Pass identification, replacement for typeid
|
|
explicit LowerInvoke() : FunctionPass(ID) {
|
|
initializeLowerInvokePass(*PassRegistry::getPassRegistry());
|
|
}
|
|
bool runOnFunction(Function &F) override;
|
|
};
|
|
}
|
|
|
|
char LowerInvoke::ID = 0;
|
|
INITIALIZE_PASS(LowerInvoke, "lowerinvoke",
|
|
"Lower invoke and unwind, for unwindless code generators",
|
|
false, false)
|
|
|
|
char &llvm::LowerInvokePassID = LowerInvoke::ID;
|
|
|
|
// Public Interface To the LowerInvoke pass.
|
|
FunctionPass *llvm::createLowerInvokePass() {
|
|
return new LowerInvoke();
|
|
}
|
|
|
|
bool LowerInvoke::runOnFunction(Function &F) {
|
|
bool Changed = false;
|
|
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
|
|
if (InvokeInst *II = dyn_cast<InvokeInst>(BB->getTerminator())) {
|
|
SmallVector<Value*,16> CallArgs(II->op_begin(), II->op_end() - 3);
|
|
// Insert a normal call instruction...
|
|
CallInst *NewCall = CallInst::Create(II->getCalledValue(),
|
|
CallArgs, "", II);
|
|
NewCall->takeName(II);
|
|
NewCall->setCallingConv(II->getCallingConv());
|
|
NewCall->setAttributes(II->getAttributes());
|
|
NewCall->setDebugLoc(II->getDebugLoc());
|
|
II->replaceAllUsesWith(NewCall);
|
|
|
|
// Insert an unconditional branch to the normal destination.
|
|
BranchInst::Create(II->getNormalDest(), II);
|
|
|
|
// Remove any PHI node entries from the exception destination.
|
|
II->getUnwindDest()->removePredecessor(BB);
|
|
|
|
// Remove the invoke instruction now.
|
|
BB->getInstList().erase(II);
|
|
|
|
++NumInvokes; Changed = true;
|
|
}
|
|
return Changed;
|
|
}
|