diff options
| author | 2020-08-03 15:06:44 +0000 | |
|---|---|---|
| committer | 2020-08-03 15:06:44 +0000 | |
| commit | b64793999546ed8adebaeebd9d8345d18db8927d (patch) | |
| tree | 4357c27b561d73b0e089727c6ed659f2ceff5f47 /gnu/llvm/lib/Transforms/IPO/ElimAvailExtern.cpp | |
| parent | Add support for UTF-8 DISPLAY-HINTs with octet length. For now only (diff) | |
| download | wireguard-openbsd-b64793999546ed8adebaeebd9d8345d18db8927d.tar.xz wireguard-openbsd-b64793999546ed8adebaeebd9d8345d18db8927d.zip | |
Remove LLVM 8.0.1 files.
Diffstat (limited to 'gnu/llvm/lib/Transforms/IPO/ElimAvailExtern.cpp')
| -rw-r--r-- | gnu/llvm/lib/Transforms/IPO/ElimAvailExtern.cpp | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/gnu/llvm/lib/Transforms/IPO/ElimAvailExtern.cpp b/gnu/llvm/lib/Transforms/IPO/ElimAvailExtern.cpp deleted file mode 100644 index d5fef59286d..00000000000 --- a/gnu/llvm/lib/Transforms/IPO/ElimAvailExtern.cpp +++ /dev/null @@ -1,102 +0,0 @@ -//===- ElimAvailExtern.cpp - DCE unreachable internal functions -----------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This transform is designed to eliminate available external global -// definitions from the program, turning them into declarations. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Transforms/IPO/ElimAvailExtern.h" -#include "llvm/ADT/Statistic.h" -#include "llvm/IR/Constant.h" -#include "llvm/IR/Function.h" -#include "llvm/IR/GlobalValue.h" -#include "llvm/IR/GlobalVariable.h" -#include "llvm/IR/Module.h" -#include "llvm/Pass.h" -#include "llvm/Transforms/IPO.h" -#include "llvm/Transforms/Utils/GlobalStatus.h" - -using namespace llvm; - -#define DEBUG_TYPE "elim-avail-extern" - -STATISTIC(NumFunctions, "Number of functions removed"); -STATISTIC(NumVariables, "Number of global variables removed"); - -static bool eliminateAvailableExternally(Module &M) { - bool Changed = false; - - // Drop initializers of available externally global variables. - for (GlobalVariable &GV : M.globals()) { - if (!GV.hasAvailableExternallyLinkage()) - continue; - if (GV.hasInitializer()) { - Constant *Init = GV.getInitializer(); - GV.setInitializer(nullptr); - if (isSafeToDestroyConstant(Init)) - Init->destroyConstant(); - } - GV.removeDeadConstantUsers(); - GV.setLinkage(GlobalValue::ExternalLinkage); - NumVariables++; - Changed = true; - } - - // Drop the bodies of available externally functions. - for (Function &F : M) { - if (!F.hasAvailableExternallyLinkage()) - continue; - if (!F.isDeclaration()) - // This will set the linkage to external - F.deleteBody(); - F.removeDeadConstantUsers(); - NumFunctions++; - Changed = true; - } - - return Changed; -} - -PreservedAnalyses -EliminateAvailableExternallyPass::run(Module &M, ModuleAnalysisManager &) { - if (!eliminateAvailableExternally(M)) - return PreservedAnalyses::all(); - return PreservedAnalyses::none(); -} - -namespace { - -struct EliminateAvailableExternallyLegacyPass : public ModulePass { - static char ID; // Pass identification, replacement for typeid - - EliminateAvailableExternallyLegacyPass() : ModulePass(ID) { - initializeEliminateAvailableExternallyLegacyPassPass( - *PassRegistry::getPassRegistry()); - } - - // run - Do the EliminateAvailableExternally pass on the specified module, - // optionally updating the specified callgraph to reflect the changes. - bool runOnModule(Module &M) override { - if (skipModule(M)) - return false; - return eliminateAvailableExternally(M); - } -}; - -} // end anonymous namespace - -char EliminateAvailableExternallyLegacyPass::ID = 0; - -INITIALIZE_PASS(EliminateAvailableExternallyLegacyPass, "elim-avail-extern", - "Eliminate Available Externally Globals", false, false) - -ModulePass *llvm::createEliminateAvailableExternallyPass() { - return new EliminateAvailableExternallyLegacyPass(); -} |
