[X86] Cleanup the WinEHState pass

Remove unnecessary includes and class state.

No functional change intended.

llvm-svn: 259340
This commit is contained in:
David Majnemer 2016-02-01 04:28:59 +00:00
parent 0314e1e1ef
commit efb41741f2
1 changed files with 14 additions and 25 deletions

View File

@ -15,31 +15,22 @@
//===----------------------------------------------------------------------===//
#include "X86.h"
#include "llvm/Analysis/CFG.h"
#include "llvm/Analysis/EHPersonalities.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/WinEHFuncInfo.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Local.h"
using namespace llvm;
using namespace llvm::PatternMatch;
#define DEBUG_TYPE "winehstate"
namespace llvm { void initializeWinEHStatePassPass(PassRegistry &); }
namespace llvm {
void initializeWinEHStatePassPass(PassRegistry &);
}
namespace {
class WinEHStatePass : public FunctionPass {
@ -68,7 +59,7 @@ private:
void linkExceptionRegistration(IRBuilder<> &Builder, Function *Handler);
void unlinkExceptionRegistration(IRBuilder<> &Builder);
void addStateStores(Function &F, WinEHFuncInfo &FuncInfo);
void insertStateNumberStore(Value *ParentRegNode, Instruction *IP, int State);
void insertStateNumberStore(Instruction *IP, int State);
Value *emitEHLSDA(IRBuilder<> &Builder, Function *F);
@ -96,9 +87,6 @@ private:
/// fs:00 chain and the current state.
AllocaInst *RegNode = nullptr;
/// Struct type of RegNode. Used for GEPing.
Type *RegNodeTy = nullptr;
/// The index of the state field of RegNode.
int StateFieldIndex = ~0U;
@ -256,6 +244,9 @@ void WinEHStatePass::emitExceptionRegistrationRecord(Function *F) {
assert(Personality == EHPersonality::MSVC_CXX ||
Personality == EHPersonality::MSVC_X86SEH);
// Struct type of RegNode. Used for GEPing.
Type *RegNodeTy;
StringRef PersonalityName = PersonalityFn->getName();
IRBuilder<> Builder(&F->getEntryBlock(), F->getEntryBlock().begin());
Type *Int8PtrType = Builder.getInt8PtrTy();
@ -268,7 +259,7 @@ void WinEHStatePass::emitExceptionRegistrationRecord(Function *F) {
Builder.CreateStore(SP, Builder.CreateStructGEP(RegNodeTy, RegNode, 0));
// TryLevel = -1
StateFieldIndex = 2;
insertStateNumberStore(RegNode, &*Builder.GetInsertPoint(), -1);
insertStateNumberStore(&*Builder.GetInsertPoint(), -1);
// Handler = __ehhandler$F
Function *Trampoline = generateLSDAInEAXThunk(F);
Link = Builder.CreateStructGEP(RegNodeTy, RegNode, 1);
@ -285,8 +276,7 @@ void WinEHStatePass::emitExceptionRegistrationRecord(Function *F) {
Builder.CreateStore(SP, Builder.CreateStructGEP(RegNodeTy, RegNode, 0));
// TryLevel = -2 / -1
StateFieldIndex = 4;
insertStateNumberStore(RegNode, &*Builder.GetInsertPoint(),
UseStackGuard ? -2 : -1);
insertStateNumberStore(&*Builder.GetInsertPoint(), UseStackGuard ? -2 : -1);
// ScopeTable = llvm.x86.seh.lsda(F)
Value *FI8 = Builder.CreateBitCast(F, Int8PtrType);
Value *LSDA = Builder.CreateCall(
@ -440,21 +430,20 @@ void WinEHStatePass::addStateStores(Function &F, WinEHFuncInfo &FuncInfo) {
// an unwind. Ensure they are in the -1 state.
if (CI->doesNotThrow())
continue;
insertStateNumberStore(RegNode, CI, BaseState);
insertStateNumberStore(CI, BaseState);
} else if (auto *II = dyn_cast<InvokeInst>(&I)) {
// Look up the state number of the landingpad this unwinds to.
assert(FuncInfo.InvokeStateMap.count(II) && "invoke has no state!");
int State = FuncInfo.InvokeStateMap[II];
insertStateNumberStore(RegNode, II, State);
insertStateNumberStore(II, State);
}
}
}
}
void WinEHStatePass::insertStateNumberStore(Value *ParentRegNode,
Instruction *IP, int State) {
void WinEHStatePass::insertStateNumberStore(Instruction *IP, int State) {
IRBuilder<> Builder(IP);
Value *StateField =
Builder.CreateStructGEP(RegNodeTy, ParentRegNode, StateFieldIndex);
Builder.CreateStructGEP(nullptr, RegNode, StateFieldIndex);
Builder.CreateStore(Builder.getInt32(State), StateField);
}