@@ -25,7 +25,7 @@ Expected<std::string> codegenIR(Module &module, unsigned items) {
2525 LLVMContext &ctx = module .getContext ();
2626 IRBuilder<> B (ctx);
2727
28- auto name = " allocforabssub " ;
28+ auto name = " integerDistances " ;
2929 auto intTy = Type::getInt32Ty (ctx);
3030 auto intPtrTy = intTy->getPointerTo ();
3131 auto signature = FunctionType::get (intPtrTy, {intPtrTy, intPtrTy}, false );
@@ -105,20 +105,6 @@ extern "C" int *customIntAllocator(unsigned items) {
105105// Also called from JITed code; make sure it's available.
106106extern " C" int abs (int );
107107
108- // Temporary global variable to replace below function step-by-step.
109- std::function<int * (int *, int *)> allocforabssub;
110-
111- // This function will be replaced by a runtime-time compiled version.
112- template <size_t sizeOfArray>
113- int *integerDistances (const int (&x)[sizeOfArray], int *y) {
114- unsigned items = arrayElements (x);
115- int *results = customIntAllocator (items);
116-
117- results = allocforabssub ((int *)x, y);
118-
119- return results;
120- }
121-
122108int main (int argc, char **argv) {
123109 InitLLVM X (argc, argv);
124110
@@ -148,7 +134,8 @@ int main(int argc, char **argv) {
148134 ExitOnErr (Jit.submitModule (std::move (M), std::move (C)));
149135
150136 // Request function; this compiles to machine code and links.
151- allocforabssub = ExitOnErr (Jit.getFunction <int *(int *, int *)>(JitedFnName));
137+ auto integerDistances =
138+ ExitOnErr (Jit.getFunction <int *(int *, int *)>(JitedFnName));
152139
153140 int *z = integerDistances (x, y);
154141
0 commit comments