Skip to content

ms: _byteswap_ulong etc intrinsic generate calls #48384

@nico

Description

@nico
Bugzilla Link 49040
Version unspecified
OS Linux
CC @topperc,@RKSimon,@zygoloid,@rnk

Extended Description

$ cat bswap.cc
#include <stdint.h>
#include <intrin.h>

int32_t ByteSwap(uint32_t x) {
return _byteswap_ulong(x);
}

$ out/gn/bin/clang-cl /FA /c bswap.cc /O2 /winsysroot ~/src/chrome/src/third_party/depot_tools/win_toolchain/vs_files/782813b4eb/
$ cat bswap.asm
...
"?ByteSwap@@yahi@Z": # @"?ByteSwap@@yahi@Z"

%bb.0: # %entry

jmp	_byteswap_ulong                 # TAILCALL
                                    # -- End function

Compare to https://godbolt.org/z/97YjTT in MSVC.

Our clang/lib/Headers/intrin.h only has a declaration for these functions in arm64 mode for some reason. So how does this even build? => Windows Kits/10/Include/10.0.19041.0/ucrt/stdlib.h declares these too.

So I guess we should put these in intrin.h, with an inline definition?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:headersHeaders provided by Clang, e.g. for intrinsics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions