Skip to content

Commit 755ffa3

Browse files
authored
[LangRef] Do not make align imply dereferenceability (#158062)
We currently specify that something like `load i8, align 16384` implies that the object is actually dereferenceable up to 16384 bytes, rather than only the one byte implied by the load type. We should stop doing that, because it makes it invalid to infer alignments larger than the load/store type, which is something we do (and want to do). There is some SDAG code that does make use of this property by widening accesses and extracting part of them. However, I believe we should be justifying that based on target-specific guarantees, rather than a generic IR property. (The reasoning goes something like this: Typically, memory protection has page granularity, so widening a load to the alignment will not trap, as long as the alignment is not larger than the page size, which is true for any practically interesting access size.) Fixes #90446.
1 parent e86209c commit 755ffa3

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

llvm/docs/LangRef.rst

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11397,11 +11397,9 @@ responsibility of the code emitter to ensure that the alignment information is
1139711397
correct. Overestimating the alignment results in undefined behavior.
1139811398
Underestimating the alignment may produce less efficient code. An alignment of
1139911399
1 is always safe. The maximum possible alignment is ``1 << 32``. An alignment
11400-
value higher than the size of the loaded type implies memory up to the
11401-
alignment value bytes can be safely loaded without trapping in the default
11402-
address space. Access of the high bytes can interfere with debugging tools, so
11403-
should not be accessed if the function has the ``sanitize_thread`` or
11404-
``sanitize_address`` attributes.
11400+
value higher than the size of the loaded type does *not* imply (without target
11401+
specific knowledge) that memory up to the alignment value bytes can be safely
11402+
loaded without trapping.
1140511403

1140611404
The alignment is only optional when parsing textual IR; for in-memory IR, it is
1140711405
always present. An omitted ``align`` argument means that the operation has the
@@ -11537,12 +11535,10 @@ operation (that is, the alignment of the memory address). It is the
1153711535
responsibility of the code emitter to ensure that the alignment information is
1153811536
correct. Overestimating the alignment results in undefined behavior.
1153911537
Underestimating the alignment may produce less efficient code. An alignment of
11540-
1 is always safe. The maximum possible alignment is ``1 << 32``. An alignment
11541-
value higher than the size of the loaded type implies memory up to the
11542-
alignment value bytes can be safely loaded without trapping in the default
11543-
address space. Access of the high bytes can interfere with debugging tools, so
11544-
should not be accessed if the function has the ``sanitize_thread`` or
11545-
``sanitize_address`` attributes.
11538+
1 is always safe. The maximum possible alignment is ``1 << 32``. An alignment
11539+
value higher than the size of the stored type does *not* imply (without target
11540+
specific knowledge) that memory up to the alignment value bytes can be safely
11541+
loaded without trapping.
1154611542

1154711543
The alignment is only optional when parsing textual IR; for in-memory IR, it is
1154811544
always present. An omitted ``align`` argument means that the operation has the

0 commit comments

Comments
 (0)