aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
diff options
context:
space:
mode:
authorMarkus Böck <markus.boeck02@gmail.com>2023-09-08 13:50:49 +0200
committerGitHub <noreply@github.com>2023-09-08 13:50:49 +0200
commitfeb7beaf70bace1c3ffafc7f732c8fadca5e8c9d (patch)
tree68bb6a5a5a4a0f168a8bd45a3bac225d7d52f453 /llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
parentda1eb886c4a6434c76d27ef0f6d5139dda930d72 (diff)
downloadllvm-feb7beaf70bace1c3ffafc7f732c8fadca5e8c9d.zip
llvm-feb7beaf70bace1c3ffafc7f732c8fadca5e8c9d.tar.gz
llvm-feb7beaf70bace1c3ffafc7f732c8fadca5e8c9d.tar.bz2
[mlir][LLVM] Model side effects of volatile and atomic load-store (#65730)
According to the LLVM language reference, both volatile memory operations and atomic operations (except unordered) do not simply read memory but also perform write operations on arbitrary memory[0][1]. In the case of volatile memory operations, this is the case due to the read possibly having target specific properties. A common real-world situation where this happens is reading memory mapped registers on an MCU for example. Atomic operations are more special. They form a kind of memory barrier which from the perspective of the optimizer/lang-ref makes writes from other threads visible in the current thread. Any kind of synchronization can therefore conservatively be modeled as a write-effect. This PR therefore adjusts the side effects of `llvm.load` and `llvm.store` to add unknown global read and write effects if they are either atomic or volatile. Regarding testing: I am not sure how to best test this change for `llvm.store` and the "globalness" of the effect that isn't just a unit test checking that the output matches exactly. For the time being, I added a test making sure that `llvm.load` does not get DCEd in aforementioned cases. Related logic in LLVM proper: https://github.com/llvm/llvm-project/blob/3398744a6106c83993611bd3c5e79ec6b94417dc/llvm/lib/IR/Instruction.cpp#L638-L676 https://github.com/llvm/llvm-project/blob/3398744a6106c83993611bd3c5e79ec6b94417dc/llvm/include/llvm/IR/Instructions.h#L258-L262 [0] https://llvm.org/docs/LangRef.html#volatile-memory-accesses [1] https://llvm.org/docs/Atomics.html#monotonic
Diffstat (limited to 'llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp')
0 files changed, 0 insertions, 0 deletions