bytecode: various LLVM version specific fixes

pull/69/head
Kevin Lin 12 years ago
parent 9f8df4ae4b
commit 0b5550c176
  1. 6
      libclamav/c++/ClamBCRTChecks.cpp
  2. 13
      libclamav/c++/PointerTracking.cpp

@ -174,7 +174,7 @@ namespace llvm {
SE = &getAnalysis<ScalarEvolution>();
PT = &getAnalysis<PointerTracking>();
DT = &getAnalysis<DominatorTree>();
expander = new SCEVExpander(*SE);
expander = new SCEVExpander(*SE OPT("SCEVexpander"));
std::vector<Instruction*> insns;
@ -474,7 +474,7 @@ namespace llvm {
}
}
if (LoadInst *LI = dyn_cast<LoadInst>(Base)) {
Value *V = LI->getPointerOperand()->stripPointerCasts()->getUnderlyingObject();
Value *V = GetUnderlyingObject(LI->getPointerOperand()->stripPointerCasts(), TD);
if (Argument *A = dyn_cast<Argument>(V)) {
if (A->getArgNo() == 0) {
// pointers from hidden ctx are trusted to be at least the
@ -870,7 +870,7 @@ INITIALIZE_AG_DEPENDENCY(CallGraph)
INITIALIZE_PASS_DEPENDENCY(CallGraph)
#endif
INITIALIZE_PASS_DEPENDENCY(PointerTracking)
INITIALIZE_PASS_END(PtrVerifier, "clambcrtchecks", "ClamBC RTchecks", false, false)
INITIALIZE_PASS_END(PtrVerifier, "clambc-rtchecks", "ClamBC RTchecks", false, false)
#endif

@ -47,22 +47,33 @@
#endif
using namespace llvm;
#if LLVM_VERSION < 29
/* function is succeeded in later LLVM with LLVM correspoding standalone */
static Value *GetUnderlyingObject(Value *P, TargetData *TD)
{
return P->getUnderlyingObject();
}
#endif
#if LLVM_VERSION >= 30
namespace llvm {
void initializePointerTrackingPass(llvm::PassRegistry&);
};
INITIALIZE_PASS_BEGIN(PointerTracking, "pointertracking",
"Track pointer bounds", false, true)
INITIALIZE_PASS_DEPENDENCY(DominatorTree)
INITIALIZE_PASS_DEPENDENCY(LoopInfo)
INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
INITIALIZE_PASS_DEPENDENCY(DominatorTree)
INITIALIZE_PASS_END(PointerTracking, "pointertracking",
"Track pointer bounds", false, true)
#endif
char PointerTracking::ID = 0;
PointerTracking::PointerTracking() : FunctionPass(ID) {
#if LLVM_VERSION >= 30
initializePointerTrackingPass(*PassRegistry::getPassRegistry());
#endif
}
bool PointerTracking::runOnFunction(Function &F) {

Loading…
Cancel
Save