<div dir="ltr">std::string's alignment is necessary because of its members' alignments - integers and pointers and such would generally have word alignment.<br><br>If you have an architecture where that's not true (where integers and pointers don't have word alignment) - there's probably some clang code that computes that alignment from those fundamental alignment operations. If I were looking for that code I'd start with a small example (not std::string - that's big and complicated) - such as a global int or pointer, and debug clang compiling that code & break on the GlobalVariable ctor - which presumably gets passed the alignment & then trace back through the code to see where the alignment value came from.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 6, 2021 at 10:50 AM Ryan Taylor <<a href="mailto:ryta1203@gmail.com">ryta1203@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Given a test case:</div><div><br></div><div>std::string test; // __attribute__((aligned(1)));<br><br>void foo() {<br> std::cout<<test<<std::endl;<br> return;<br>}<br></div><div><br></div><div>It looks like test is align 4:</div><div><br></div><div>@test = dso_local global %"class.std::basic_string" zeroinitializer, align 4<br></div><div><br></div><div><br><div><br></div><div> </div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 6, 2021 at 12:56 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">which string type? The alignment of the `char` type? Its size is 1, I don't think it's possible/reasonable to have an alignment greater than the size of the type (because then how do you have an array of such types?)</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 6, 2021 at 9:03 AM Ryan Taylor via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">How would I change the byte alignment of the string type from 1 byte to 4 bytes? I have little/no experience in that side of clang.<div><br></div><div>Thanks,</div><div><br></div><div>Ryan</div></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>