<div dir="ltr">32bit case does not seem to work well.<div>1) a subtle problem is that __llvm_profile_data struct is not declared to match the instrumentation in terms of alignment, sizeof operator returns smaller value than that is actually allocated -- the result is that some profile-data may get silently dropped/truncated during dump.</div><div>2) 32 bit reader also assumes 4 byte alignment while the actual data is 8 byte aligned.</div><div><br></div><div>The fix is simple, just use LLVM_ALIGNAS macro when declaring prof data structure (in both runtime and InstrProf.h). In runtime, we will have to duplicate the def of LLVM_ALIGNAS macro for now.  With this change, cross platform reading are also fine.</div><div><br></div><div>This is actually an old bug exposed by this change. The old layout of ProfileData happens to work (multiples of 8 bytes).</div><div><br></div><div>David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 15, 2015 at 1:25 PM, Xinliang David Li <span dir="ltr"><<a href="mailto:davidxl@google.com" target="_blank">davidxl@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Let me reexamine the code a little more to make sure reading cross platform profiling reading (32 --> 64, 64->64) will be ok (I suppose there are test coverage on that).<span class="HOEnZb"><font color="#888888"><div><br></div><div>David</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 15, 2015 at 1:11 PM, Betul Buyukkurt <span dir="ltr"><<a href="mailto:betulb@codeaurora.org" target="_blank">betulb@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi David,<br>
<br>
Alignment is set to be 8 bytes for the ProfileData struct elements in<br>
lib/Transforms/Instrumentation/InstrProfiling.cpp through the line:<br>
<br>
 Data->setAlignment(8);<br>
<br>
I also checked the size of the ProfileData struct during raw test file<br>
updates. It came up to be 40 bytes i.e. assigning 6 bytes of padding to<br>
the 34 byte actual ProfileData struct size on a 32 byte architectures.<br>
<br>
I just got my commit rights. I'll merge the patches once I have an LGTM on<br>
them.<br>
<span><font color="#888888"><br>
-Betul<br>
</font></span><span><br>
> This may not be true for 32 bit target.<br>
><br>
> David<br>
><br>
> On Sun, Nov 15, 2015 at 6:23 AM, Betul Buyukkurt <<a href="mailto:betulb@codeaurora.org" target="_blank">betulb@codeaurora.org</a><br>
</span><div><div>> <mailto:<a href="mailto:betulb@codeaurora.org" target="_blank">betulb@codeaurora.org</a>> > wrote:<br>
><br>
><br>
> betulb updated this revision to Diff 40236.<br>
> betulb added a comment.<br>
><br>
> In this revision:<br>
><br>
> - Removed padding computation after the Data section. It's not needed as<br>
> the<br>
> ProfileData struct is 8 byte aligned.<br>
><br>
><br>
><br>
> <a href="http://reviews.llvm.org/D9009" rel="noreferrer" target="_blank">http://reviews.llvm.org/D9009</a><br>
><br>
> Files:<br>
>   lib/profile/InstrProfiling.c<br>
>   lib/profile/InstrProfiling.h<br>
>   lib/profile/InstrProfilingBuffer.c<br>
>   lib/profile/InstrProfilingFile.c<br>
><br>
><br>
><br>
><br>
><br>
<br>
<br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>