1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
//===- BreakConstantGEPs.h - Change constant GEPs into GEP instructions --- --//
//
// pocl note: This pass is taken from The SAFECode project with trivial modifications.
// Automatic locals might cause constant GEPs which cause problems during
// converting the locals to kernel function arguments for thread safety.
//
// The SAFECode Compiler
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This pass changes all GEP constant expressions into GEP instructions. This
// permits the rest of SAFECode to put run-time checks on them if necessary.
//
//===----------------------------------------------------------------------===//
#ifndef POCL_BREAKCONSTANTGEPS_H
#define POCL_BREAKCONSTANTGEPS_H
#include "config.h"
#include <llvm/IR/Function.h>
#include <llvm/IR/PassManager.h>
#include <llvm/Pass.h>
#include <llvm/Passes/PassBuilder.h>
//
// Pass: BreakConstantGEPs
//
// Description:
// This pass modifies a function so that it uses GEP instructions instead of
// GEP constant expressions.
//
namespace pocl {
#if LLVM_MAJOR < MIN_LLVM_NEW_PASSMANAGER
class BreakConstantGEPs : public llvm::FunctionPass {
public:
static char ID;
BreakConstantGEPs() : FunctionPass(ID){};
virtual ~BreakConstantGEPs(){};
virtual bool runOnFunction(llvm::Function &F) override;
virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const override;
};
#else
class BreakConstantGEPs : public llvm::PassInfoMixin<BreakConstantGEPs> {
public:
static void registerWithPB(llvm::PassBuilder &B);
llvm::PreservedAnalyses run(llvm::Function &F,
llvm::FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};
#endif
} // namespace pocl
#endif
|