Don't codegen bytecodes that have a functionality_level test in entrypoint
that would prevent them from running.
... | ... |
@@ -1451,6 +1451,11 @@ public: |
1451 | 1451 |
assert(inst->u.ops.funcid < cli_apicall_maxapi && "APICall out of range"); |
1452 | 1452 |
std::vector<Value*> args; |
1453 | 1453 |
Function *DestF = apiFuncs[inst->u.ops.funcid]; |
1454 |
+ if (!strcmp(cli_apicalls[inst->u.ops.funcid].name, "engine_functionality_level")) { |
|
1455 |
+ Store(inst->dest, |
|
1456 |
+ ConstantInt::get(Type::getInt32Ty(Context), |
|
1457 |
+ cl_retflevel())); |
|
1458 |
+ } else { |
|
1454 | 1459 |
args.push_back(&*F->arg_begin()); // pass hidden arg |
1455 | 1460 |
for (unsigned a=0;a<inst->u.ops.numOps;a++) { |
1456 | 1461 |
operand_t op = inst->u.ops.ops[a]; |
... | ... |
@@ -1459,6 +1464,7 @@ public: |
1459 | 1459 |
CallInst *CI = Builder.CreateCall(DestF, args.begin(), args.end()); |
1460 | 1460 |
CI->setDoesNotThrow(true); |
1461 | 1461 |
Store(inst->dest, CI); |
1462 |
+ } |
|
1462 | 1463 |
break; |
1463 | 1464 |
} |
1464 | 1465 |
case OP_BC_GEP1: |
... | ... |
@@ -2103,8 +2109,8 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs) |
2103 | 2103 |
// TODO: only run this on the untrusted bytecodes, not all of them... |
2104 | 2104 |
if (has_untrusted) |
2105 | 2105 |
PM.add(createClamBCRTChecks()); |
2106 |
- PM.add(createCFGSimplificationPass()); |
|
2107 | 2106 |
PM.add(createSCCPPass()); |
2107 |
+ PM.add(createCFGSimplificationPass()); |
|
2108 | 2108 |
PM.add(createGlobalOptimizerPass()); |
2109 | 2109 |
PM.add(createConstantMergePass()); |
2110 | 2110 |
PM.add(new RuntimeLimits()); |
... | ... |
@@ -2121,8 +2127,9 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs) |
2121 | 2121 |
// compile all functions now, not lazily! |
2122 | 2122 |
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) { |
2123 | 2123 |
Function *Fn = &*I; |
2124 |
- if (!Fn->isDeclaration()) |
|
2124 |
+ if (!Fn->isDeclaration()) { |
|
2125 | 2125 |
EE->getPointerToFunction(Fn); |
2126 |
+ } |
|
2126 | 2127 |
} |
2127 | 2128 |
codegenTimer.stopTimer(); |
2128 | 2129 |
} |