[llvm-dev] Possible GlobalModRef bug -- arg-less calls produce wrong ref info.

Artem Belevich via llvm-dev llvm-dev at lists.llvm.org
Tue Nov 30 12:00:42 PST 2021


Hi Nikita,

I've been tracking a miscompile in NVPTX which I've narrowed down to this
oddity, where GlobalModRef gives different answers depending on whether an
intrinsic call has an argument or not:

https://godbolt.org/z/4PqhWKha5

The difference in behavior appears to originate here:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/GlobalsModRef.cpp#L908
If the intrinsic has no arguments, it always returns `NoModRef`.
This allows LLVM to eliminate loads and stores that should have been
preserved.

I'm not sure it's the real root cause, though. Supposedly the purpose of
the `getModRefInfoForArgument` function is to tell whether the argument
references the value, so technically, if there's no argument, there's no
reference.

It's possible that the real issue is that something/somewhere ignores the
function attributes (or, rather, lack or readonly/writeonly, argmemonly,
etc) and we've just been lucky to have things working correctly for the
intrinsics *with* an argument only because `getModRefInfoForArgument` would
give a conservative answer when we use a scalar value.

I'm not familiar with AA machinery and could use your help figuring out
what's going on.

Thank you,
--Artem
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211130/9d3212b8/attachment.html>


More information about the llvm-dev mailing list