Skip to content

Conversation

@MaxGraey
Copy link
Contributor

Fix issue found by fuzzer: #3038 (comment)

@MaxGraey MaxGraey changed the title optimize memory.copy: check size for side effect as well Fix optimize memory.copy: check size for side effect as well Aug 23, 2020
if (!EffectAnalyzer(getPassOptions(), features, memCopy->dest)
.hasSideEffects() &&
!EffectAnalyzer(getPassOptions(), features, memCopy->size)
.hasSideEffects() &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about just checking for side effects on memCopy itself? that would be shorter and handle all the cases.

Copy link
Contributor Author

@MaxGraey MaxGraey Aug 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case:

(memory.copy  ;; nop
  (local.get $dst)
  (local.get $dst)
  (local.get $sz)
)

will not reduced to nop. I don't know why

Copy link
Contributor Author

@MaxGraey MaxGraey Aug 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's because MemoryCopy just don't properly handle by EffectAnalyzer? It just use this:

void visitMemoryCopy(MemoryCopy* curr) {
  readsMemory = true;
  writesMemory = true;
  if (!ignoreImplicitTraps) {
    implicitTrap = true;
  }
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes, that makes sense. It doesn't know it doesn't read/write in this case.

@kripken kripken merged commit 1f439f7 into WebAssembly:master Aug 23, 2020
@MaxGraey MaxGraey deleted the fix-memcpy-opt branch August 23, 2020 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants