41
41
#include " llvm/IR/MatrixBuilder.h"
42
42
#include " llvm/Passes/OptimizationLevel.h"
43
43
#include " llvm/Support/ConvertUTF.h"
44
- #include " llvm/Support/Endian.h"
45
44
#include " llvm/Support/MathExtras.h"
46
45
#include " llvm/Support/Path.h"
47
46
#include " llvm/Support/SaveAndRestore.h"
@@ -65,22 +64,6 @@ static llvm::cl::opt<bool> ClSanitizeGuardChecks(
65
64
" ubsan-guard-checks" , llvm::cl::Optional,
66
65
llvm::cl::desc (" Guard UBSAN checks with `llvm.allow.ubsan.check()`." ));
67
66
68
- // ===--------------------------------------------------------------------===//
69
- // Defines for metadata
70
- // ===--------------------------------------------------------------------===//
71
-
72
- // Those values are crucial to be the SAME as in ubsan runtime library.
73
- enum VariableTypeDescriptorKind : uint16_t {
74
- // / An integer type.
75
- TK_Integer = 0x0000 ,
76
- // / A floating-point type.
77
- TK_Float = 0x0001 ,
78
- // / An _BitInt(N) type.
79
- TK_BitInt = 0x0002 ,
80
- // / Any other type. The value representation is unspecified.
81
- TK_Unknown = 0xffff
82
- };
83
-
84
67
// ===--------------------------------------------------------------------===//
85
68
// Miscellaneous Helper Methods
86
69
// ===--------------------------------------------------------------------===//
@@ -3315,40 +3298,22 @@ LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) {
3315
3298
// / { i16 TypeKind, i16 TypeInfo }
3316
3299
// / \endcode
3317
3300
// /
3318
- // / followed by an array of i8 containing the type name with extra information
3319
- // / for BitInt. TypeKind is TK_Integer(0) for an integer, TK_Float(1) for a
3320
- // / floating point value, TK_BitInt(2) for BitInt and TK_Unknown(0xFFFF) for
3321
- // / anything else.
3301
+ // / followed by an array of i8 containing the type name. TypeKind is 0 for an
3302
+ // / integer, 1 for a floating point value, and -1 for anything else.
3322
3303
llvm::Constant *CodeGenFunction::EmitCheckTypeDescriptor (QualType T) {
3323
3304
// Only emit each type's descriptor once.
3324
3305
if (llvm::Constant *C = CGM.getTypeDescriptorFromMap (T))
3325
3306
return C;
3326
3307
3327
- uint16_t TypeKind = TK_Unknown ;
3308
+ uint16_t TypeKind = - 1 ;
3328
3309
uint16_t TypeInfo = 0 ;
3329
- bool IsBitInt = false ;
3330
3310
3331
3311
if (T->isIntegerType ()) {
3332
- TypeKind = TK_Integer ;
3312
+ TypeKind = 0 ;
3333
3313
TypeInfo = (llvm::Log2_32 (getContext ().getTypeSize (T)) << 1 ) |
3334
3314
(T->isSignedIntegerType () ? 1 : 0 );
3335
- // Follow suggestion from https://github.com/llvm/llvm-project/issues/64100
3336
- // So we can write the exact amount of bits in TypeName after '\0'
3337
- // making it <diagnostic-like type name>.'\0'.<32-bit width>.
3338
- if (T->isSignedIntegerType () && T->getAs <BitIntType>()) {
3339
- // Do a sanity checks as we are using 32-bit type to store bit length.
3340
- assert ((getContext ().getTypeSize (T) > 0 ) &&
3341
- " non positive amount of bits in __BitInt type" );
3342
- assert ((getContext ().getTypeSize (T) <= 0xFFFFFFFF ) &&
3343
- " too many bits in __BitInt type" );
3344
-
3345
- // Redefine TypeKind with the actual __BitInt type if we have signed
3346
- // BitInt.
3347
- TypeKind = TK_BitInt;
3348
- IsBitInt = true ;
3349
- }
3350
3315
} else if (T->isFloatingType ()) {
3351
- TypeKind = TK_Float ;
3316
+ TypeKind = 1 ;
3352
3317
TypeInfo = getContext ().getTypeSize (T);
3353
3318
}
3354
3319
@@ -3359,20 +3324,6 @@ llvm::Constant *CodeGenFunction::EmitCheckTypeDescriptor(QualType T) {
3359
3324
DiagnosticsEngine::ak_qualtype, (intptr_t )T.getAsOpaquePtr (), StringRef (),
3360
3325
StringRef (), std::nullopt, Buffer, std::nullopt);
3361
3326
3362
- if (IsBitInt) {
3363
- // The Structure is: 0 to end the string, 32 bit unsigned integer in target
3364
- // endianness, zero.
3365
- char S[6 ] = {' \0 ' , ' \0 ' , ' \0 ' , ' \0 ' , ' \0 ' , ' \0 ' };
3366
- const auto *EIT = T->castAs <BitIntType>();
3367
- uint32_t Bits = EIT->getNumBits ();
3368
- llvm::support::endian::write32 (S + 1 , Bits,
3369
- getTarget ().isBigEndian ()
3370
- ? llvm::endianness::big
3371
- : llvm::endianness::little);
3372
- StringRef str = StringRef (S, sizeof (S) / sizeof (decltype (S[0 ])));
3373
- Buffer.append (str);
3374
- }
3375
-
3376
3327
llvm::Constant *Components[] = {
3377
3328
Builder.getInt16 (TypeKind), Builder.getInt16 (TypeInfo),
3378
3329
llvm::ConstantDataArray::getString (getLLVMContext (), Buffer)
0 commit comments