<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">That’s interesting (and slightly confusing) <br class=""><br class="">I could only see this happening if <b class="">Layout.getFieldOffset(idx)</b> would return a value greater than zero for the <b class="">b</b> member. (TargetInfo.cpp, line 3071)<div class=""><br class=""></div><div class="">However, that seemed unlikely… What I forgot to do though was to take C++ into account. It appears that for C++ the offset is indeed 8 for <b class="">b</b> (whereas for C it is 0). So then this behaviour is strictly something that can occur in C++ code.</div><div class=""><br class=""></div><div class="">This could possibly be added to the code as a comment to clarify it to readers.</div><div class=""><div class=""><br class=""><div class="">Christoffer<br class="">AEGIK / <a href="http://www.aegik.se" class="">www.aegik.se</a><br class=""></div><br class=""><blockquote type="cite" class="">On 12 Nov 2020, at 23:13, Craig Topper <<a href="mailto:craig.topper@gmail.com" class="">craig.topper@gmail.com</a>> wrote:<br class=""><br class="">Adding an assert(0) inside that if fires on this test case from clang/test/CodeGenCXX/x86_64-arguments.cpp<br class=""><br class="">// PR5831<br class="">// CHECK-LABEL: define void @_Z2f34s3_1(i64 %x.coerce)<br class="">struct s3_0 {};<br class="">struct s3_1 { struct s3_0 a; long b; };<br class="">void f3(struct s3_1 x) {}<br class=""><br class="">~Craig<br class=""><br class=""><br class="">On Thu, Nov 12, 2020 at 1:06 PM Christoffer Lernö via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:<br class="">I apologize for spamming with so many questions, but this really confusing me.<br class=""><br class="">In X86_64ABIInfo::classifyArgumentType we have this code:<br class=""><br class="">> case Integer:<br class="">> ++neededInt;<br class="">> // Pick an 8-byte type based on the preferred type.<br class="">> HighPart = GetINTEGERTypeAtOffset(CGT.ConvertType(Ty), 8, Ty, 8);<br class="">> <br class="">> if (Lo == NoClass) // Pass HighPart at offset 8 in memory.<br class="">> return ABIArgInfo::getDirect(HighPart, 8);<br class="">> break;<br class=""><br class="">Zooming in on the ”Lo == NoClass”. As far as I can tell this can only happen in the case where a struct has padding in front, and the first real integer parameter is actually 64 bits in.<br class=""><br class="">I admit I have no idea how to construct such a type in C to trigger this. Since Clang has a non-trivial amount of code to handle this I am wondering what I’m missing. (I’ve looked through the x86 test cases as well but was unable to find a test case for this particular situation. I might have overlooked something though)<br class=""><br class=""><br class="">/Christoffer<br class="">_______________________________________________<br class="">cfe-dev mailing list<br class="">cfe-dev@lists.llvm.org<br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></blockquote><br class=""></div></div></body></html>