Speed up bytecode load.

Don't codegen bytecodes that have a functionality_level test in entrypoint
that would prevent them from running.
remotes/push_mirror/vc9-vt-dnd
Török Edvin 15 years ago
parent 26b86d8d8e
commit ab402e6aae
  1. 11
      libclamav/c++/bytecode2llvm.cpp

@ -1451,6 +1451,11 @@ public:
assert(inst->u.ops.funcid < cli_apicall_maxapi && "APICall out of range");
std::vector<Value*> args;
Function *DestF = apiFuncs[inst->u.ops.funcid];
if (!strcmp(cli_apicalls[inst->u.ops.funcid].name, "engine_functionality_level")) {
Store(inst->dest,
ConstantInt::get(Type::getInt32Ty(Context),
cl_retflevel()));
} else {
args.push_back(&*F->arg_begin()); // pass hidden arg
for (unsigned a=0;a<inst->u.ops.numOps;a++) {
operand_t op = inst->u.ops.ops[a];
@ -1459,6 +1464,7 @@ public:
CallInst *CI = Builder.CreateCall(DestF, args.begin(), args.end());
CI->setDoesNotThrow(true);
Store(inst->dest, CI);
}
break;
}
case OP_BC_GEP1:
@ -2103,8 +2109,8 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
// TODO: only run this on the untrusted bytecodes, not all of them...
if (has_untrusted)
PM.add(createClamBCRTChecks());
PM.add(createCFGSimplificationPass());
PM.add(createSCCPPass());
PM.add(createCFGSimplificationPass());
PM.add(createGlobalOptimizerPass());
PM.add(createConstantMergePass());
PM.add(new RuntimeLimits());
@ -2121,8 +2127,9 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
// compile all functions now, not lazily!
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) {
Function *Fn = &*I;
if (!Fn->isDeclaration())
if (!Fn->isDeclaration()) {
EE->getPointerToFunction(Fn);
}
}
codegenTimer.stopTimer();
}

Loading…
Cancel
Save