From 044eb2f6afba375a914ac9d8024f8f5142bb912e Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 18 Dec 2017 20:10:56 +0000 Subject: Vendor import of llvm trunk r321017: https://llvm.org/svn/llvm-project/llvm/trunk@321017 --- lib/CodeGen/ShadowStackGCLowering.cpp | 43 ++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'lib/CodeGen/ShadowStackGCLowering.cpp') diff --git a/lib/CodeGen/ShadowStackGCLowering.cpp b/lib/CodeGen/ShadowStackGCLowering.cpp index 7b60d22c7ace..25d405bf63de 100644 --- a/lib/CodeGen/ShadowStackGCLowering.cpp +++ b/lib/CodeGen/ShadowStackGCLowering.cpp @@ -1,4 +1,4 @@ -//===-- ShadowStackGCLowering.cpp - Custom lowering for shadow-stack gc ---===// +//===- ShadowStackGCLowering.cpp - Custom lowering for shadow-stack gc ----===// // // The LLVM Compiler Infrastructure // @@ -16,14 +16,31 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/CodeGen/GCStrategy.h" #include "llvm/CodeGen/Passes.h" -#include "llvm/IR/CallSite.h" +#include "llvm/IR/BasicBlock.h" +#include "llvm/IR/Constant.h" +#include "llvm/IR/Constants.h" +#include "llvm/IR/DerivedTypes.h" +#include "llvm/IR/Function.h" +#include "llvm/IR/GlobalValue.h" +#include "llvm/IR/GlobalVariable.h" #include "llvm/IR/IRBuilder.h" +#include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" +#include "llvm/IR/Intrinsics.h" #include "llvm/IR/Module.h" +#include "llvm/IR/Type.h" +#include "llvm/IR/Value.h" +#include "llvm/Pass.h" +#include "llvm/Support/Casting.h" #include "llvm/Transforms/Utils/EscapeEnumerator.h" +#include +#include +#include +#include +#include using namespace llvm; @@ -34,12 +51,11 @@ namespace { class ShadowStackGCLowering : public FunctionPass { /// RootChain - This is the global linked-list that contains the chain of GC /// roots. - GlobalVariable *Head; + GlobalVariable *Head = nullptr; /// StackEntryTy - Abstract type of a link in the shadow stack. - /// - StructType *StackEntryTy; - StructType *FrameMapTy; + StructType *StackEntryTy = nullptr; + StructType *FrameMapTy = nullptr; /// Roots - GC roots in the current function. Each is a pair of the /// intrinsic call and its corresponding alloca. @@ -47,6 +63,7 @@ class ShadowStackGCLowering : public FunctionPass { public: static char ID; + ShadowStackGCLowering(); bool doInitialization(Module &M) override; @@ -57,6 +74,7 @@ private: Constant *GetFrameMap(Function &F); Type *GetConcreteStackEntryType(Function &F); void CollectRoots(Function &F); + static GetElementPtrInst *CreateGEP(LLVMContext &Context, IRBuilder<> &B, Type *Ty, Value *BasePtr, int Idx1, const char *Name); @@ -64,7 +82,10 @@ private: Type *Ty, Value *BasePtr, int Idx1, int Idx2, const char *Name); }; -} + +} // end anonymous namespace + +char ShadowStackGCLowering::ID = 0; INITIALIZE_PASS_BEGIN(ShadowStackGCLowering, DEBUG_TYPE, "Shadow Stack GC Lowering", false, false) @@ -74,11 +95,7 @@ INITIALIZE_PASS_END(ShadowStackGCLowering, DEBUG_TYPE, FunctionPass *llvm::createShadowStackGCLoweringPass() { return new ShadowStackGCLowering(); } -char ShadowStackGCLowering::ID = 0; - -ShadowStackGCLowering::ShadowStackGCLowering() - : FunctionPass(ID), Head(nullptr), StackEntryTy(nullptr), - FrameMapTy(nullptr) { +ShadowStackGCLowering::ShadowStackGCLowering() : FunctionPass(ID) { initializeShadowStackGCLoweringPass(*PassRegistry::getPassRegistry()); } -- cgit v1.3