D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20652 - extern(C++) doesn't seem to mangle the types in core.simd right
Summary: extern(C++) doesn't seem to mangle the types in core.simd right
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull, SIMD
Depends on:
Blocks:
 
Reported: 2020-03-09 17:25 UTC by Manu
Modified: 2021-01-01 18:40 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Manu 2020-03-09 17:25:09 UTC
c++:
#include <immintrin.h>
void test(const __m128&) {}

d:
import core.simd;
extern(C++) void test(ref const float4);

void main()
{
  float4 f4;
  test(f4);
}


__mm128 doesn't seem to mangle right...
Comment 1 Walter Bright 2020-12-22 09:59:54 UTC
What does it mangle to and what should it mangle to?
Comment 2 Iain Buclaw 2020-12-30 12:15:12 UTC
And on what ABI?  MSVC++ or Itanium?
Comment 3 Dlang Bot 2020-12-30 12:42:42 UTC
@ibuclaw created dlang/dmd pull request #12080 "fix Issue 20652 - extern(C++) doesn't seem to mangle the types in core.simd right" fixing this issue:

- fix Issue 20652 - extern(C++) doesn't seem to mangle the types in core.simd right

https://github.com/dlang/dmd/pull/12080
Comment 4 Iain Buclaw 2020-12-30 12:54:58 UTC
(In reply to Iain Buclaw from comment #2)
> And on what ABI?  MSVC++ or Itanium?
I've just realised that there's still this in cppmangle.d

---
version (none)
{
    buf.writestring("Dv");
    buf.print((cast(TypeSArray *)t.basetype).dim.toInteger()); // -- Gnu ABI v.4
    buf.writeByte('_');
}
else
    buf.writestring("U8__vector"); //-- Gnu ABI v.3
---

I thought I dealt with this after introducing target.cpp.typeMangle().  A pull has been raised to enable the V4 ABI path.  The V4 ABI first appeared in g++ 4.5, and became the default in g++ 5.
Comment 5 Iain Buclaw 2020-12-30 18:07:34 UTC
According to the testsuite, it looks like the MSVC mangler is broken too, not just the Itanium one.

DMD: ?test20652@@YAXAET__m128@@@Z
MSVC: ?test20652@@YAXAEBT__m128@@@Z

The B looks to be for const, this has also been addressed in the PR.
Comment 6 Dlang Bot 2021-01-01 06:03:14 UTC
dlang/dmd pull request #12080 "fix Issue 20652 - extern(C++) doesn't seem to mangle the types in core.simd right" was merged into stable:

- 67cbcf1dceee5b7fd327a774b1a43b6c07175561 by Iain Buclaw:
  fix Issue 20652 - extern(C++) doesn't seem to mangle the types in core.simd right

https://github.com/dlang/dmd/pull/12080
Comment 7 Dlang Bot 2021-01-01 18:40:26 UTC
dlang/dmd pull request #12088 "merge stable" was merged into master:

- cd5c6d49f3c52945cf8d1eeca4d11db6555d2125 by Iain Buclaw:
  fix Issue 20652 - extern(C++) doesn't seem to mangle the types in core.simd right

https://github.com/dlang/dmd/pull/12088