[llvm] [IR] Memory locations for floating-point operations (PR #226826)

via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 27 12:12:15 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Serge Pavlov (spavloff)

<details>
<summary>Changes</summary>

Floating-point operations in a strictfp function have side effects, which are modeled using memory effects in the form of a read-write access to "inaccessible memory". This helps maintain strictfp semantics but may hinder optimizations. Floating-point operations may depend on rounding mode or not - this fact may be used to reorder them in a more optimal way. Similarly, functions that control floating-point environment (like `set_rounding`, `set_fpmode` etc.) also have more specific access than generic read-write. Also, "inaccessible memory" is used in cases other than FP operation, this results in unnecessary restrictions.

This change implements two new memory location to use instead of the access to "inaccessible memory". The "fpcontrol" location is used to represent access to floating-point control modes, of which only rounding mode is currently supported. The other location, "fpstatus", represents access to floating-point exceptions. Together they replace the use of "inaccessible memory".

The new memory locations are not supported in all cases. The Attributor does not support them now, as these locations do not exactly represent memory. Writing to a floating-point control register inside a function does not mean that the function itself changes some floating-point control mode. Supporting these locations in the Attributor requires additional considerations and, probably, new attributes.

The meaning of `MemoryEffects::onlyAccessesInaccessibleMem` is changed in this commit. Now this method checks not only the "inaccessible memory" but also floating-point environment. This change agrees with the current usage of the method in the compiler sources and will hopefully reduce the risk on misuse.

This change only introduces the new memory locations. Their use in the functions that access the floating-point environment will be implemented in another commit.

This MR was obtained from
https://github.com/llvm/llvm-project/pull/221754 by keeping only the changes required to introduce the new memory locations only.

---
Full diff: https://github.com/llvm/llvm-project/pull/226826.diff


17 Files Affected:

- (modified) llvm/include/llvm/AsmParser/LLToken.h (+2) 
- (modified) llvm/include/llvm/Support/ModRef.h (+69-7) 
- (modified) llvm/include/llvm/Transforms/IPO/Attributor.h (+2-2) 
- (modified) llvm/lib/Analysis/AliasAnalysis.cpp (+2) 
- (modified) llvm/lib/Analysis/BasicAliasAnalysis.cpp (+5-2) 
- (modified) llvm/lib/Analysis/GlobalsModRef.cpp (+1-1) 
- (modified) llvm/lib/AsmParser/LLLexer.cpp (+2) 
- (modified) llvm/lib/AsmParser/LLParser.cpp (+7-2) 
- (modified) llvm/lib/IR/Attributes.cpp (+31-9) 
- (modified) llvm/lib/Support/ModRef.cpp (+6) 
- (modified) llvm/lib/Transforms/IPO/Attributor.cpp (+3-1) 
- (modified) llvm/lib/Transforms/IPO/AttributorAttributes.cpp (+4-4) 
- (modified) llvm/lib/Transforms/IPO/FunctionAttrs.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+2) 
- (modified) llvm/test/Assembler/memory-attribute-errors.ll (+3-3) 
- (modified) llvm/test/Assembler/memory-attribute.ll (+30) 
- (modified) llvm/unittests/Support/ModRefTest.cpp (+2-1) 


``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````

</details>


https://github.com/llvm/llvm-project/pull/226826


More information about the llvm-commits mailing list