[PATCH] D86189: [LangRef] State that storing an aggregate fills padding with undef

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 18 19:28:09 PDT 2020


aqjune created this revision.
aqjune added reviewers: reames, jdoerfert, hfinkel, efriedma, craig.topper, nikic, spatel, nlopes, regehr, lebedev.ri.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
aqjune requested review of this revision.

This patch makes LangRef be explicit about the value of padding when storing an aggregate.
It states that when an aggregate is stored into memory, padding is filled with undef.
I’ll send a mail to llvm-dev for a discussion.

Here are a few clues that supports this change:

- According to C17, the value of padding bytes when storing values in structures or unions is unspecified.

- IPSCCP ignores padding and directly stores a constant aggregate if possible. It loses the data stored in the padding. https://godbolt.org/z/xzenYs

- I updated Alive2 and it did not find any problematic transformation from LLVM unit tests and while running translation validation of a few C programs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86189

Files:
  llvm/docs/LangRef.rst


Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -9327,6 +9327,8 @@
 value of a type like ``i20`` with a size that is not an integral number
 of bytes, it is unspecified what happens to the extra bits that do not
 belong to the type, but they will typically be overwritten.
+If ``<value>`` is of aggregate type, padding is filled with
+:ref:`undef <undefvalues>`.
 
 Example:
 """"""""


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86189.286458.patch
Type: text/x-patch
Size: 489 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200819/e09a1ebe/attachment.bin>


More information about the llvm-commits mailing list