This is an archive of the discontinued LLVM Phabricator instance.

Mangle calling conventions into function pointer types where GCC does
ClosedPublic

Authored by rnk on Dec 13 2018, 2:06 PM.

Details

Summary

GCC 5.1 began mangling these Windows calling conventions into function
types, since they can be used for overloading. They've always been
mangled in the MS ABI, but they are new to the Itanium mangler. Note
that the calling convention doesn't appear as part of the main
declaration, it only appears on function parameter types and other
types.

Fixes PR39860

Diff Detail

Repository
rL LLVM

Event Timeline

rnk created this revision.Dec 13 2018, 2:06 PM
rnk planned changes to this revision.Dec 13 2018, 2:07 PM

I guess that was premature, I suppose I should test these cases John enumerated:

I think some basic validation of that is probably called for before committing. The obvious places to check:

  • a function pointer type
  • a function reference type
  • a member function pointer type
  • a template argument that's just a function type, not a function pointer or reference type
  • a function that happens to be declared with this calling convention (this probably shouldn't include the CC in the mangling, and if GCC mangles this it should probably be considered a bug)
  • a specialization of a function template that happens to be declared with this calling convention (this also probably shouldn't include the CC in the mangling, but it's okay to match GCC if it does)
rnk updated this revision to Diff 178137.Dec 13 2018, 2:20 PM
  • add more tests
rnk added a comment.Dec 13 2018, 2:24 PM
In D55672#1330402, @rnk wrote:
  • a specialization of a function template that happens to be declared with this calling convention (this also probably shouldn't include the CC in the mangling, but it's okay to match GCC if it does)

I didn't add a test for this special case, since we don't mangle ccs into normal functions. I don't think making a function specialization template is likely to cause us to suddenly emit the convention.

Thanks. I think you missed these, though:

  • a template argument that's just a function type, not a function pointer or reference type
  • a specialization of a function template that happens to be declared with this calling convention (this also probably shouldn't include the CC in the mangling, but it's okay to match GCC if it does)
In D55672#1330458, @rnk wrote:
In D55672#1330402, @rnk wrote:
  • a specialization of a function template that happens to be declared with this calling convention (this also probably shouldn't include the CC in the mangling, but it's okay to match GCC if it does)

I didn't add a test for this special case, since we don't mangle ccs into normal functions. I don't think making a function specialization template is likely to cause us to suddenly emit the convention.

Tests are good! Also, we do mangle more things from a function template specialization, like the return type and other things that might trigger SFINAE conditions; it's not the same code path.

rnk updated this revision to Diff 178138.Dec 13 2018, 2:38 PM
  • more tests
rnk added a comment.Dec 13 2018, 2:38 PM

Thanks. I think you missed these, though:

  • a template argument that's just a function type, not a function pointer or reference type

I think useTemplateFnType is supposed to handle that case.

Tests are good! Also, we do mangle more things from a function template specialization, like the return type and other things that might trigger SFINAE conditions; it's not the same code path.

Fair enough, hopefully these are what you had in mind.

rnk updated this revision to Diff 178144.Dec 13 2018, 3:04 PM
  • Add ms_abi and sysv_abi tests to match GCC
rjmccall accepted this revision.Dec 13 2018, 7:31 PM

Thanks, that looks great.

This revision is now accepted and ready to land.Dec 13 2018, 7:31 PM
This revision was automatically updated to reflect the committed changes.