This is an archive of the discontinued LLVM Phabricator instance.

[MachineInstr] return mayAlias for not mayLoadOrStore instructions.
ClosedPublic

Authored by shchenz on Sep 10 2020, 9:25 PM.

Details

Summary

This is a typo fix for bool MachineInstr::mayAlias() function.

For now mayAlias(CallInstruction, LoadInstruction) always returns false (NoAlias), this is not right. CallInstruction may alter the memory where the LoadInstruction operates on.

Diff Detail

Event Timeline

shchenz created this revision.Sep 10 2020, 9:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 10 2020, 9:25 PM
shchenz requested review of this revision.Sep 10 2020, 9:25 PM
shchenz edited the summary of this revision. (Show Details)
shchenz updated this revision to Diff 291125.Sep 10 2020, 9:41 PM

Hmm.

Maybe we should be explicitly checking for isCall here? It's not really right to assume instructions that any instruction that doesn't have mayLoad/mayStore modifies memory.

shchenz updated this revision to Diff 291485.Sep 13 2020, 6:53 PM

explicitly check for isCall

shchenz edited the summary of this revision. (Show Details)Sep 13 2020, 7:02 PM

Hi @efriedma could you please help to have another look for this simple fix? Thanks.

gentle ping

This is a quite 'small' patch and it should be a NFC patch as if any existing case hits this pattern, it gets a wrong aliasing query result.

I will commit this first and welcome your post-commit comments.

This revision was not accepted when it landed; it landed in state Needs Review.Oct 6 2020, 9:19 PM
This revision was automatically updated to reflect the committed changes.

For starters, this is missing a test.

For starters, this is missing a test.

@lebedev.ri thanks for looking into this, Roman. This patch protects protential alias query between a call instruction and a call/load/store instruction. Currently there is no such query in clang/llvm code base. So if we don't add a problematic alias query first in clang/llvm code base, there will be no difference with/without this patch. So I leave this without a test. Hope this is ok.

For starters, this is missing a test.

@lebedev.ri thanks for looking into this, Roman. This patch protects protential alias query between a call instruction and a call/load/store instruction. Currently there is no such query in clang/llvm code base. So if we don't add a problematic alias query first in clang/llvm code base, there will be no difference with/without this patch. So I leave this without a test. Hope this is ok.

So why are we adding dead code then?

So why are we adding dead code then?

I think this is necessary for the mayAlias interface. Alias query always contains the query for a call instruction. If we call this interface based on MIR for a call instruction, we get a wrong result. This was from my development, I originally thought this function can handle call instruciton, but as a result it can not. so I called this interface and my codes made some loads sink down crossing a call instruction. This was not right. The call alters the memory where the loads got content.

So I think we need to add more conditions in mayAlias interface.

I think we are talking past each other.
Either the code you've added can be triggered, and therefore needs a test,
or it can't be triggered/reached, and it should be removed as dead code.

I think to make a fundamental interface strong, it is always possible to add some unreachable path for current code base to protect some furture improper callers. This is very like the assert statement. There should always no code path can trigger the assertion.

If you insist, I can revert this or I can change it to a assertion.