This is an archive of the discontinued LLVM Phabricator instance.

[MemorySSA] Don't check def set when cloning memoryaccesses
ClosedPublic

Authored by StephenFan on Jan 7 2023, 12:17 AM.

Details

Summary

For internal functions, globals-aa returns different ModRefInfo
results if they are inlined and are no longer called by external
functions. This causes an assertion failure when cloning memoryssa
accesses.

Fixes: https://github.com/llvm/llvm-project/issues/59546

Diff Detail

Event Timeline

StephenFan created this revision.Jan 7 2023, 12:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 7 2023, 12:17 AM
StephenFan requested review of this revision.Jan 7 2023, 12:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 7 2023, 12:17 AM
nikic added inline comments.Jan 7 2023, 1:04 AM
llvm/lib/Analysis/MemorySSA.cpp
1764

We could do something like assert(Def == DefCheck || !DefCheck), to check that we only reduce, but not increase possible accesses. (Though I suspect that we'll hit cases like that as well...)

llvm/test/Transforms/SimpleLoopUnswitch/pr59546.ll
42

Is this needed to prevent inlining? Can we mark it noinline instead?

asbirlea added inline comments.Jan 9 2023, 12:19 PM
llvm/lib/Analysis/MemorySSA.cpp
1764

+1 to add this check now.
If we encounter the opposite it'll be worth understanding how something became obfuscated enough to miss that the instruction cannot write.

StephenFan updated this revision to Diff 487652.Jan 9 2023, 7:55 PM

Add an assertion.

StephenFan updated this revision to Diff 487653.Jan 9 2023, 8:07 PM

Replace attribute to noinline.

nikic accepted this revision.Jan 10 2023, 1:13 AM

LG

llvm/lib/Analysis/MemorySSA.cpp
1764

Can you please add () around the expression? I think it still does the right thing in the end, but mostly by accident. It will evaluate Def == DefCheck || (!DefCheck && "")

This revision is now accepted and ready to land.Jan 10 2023, 1:13 AM
This revision was landed with ongoing or failed builds.Jan 12 2023, 5:54 AM
This revision was automatically updated to reflect the committed changes.