mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Eliminate some temporaries.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85896 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
674fdc9a28
commit
419e44edab
@ -47,9 +47,6 @@
|
||||
#include "llvm/Transforms/Utils/Local.h"
|
||||
#include "llvm/ADT/DepthFirstIterator.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/VectorExtras.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include <map>
|
||||
using namespace llvm;
|
||||
|
||||
@ -108,7 +105,7 @@ namespace {
|
||||
void TransformLongJmpCall(CallInst* Inst);
|
||||
void TransformSetJmpCall(CallInst* Inst);
|
||||
|
||||
bool IsTransformableFunction(const std::string& Name);
|
||||
bool IsTransformableFunction(StringRef Name);
|
||||
public:
|
||||
static char ID; // Pass identification, replacement for typeid
|
||||
LowerSetJmp() : ModulePass(&ID) {}
|
||||
@ -249,13 +246,8 @@ bool LowerSetJmp::doInitialization(Module& M)
|
||||
// "llvm.{setjmp,longjmp}" functions and none of the setjmp/longjmp error
|
||||
// handling functions (beginning with __llvm_sjljeh_...they don't throw
|
||||
// exceptions).
|
||||
bool LowerSetJmp::IsTransformableFunction(const std::string& Name) {
|
||||
std::string SJLJEh("__llvm_sjljeh");
|
||||
|
||||
if (Name.size() > SJLJEh.size())
|
||||
return std::string(Name.begin(), Name.begin() + SJLJEh.size()) != SJLJEh;
|
||||
|
||||
return true;
|
||||
bool LowerSetJmp::IsTransformableFunction(StringRef Name) {
|
||||
return !Name.startswith("__llvm_sjljeh_");
|
||||
}
|
||||
|
||||
// TransformLongJmpCall - Transform a longjmp call into a call to the
|
||||
@ -263,8 +255,7 @@ bool LowerSetJmp::IsTransformableFunction(const std::string& Name) {
|
||||
// throwing the exception for us.
|
||||
void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
|
||||
{
|
||||
const Type* SBPTy =
|
||||
Type::getInt8PtrTy(Inst->getContext());
|
||||
const Type* SBPTy = Type::getInt8PtrTy(Inst->getContext());
|
||||
|
||||
// Create the call to "__llvm_sjljeh_throw_longjmp". This takes the
|
||||
// same parameters as "longjmp", except that the buffer is cast to a
|
||||
@ -272,10 +263,8 @@ void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
|
||||
// Inst's uses and doesn't get a name.
|
||||
CastInst* CI =
|
||||
new BitCastInst(Inst->getOperand(1), SBPTy, "LJBuf", Inst);
|
||||
SmallVector<Value *, 2> Args;
|
||||
Args.push_back(CI);
|
||||
Args.push_back(Inst->getOperand(2));
|
||||
CallInst::Create(ThrowLongJmp, Args.begin(), Args.end(), "", Inst);
|
||||
Value *Args[] = { CI, Inst->getOperand(2) };
|
||||
CallInst::Create(ThrowLongJmp, Args, Args + 2, "", Inst);
|
||||
|
||||
SwitchValuePair& SVP = SwitchValMap[Inst->getParent()->getParent()];
|
||||
|
||||
@ -390,11 +379,11 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst)
|
||||
Type::getInt8PtrTy(Inst->getContext());
|
||||
CastInst* BufPtr =
|
||||
new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst);
|
||||
std::vector<Value*> Args =
|
||||
make_vector<Value*>(GetSetJmpMap(Func), BufPtr,
|
||||
ConstantInt::get(Type::getInt32Ty(Inst->getContext()),
|
||||
SetJmpIDMap[Func]++), 0);
|
||||
CallInst::Create(AddSJToMap, Args.begin(), Args.end(), "", Inst);
|
||||
Value *Args[] = {
|
||||
GetSetJmpMap(Func), BufPtr,
|
||||
ConstantInt::get(Type::getInt32Ty(Inst->getContext()), SetJmpIDMap[Func]++)
|
||||
};
|
||||
CallInst::Create(AddSJToMap, Args, Args + 3, "", Inst);
|
||||
|
||||
// We are guaranteed that there are no values live across basic blocks
|
||||
// (because we are "not in SSA form" yet), but there can still be values live
|
||||
|
Loading…
Reference in New Issue
Block a user