summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2009-10-23 15:58:05 +0000
committerrdivacky <rdivacky@FreeBSD.org>2009-10-23 15:58:05 +0000
commitd1f06de484602e72707476a6152974847bac1570 (patch)
tree8a2c83dce680f5d1994d39dfceb73e15836bf900 /lib
parentf2a8012c6ff5a46a00b389d1fb494e0df6798034 (diff)
downloadFreeBSD-src-d1f06de484602e72707476a6152974847bac1570.zip
FreeBSD-src-d1f06de484602e72707476a6152974847bac1570.tar.gz
This was removed upstream.
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/IPO/IndMemRemoval.cpp90
1 files changed, 0 insertions, 90 deletions
diff --git a/lib/Transforms/IPO/IndMemRemoval.cpp b/lib/Transforms/IPO/IndMemRemoval.cpp
deleted file mode 100644
index e7884ec..0000000
--- a/lib/Transforms/IPO/IndMemRemoval.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-//===-- IndMemRemoval.cpp - Remove indirect allocations and frees ---------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This pass finds places where memory allocation functions may escape into
-// indirect land. Some transforms are much easier (aka possible) only if free
-// or malloc are not called indirectly.
-// Thus find places where the address of memory functions are taken and
-// construct bounce functions with direct calls of those functions.
-//
-//===----------------------------------------------------------------------===//
-
-#define DEBUG_TYPE "indmemrem"
-#include "llvm/Transforms/IPO.h"
-#include "llvm/Pass.h"
-#include "llvm/Module.h"
-#include "llvm/Instructions.h"
-#include "llvm/Type.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/ADT/Statistic.h"
-#include "llvm/Support/Compiler.h"
-using namespace llvm;
-
-STATISTIC(NumBounceSites, "Number of sites modified");
-STATISTIC(NumBounce , "Number of bounce functions created");
-
-namespace {
- class VISIBILITY_HIDDEN IndMemRemPass : public ModulePass {
- public:
- static char ID; // Pass identification, replacement for typeid
- IndMemRemPass() : ModulePass(&ID) {}
-
- virtual bool runOnModule(Module &M);
- };
-} // end anonymous namespace
-
-char IndMemRemPass::ID = 0;
-static RegisterPass<IndMemRemPass>
-X("indmemrem","Indirect Malloc and Free Removal");
-
-bool IndMemRemPass::runOnModule(Module &M) {
- // In theory, all direct calls of malloc and free should be promoted
- // to intrinsics. Therefore, this goes through and finds where the
- // address of free or malloc are taken and replaces those with bounce
- // functions, ensuring that all malloc and free that might happen
- // happen through intrinsics.
- bool changed = false;
- if (Function* F = M.getFunction("free")) {
- if (F->isDeclaration() && F->arg_size() == 1 && !F->use_empty()) {
- Function* FN = Function::Create(F->getFunctionType(),
- GlobalValue::LinkOnceAnyLinkage,
- "free_llvm_bounce", &M);
- BasicBlock* bb = BasicBlock::Create(M.getContext(), "entry",FN);
- Instruction* R = ReturnInst::Create(M.getContext(), bb);
- new FreeInst(FN->arg_begin(), R);
- ++NumBounce;
- NumBounceSites += F->getNumUses();
- F->replaceAllUsesWith(FN);
- changed = true;
- }
- }
- if (Function* F = M.getFunction("malloc")) {
- if (F->isDeclaration() && F->arg_size() == 1 && !F->use_empty()) {
- Function* FN = Function::Create(F->getFunctionType(),
- GlobalValue::LinkOnceAnyLinkage,
- "malloc_llvm_bounce", &M);
- FN->setDoesNotAlias(0);
- BasicBlock* bb = BasicBlock::Create(M.getContext(), "entry",FN);
- Instruction* c = CastInst::CreateIntegerCast(
- FN->arg_begin(), Type::getInt32Ty(M.getContext()), false, "c", bb);
- Instruction* a = new MallocInst(Type::getInt8Ty(M.getContext()),
- c, "m", bb);
- ReturnInst::Create(M.getContext(), a, bb);
- ++NumBounce;
- NumBounceSites += F->getNumUses();
- F->replaceAllUsesWith(FN);
- changed = true;
- }
- }
- return changed;
-}
-
-ModulePass *llvm::createIndMemRemPass() {
- return new IndMemRemPass();
-}
OpenPOWER on IntegriCloud