-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[compiler-rt] Make sure __clzdi2 doesn't call itself recursively on sparc64 #136737
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,12 +14,12 @@ | |
|
||
// Returns: the number of leading 0-bits | ||
|
||
#if !defined(__clang__) && \ | ||
((defined(__sparc__) && defined(__arch64__)) || defined(__mips64) || \ | ||
#if ((defined(__sparc__) && defined(__arch64__)) || defined(__mips64) || \ | ||
(defined(__riscv) && __SIZEOF_POINTER__ >= 8)) | ||
// On 64-bit architectures with neither a native clz instruction nor a native | ||
// ctz instruction, gcc resolves __builtin_clz to __clzdi2 rather than | ||
// __clzsi2, leading to infinite recursion. | ||
// ctz instruction, `__builtin_clz` resolves to `__clzdi2` rather than | ||
// __clzsi2 as libgcc does not ship with `__clzsi2`, leading to infinite | ||
// recursion. | ||
Comment on lines
+20
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That doesn't seem to be true on RISC-V/Mips (clang). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, looking at the respective backends, seems like they are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could rewrite the check so that the clang check is omitted only if compiling on SPARC, but wouldn't that be too complicated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with any solution as long as it doesn't break/pessimize other targets. |
||
#define __builtin_clz(a) __clzsi2(a) | ||
compnerd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
extern int __clzsi2(si_int); | ||
#endif | ||
|
Uh oh!
There was an error while loading. Please reload this page.