#include "NVPTXCtorDtorLowering.h"
#include "MCTargetDesc/NVPTXBaseInfo.h"
#include "NVPTX.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Value.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/MD5.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
usingnamespacellvm;
#define DEBUG_TYPE …
static cl::opt<std::string>
GlobalStr("nvptx-lower-global-ctor-dtor-id",
cl::desc("Override unique ID of ctor/dtor globals."),
cl::init(""), cl::Hidden);
static cl::opt<bool>
CreateKernels("nvptx-emit-init-fini-kernel",
cl::desc("Emit kernels to call ctor/dtor globals."),
cl::init(true), cl::Hidden);
namespace {
static std::string getHash(StringRef Str) { … }
static void addKernelMetadata(Module &M, GlobalValue *GV) { … }
static Function *createInitOrFiniKernelFunction(Module &M, bool IsCtor) { … }
static void createInitOrFiniCalls(Function &F, bool IsCtor) { … }
static bool createInitOrFiniGlobals(Module &M, GlobalVariable *GV,
bool IsCtor) { … }
static bool createInitOrFiniKernel(Module &M, StringRef GlobalName,
bool IsCtor) { … }
static bool lowerCtorsAndDtors(Module &M) { … }
class NVPTXCtorDtorLoweringLegacy final : public ModulePass { … };
}
PreservedAnalyses NVPTXCtorDtorLoweringPass::run(Module &M,
ModuleAnalysisManager &AM) { … }
char NVPTXCtorDtorLoweringLegacy::ID = …;
char &llvm::NVPTXCtorDtorLoweringLegacyPassID = …;
INITIALIZE_PASS(…)
ModulePass *llvm::createNVPTXCtorDtorLoweringLegacyPass() { … }