This is an archive of the discontinued LLVM Phabricator instance.

[FunctionAttrs] Volatile operations can access inaccessible memory
ClosedPublic

Authored by nikic on Oct 13 2022, 3:24 AM.

Details

Summary

Per LangRef, volatile operations are allowed to access the location of their pointer argument, plus inaccessible memory:

Any volatile operation can have side effects, and any volatile operation can read and/or modify state which is not accessible via a regular load or store in this module.
[...]
The allowed side-effects for volatile accesses are limited. If a non-volatile store to a given address would be legal, a volatile operation may modify the memory at that address. A volatile operation may not modify any other memory accessible by the module being compiled. A volatile operation may not call any code in the current module.

FunctionAttrs currently does not model this and ends up marking functions with volatile accesses on arguments as argmemonly, even though they should be inaccessiblemem_or_argmemonly.

Diff Detail

Event Timeline

nikic created this revision.Oct 13 2022, 3:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 13 2022, 3:24 AM
nikic requested review of this revision.Oct 13 2022, 3:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 13 2022, 3:24 AM

Not an expert on our requirements for volatile. I agree that this is the more conservative approach though. Fine with me.

nikic updated this revision to Diff 468912.Oct 19 2022, 7:49 AM

Rebase over rename.

This revision is now accepted and ready to land.Oct 19 2022, 2:08 PM