[clang] [compiler-rt] [ubsan] Display correct runtime messages for negative _BitInt (PR #96240)
Jakub JelĂnek via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 23 14:41:26 PDT 2024
================
@@ -125,6 +137,25 @@ class TypeDescriptor {
return 1 << (TypeInfo >> 1);
}
+ const char *getBitIntBitCountPointer() const {
+ DCHECK(isBitIntTy());
+ DCHECK(isSignedBitIntTy());
+ // Scan Name for zero and return the next address
+ const char *p = getTypeName();
+ while (*p != '\0')
+ ++p;
+ // Return the next address
+ return p + 1;
+ }
+
+ unsigned getIntegerBitCount() const {
+ DCHECK(isIntegerTy());
+ if (isSignedBitIntTy())
+ return *reinterpret_cast<const u32 *>(getBitIntBitCountPointer());
----------------
jakubjelinek wrote:
This will not work on strict alignment targets. I'd suggest instead of trying to reinterpret the bits memcpy them into u32 and return that, the compilers will optimize that properly.
https://github.com/llvm/llvm-project/pull/96240
More information about the llvm-commits
mailing list