<div dir="ltr"><div>Dear LLVMers,</div><div><br></div><div>I'm following the TBAA section from the LLVM <br></div><div>Language Reference Manual, and I found a minor</div><div>detail in the offsets in the access tags. <br></div><div><br></div><div>For example:<br></div><div><br></div><div><pre><span class="gmail-kt">void</span> <span class="gmail-nf">f</span><span class="gmail-p">(</span><span class="gmail-k">struct</span> <span class="gmail-nc">Outer</span><span class="gmail-o">*</span> <span class="gmail-n">outer</span><span class="gmail-p">,</span> <span class="gmail-k">struct</span> <span class="gmail-nc">Inner</span><span class="gmail-o">*</span> <span class="gmail-n">inner</span><span class="gmail-p">,</span> <span class="gmail-kt">float</span><span class="gmail-o">*</span> <span class="gmail-n">f</span><span class="gmail-p">,</span> <span class="gmail-kt">int</span><span class="gmail-o">*</span> <span class="gmail-n">i</span><span class="gmail-p">,</span> <span class="gmail-kt">char</span><span class="gmail-o">*</span> <span class="gmail-n">c</span><span class="gmail-p">)</span> <span class="gmail-p">{</span>
  <span class="gmail-n">outer</span><span class="gmail-o">-></span><span class="gmail-n">f</span> <span class="gmail-o">=</span> <span class="gmail-mi">0</span><span class="gmail-p">;</span>            <span class="gmail-c1">// tag0: (OuterStructTy, FloatScalarTy, 0)</span>
  <span class="gmail-n">outer</span><span class="gmail-o">-></span><span class="gmail-n">inner_a</span><span class="gmail-p">.</span><span class="gmail-n">i</span> <span class="gmail-o">=</span> <span class="gmail-mi">0</span><span class="gmail-p">;</span>    <span class="gmail-c1">// tag1: (OuterStructTy, IntScalarTy, 12)</span>
  <span class="gmail-n">outer</span><span class="gmail-o">-></span><span class="gmail-n">inner_a</span><span class="gmail-p">.</span><span class="gmail-n">f</span> <span class="gmail-o">=</span> <span class="gmail-mf">0.0</span><span class="gmail-p">;</span>  <span class="gmail-c1">// tag2: (OuterStructTy, FloatScalarTy, 16)</span>
  <span class="gmail-o">*</span><span class="gmail-n">f</span> <span class="gmail-o">=</span> <span class="gmail-mf">0.0</span><span class="gmail-p">;</span>                <span class="gmail-c1">// tag3: (FloatScalarTy, FloatScalarTy, 0)</span>
<span class="gmail-p">}<br></span></pre></div><div><br></div><div>When this program is compiled to the IR, the</div><div>offsets in tag1 and tag2 are actually 4 bytes more</div><div>than the indicated in the text. (x86_64 architecture)</div><div><br></div><div><span style="font-family:monospace">store i32 0, i32* %i2, align 8, !dbg !46, !tbaa !47</span></div><div><span style="font-family:monospace">!47 = !{!38, !44, i64 16} (tag1)</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">store float 0.000000e+00, float* %f4, align 4, !dbg !49, !tbaa !50</span></div><div><span style="font-family:monospace">!50 = !{!38, !39, i64 20} (tag2)<br></span></div><div><br></div><div>Is this an error in the manual, or is just some padding</div><div>within structs Outer and Inner that are yielding</div><div>such a difference?<br></div><div></div><div><br></div><div>Best regards,</div><div><br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">José Wesley de Souza Magalhães<div>MSc Student in Computer Science<br></div><div>Belo Horizonte/MG - Brazil</div></div></div></div></div></div></div></div>