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