Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I found memcpySmallAllowReadWriteOverflow15Impl will call built-in memcpy because of clang loop-idiom optimization. It is as expected, or an issue? #61074

Closed
taiyang-li opened this issue Mar 8, 2024 · 5 comments · Fixed by #61075

Comments

@taiyang-li
Copy link
Contributor

dc4d586ae2a041a2e992185fc004747

https://godbolt.org/z/YxM3rc7Eh

@taiyang-li taiyang-li changed the title I found memcpySmallAllowReadWriteOverflow15Impl will call built-in memcpy because of clang loop-idiom optimization. It is as expected? I found memcpySmallAllowReadWriteOverflow15Impl will call built-in memcpy because of clang loop-idiom optimization. It is as expected, or issue? Mar 8, 2024
@taiyang-li taiyang-li changed the title I found memcpySmallAllowReadWriteOverflow15Impl will call built-in memcpy because of clang loop-idiom optimization. It is as expected, or issue? I found memcpySmallAllowReadWriteOverflow15Impl will call built-in memcpy because of clang loop-idiom optimization. It is as expected, or an issue? Mar 8, 2024
@alexey-milovidov
Copy link
Member

Not expected. We already noticed this behavior in GCC a long time ago, but not in Clang:
https://presentations.clickhouse.com/zero_cost_conf/memcpy/#11

@nickitat
Copy link
Member

nickitat commented Mar 8, 2024

it is known
llvm/llvm-project#56467

@alexey-milovidov
Copy link
Member

@taiyang-li, let's use [[clang::no_builtin("memcpy")]] to better express the intent.

@taiyang-li
Copy link
Contributor Author

@taiyang-li, let's use [[clang::no_builtin("memcpy")]] to better express the intent.

i tried before, but the function won't be inlined, which is slow. if i add always inline attribute, the compiler will compain with an error.

@alexey-milovidov
Copy link
Member

Ok, then your approach will suffice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants