<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal">
<p dir="auto">On 15 Jun 2021, at 1:49, Juneyoung Lee wrote:</p>

</div>
<div style="white-space:normal"><blockquote style="border-left:2px solid #3983C4; color:#3983C4; margin:0 0 5px; padding-left:5px"><p dir="auto">On Tue, Jun 15, 2021 at 1:08 AM John McCall via llvm-dev <<br>
llvm-dev@lists.llvm.org> wrote:<br>
</p>
<blockquote style="border-left:2px solid #3983C4; color:#7CBF0C; margin:0 0 5px; padding-left:5px; border-left-color:#7CBF0C"><p dir="auto">The semantics you seem to want are that LLVM’s integer types cannot carry<br>
information from pointers. But I can cast a pointer to an integer in C and<br>
vice-versa, and compilers have de facto defined the behavior of subsequent<br>
operations like breaking the integer up (and then putting it back<br>
together), adding numbers to it, and so on. So no, as a C compiler writer,<br>
I do not have a choice; I will have to use a type that can validly carry<br>
pointer information for integers in C.<br>
</p>
</blockquote><p dir="auto">int->ptr cast can reconstruct the pointer information, so making integer<br>
types not carry pointer information does not necessarily mean that<br>
dereferencing a pointer casted from integer is UB.</p>
</blockquote></div>
<div style="white-space:normal">

<p dir="auto">What exactly is the claimed formal property of byte types, then,<br>
that integer types will lack?  Because it seems to me that converting<br>
from an integer gives us valid provenance in strictly more situations<br>
than converting from bytes, since it reconstructs provenance if there’s<br>
any object at that address (under still-debated restrictions),<br>
while converting from bytes always preserves the original provenance<br>
(if any).  I don’t understand how that can possibly give us <em>more</em><br>
flexibility to optimize integers.</p>

</div>
<div style="white-space:normal"><blockquote style="border-left:2px solid #3983C4; color:#3983C4; margin:0 0 5px; padding-left:5px"><blockquote style="border-left:2px solid #3983C4; color:#7CBF0C; margin:0 0 5px; padding-left:5px; border-left-color:#7CBF0C"><p dir="auto">Since you seem to find this sort of thing compelling, please note that<br>
even a simple assignment like char c2 = c1 technically promotes through<br>
int in C, and so int must be able to carry pointer information if char<br>
can.<br>
</p>
</blockquote><p dir="auto">IIUC integer promotion is done when it is used as an operand of arithmetic<br>
ops or switch's condition, so I think assignment operation is okay.</p>
</blockquote></div>
<div style="white-space:normal">

<p dir="auto">Hmm, I was misremembering the rule, you’re right.</p>

<p dir="auto">John.</p>
</div>
</div>
</body>
</html>