Skip to content

Commit

Permalink
Do not lookup and retrieve function if already exists
Browse files Browse the repository at this point in the history
Due to the way encoding/decoding routines are jit-compiled,
we need to recreate the decode function at each decoding
invocation. This is suboptimal, and needs to be reviewed
in the future.
  • Loading branch information
antoniofrighetto committed Feb 26, 2024
1 parent 2a07dab commit bd1440f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/passes/strings-encoding/StringEncoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,9 @@ bool StringEncoding::injectOnStackLoop(BasicBlock& BB, Instruction& I, Use& Op,
}

auto *M = BB.getModule();
FunctionCallee DecodeCallee =
M->getOrInsertFunction("__omvll_decode", FDecode->getFunctionType());
auto *NewF = cast<Function>(DecodeCallee.getCallee());
auto *NewF =
Function::Create(FDecode->getFunctionType(), GlobalValue::PrivateLinkage,
"__omvll_decode", M);

ValueToValueMapTy VMap;
auto NewFArgsIt = NewF->arg_begin();
Expand Down Expand Up @@ -507,9 +507,9 @@ bool StringEncoding::processGlobal(BasicBlock& BB, Instruction&, Use& Op, Global
fatalError("Can't find the 'decode' routine");
}

FunctionCallee DecodeCallee =
M->getOrInsertFunction("__omvll_decode", FDecode->getFunctionType());
auto *NewF = cast<Function>(DecodeCallee.getCallee());
auto *NewF =
Function::Create(FDecode->getFunctionType(), GlobalValue::PrivateLinkage,
"__omvll_decode", M);

ValueToValueMapTy VMap;
auto NewFArgsIt = NewF->arg_begin();
Expand Down

0 comments on commit bd1440f

Please sign in to comment.