This is an archive of the discontinued LLVM Phabricator instance.

[Mangler] Calculate the argument list byte count suffix correctly when returning large values
ClosedPublic

Authored by wesleywiser on Sep 29 2021, 8:07 AM.

Details

Summary

__stdcall, __fastcall and __vectorcall return large values via a hidden pointer argument. However, the size of that argument should not be included in the argument list byte count suffix added to the function's decorated name.

This patch fixes that issue so that LLVM generates the same decorated name as MSVC does.

MSVC example: https://godbolt.org/z/nc35MKPhr

Diff Detail

Event Timeline

wesleywiser created this revision.Sep 29 2021, 8:07 AM
wesleywiser requested review of this revision.Sep 29 2021, 8:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2021, 8:07 AM
rnk accepted this revision.Sep 29 2021, 10:48 AM

lgtm

For what it's worth, this issue is not observable from clang because clang does this mangling in the frontend. See https://godbolt.org/z/GM1Evjj3Y, it produces the function name \01_return_large@0. Looking at the code suggests that this is just an accident. It works because it is driven by the AST, which doesn't have the implicit sret parameter.

This revision is now accepted and ready to land.Sep 29 2021, 10:48 AM
rnk added a comment.Sep 29 2021, 10:49 AM

Should I go ahead and push this for you? I will include your email in the commit Author record unless you ask me not to.

Should I go ahead and push this for you? I will include your email in the commit Author record unless you ask me not to.

That would be great, thank you!

Are you concerned about the build failure? I've started trying to repro locally but I don't see off hand how my changes could cause that.

rnk added a comment.Sep 29 2021, 11:39 AM

Should I go ahead and push this for you? I will include your email in the commit Author record unless you ask me not to.

That would be great, thank you!

Thanks for the patch!

Are you concerned about the build failure? I've started trying to repro locally but I don't see off hand how my changes could cause that.

I'm pretty confident that it's unrelated. The sanitizer tests are probably flaky.

This revision was landed with ongoing or failed builds.Sep 29 2021, 11:42 AM
This revision was automatically updated to reflect the committed changes.