Skip to content

Commit

Permalink
Fix ExpandMemoryOpPass don't work properly
Browse files Browse the repository at this point in the history
  • Loading branch information
no1wudi committed Jul 28, 2023
1 parent bab1b31 commit d611014
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions core/iwasm/compilation/aot_llvm_extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,43 +82,29 @@ class ExpandMemoryOpPass : public PassInfoMixin<ExpandMemoryOpPass>
PreservedAnalyses
ExpandMemoryOpPass::run(Function &F, FunctionAnalysisManager &AM)
{
Intrinsic::ID ID = F.getIntrinsicID();
bool Changed = false;
/* Iterate over all instructions in the function, looking for memcpy,
* memmove, and memset. When we find one, expand it into a loop. */

for (auto I = F.user_begin(), E = F.user_end(); I != E;) {
Instruction *Inst = cast<Instruction>(*I);
++I;

switch (ID) {
case Intrinsic::memcpy:
{
auto *Memcpy = cast<MemCpyInst>(Inst);
for (auto &BB : F) {
for (auto &Inst : BB) {
if (auto *Memcpy = dyn_cast<MemCpyInst>(&Inst)) {
Function *ParentFunc = Memcpy->getParent()->getParent();
const TargetTransformInfo &TTI =
AM.getResult<TargetIRAnalysis>(*ParentFunc);
expandMemCpyAsLoop(Memcpy, TTI);
Memcpy->eraseFromParent();
Changed = true;
break;
}
case Intrinsic::memmove:
{
auto *Memmove = cast<MemMoveInst>(Inst);
else if (auto *Memmove = dyn_cast<MemMoveInst>(&Inst)) {
expandMemMoveAsLoop(Memmove);
Memmove->eraseFromParent();
Changed = true;
break;
}
case Intrinsic::memset:
{
auto *Memset = cast<MemSetInst>(Inst);
else if (auto *Memset = dyn_cast<MemSetInst>(&Inst)) {
expandMemSetAsLoop(Memset);
Memset->eraseFromParent();
Changed = true;
break;
}
default:
break;
}
}

Expand Down

0 comments on commit d611014

Please sign in to comment.