@@ -60,15 +60,6 @@ Type *IRBuilderBase::getCurrentFunctionReturnType() const {
60
60
return BB->getParent ()->getReturnType ();
61
61
}
62
62
63
- Value *IRBuilderBase::getCastedInt8PtrValue (Value *Ptr) {
64
- auto *PT = cast<PointerType>(Ptr->getType ());
65
- if (PT->isOpaqueOrPointeeTypeMatches (getInt8Ty ()))
66
- return Ptr;
67
-
68
- // Otherwise, we need to insert a bitcast.
69
- return CreateBitCast (Ptr, getInt8PtrTy (PT->getAddressSpace ()));
70
- }
71
-
72
63
DebugLoc IRBuilderBase::getCurrentDebugLocation () const {
73
64
for (auto &KV : MetadataToCopy)
74
65
if (KV.first == LLVMContext::MD_dbg)
@@ -147,7 +138,6 @@ CallInst *IRBuilderBase::CreateMemSet(Value *Ptr, Value *Val, Value *Size,
147
138
MaybeAlign Align, bool isVolatile,
148
139
MDNode *TBAATag, MDNode *ScopeTag,
149
140
MDNode *NoAliasTag) {
150
- Ptr = getCastedInt8PtrValue (Ptr);
151
141
Value *Ops[] = {Ptr, Val, Size, getInt1 (isVolatile)};
152
142
Type *Tys[] = { Ptr->getType (), Size->getType () };
153
143
Module *M = BB->getParent ()->getParent ();
@@ -176,7 +166,6 @@ CallInst *IRBuilderBase::CreateMemSetInline(Value *Dst, MaybeAlign DstAlign,
176
166
bool IsVolatile, MDNode *TBAATag,
177
167
MDNode *ScopeTag,
178
168
MDNode *NoAliasTag) {
179
- Dst = getCastedInt8PtrValue (Dst);
180
169
Value *Ops[] = {Dst, Val, Size, getInt1 (IsVolatile)};
181
170
Type *Tys[] = {Dst->getType (), Size->getType ()};
182
171
Module *M = BB->getParent ()->getParent ();
@@ -204,7 +193,6 @@ CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemSet(
204
193
Value *Ptr, Value *Val, Value *Size, Align Alignment, uint32_t ElementSize,
205
194
MDNode *TBAATag, MDNode *ScopeTag, MDNode *NoAliasTag) {
206
195
207
- Ptr = getCastedInt8PtrValue (Ptr);
208
196
Value *Ops[] = {Ptr, Val, Size, getInt32 (ElementSize)};
209
197
Type *Tys[] = {Ptr->getType (), Size->getType ()};
210
198
Module *M = BB->getParent ()->getParent ();
@@ -232,9 +220,6 @@ CallInst *IRBuilderBase::CreateMemTransferInst(
232
220
Intrinsic::ID IntrID, Value *Dst, MaybeAlign DstAlign, Value *Src,
233
221
MaybeAlign SrcAlign, Value *Size, bool isVolatile, MDNode *TBAATag,
234
222
MDNode *TBAAStructTag, MDNode *ScopeTag, MDNode *NoAliasTag) {
235
- Dst = getCastedInt8PtrValue (Dst);
236
- Src = getCastedInt8PtrValue (Src);
237
-
238
223
Value *Ops[] = {Dst, Src, Size, getInt1 (isVolatile)};
239
224
Type *Tys[] = { Dst->getType (), Src->getType (), Size->getType () };
240
225
Module *M = BB->getParent ()->getParent ();
@@ -269,9 +254,6 @@ CallInst *IRBuilderBase::CreateMemCpyInline(
269
254
Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign,
270
255
Value *Size, bool IsVolatile, MDNode *TBAATag, MDNode *TBAAStructTag,
271
256
MDNode *ScopeTag, MDNode *NoAliasTag) {
272
- Dst = getCastedInt8PtrValue (Dst);
273
- Src = getCastedInt8PtrValue (Src);
274
-
275
257
Value *Ops[] = {Dst, Src, Size, getInt1 (IsVolatile)};
276
258
Type *Tys[] = {Dst->getType (), Src->getType (), Size->getType ()};
277
259
Function *F = BB->getParent ();
@@ -311,9 +293,6 @@ CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemCpy(
311
293
" Pointer alignment must be at least element size" );
312
294
assert (SrcAlign >= ElementSize &&
313
295
" Pointer alignment must be at least element size" );
314
- Dst = getCastedInt8PtrValue (Dst);
315
- Src = getCastedInt8PtrValue (Src);
316
-
317
296
Value *Ops[] = {Dst, Src, Size, getInt32 (ElementSize)};
318
297
Type *Tys[] = {Dst->getType (), Src->getType (), Size->getType ()};
319
298
Module *M = BB->getParent ()->getParent ();
@@ -349,9 +328,6 @@ CallInst *IRBuilderBase::CreateMemMove(Value *Dst, MaybeAlign DstAlign,
349
328
Value *Size, bool isVolatile,
350
329
MDNode *TBAATag, MDNode *ScopeTag,
351
330
MDNode *NoAliasTag) {
352
- Dst = getCastedInt8PtrValue (Dst);
353
- Src = getCastedInt8PtrValue (Src);
354
-
355
331
Value *Ops[] = {Dst, Src, Size, getInt1 (isVolatile)};
356
332
Type *Tys[] = { Dst->getType (), Src->getType (), Size->getType () };
357
333
Module *M = BB->getParent ()->getParent ();
@@ -386,9 +362,6 @@ CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemMove(
386
362
" Pointer alignment must be at least element size" );
387
363
assert (SrcAlign >= ElementSize &&
388
364
" Pointer alignment must be at least element size" );
389
- Dst = getCastedInt8PtrValue (Dst);
390
- Src = getCastedInt8PtrValue (Src);
391
-
392
365
Value *Ops[] = {Dst, Src, Size, getInt32 (ElementSize)};
393
366
Type *Tys[] = {Dst->getType (), Src->getType (), Size->getType ()};
394
367
Module *M = BB->getParent ()->getParent ();
@@ -493,7 +466,6 @@ CallInst *IRBuilderBase::CreateFPMinimumReduce(Value *Src) {
493
466
CallInst *IRBuilderBase::CreateLifetimeStart (Value *Ptr, ConstantInt *Size) {
494
467
assert (isa<PointerType>(Ptr->getType ()) &&
495
468
" lifetime.start only applies to pointers." );
496
- Ptr = getCastedInt8PtrValue (Ptr);
497
469
if (!Size)
498
470
Size = getInt64 (-1 );
499
471
else
@@ -509,7 +481,6 @@ CallInst *IRBuilderBase::CreateLifetimeStart(Value *Ptr, ConstantInt *Size) {
509
481
CallInst *IRBuilderBase::CreateLifetimeEnd (Value *Ptr, ConstantInt *Size) {
510
482
assert (isa<PointerType>(Ptr->getType ()) &&
511
483
" lifetime.end only applies to pointers." );
512
- Ptr = getCastedInt8PtrValue (Ptr);
513
484
if (!Size)
514
485
Size = getInt64 (-1 );
515
486
else
@@ -526,7 +497,6 @@ CallInst *IRBuilderBase::CreateInvariantStart(Value *Ptr, ConstantInt *Size) {
526
497
527
498
assert (isa<PointerType>(Ptr->getType ()) &&
528
499
" invariant.start only applies to pointers." );
529
- Ptr = getCastedInt8PtrValue (Ptr);
530
500
if (!Size)
531
501
Size = getInt64 (-1 );
532
502
else
@@ -606,7 +576,6 @@ CallInst *IRBuilderBase::CreateMaskedLoad(Type *Ty, Value *Ptr, Align Alignment,
606
576
const Twine &Name) {
607
577
auto *PtrTy = cast<PointerType>(Ptr->getType ());
608
578
assert (Ty->isVectorTy () && " Type should be vector" );
609
- assert (PtrTy->isOpaqueOrPointeeTypeMatches (Ty) && " Wrong element type" );
610
579
assert (Mask && " Mask should not be all-ones (null)" );
611
580
if (!PassThru)
612
581
PassThru = PoisonValue::get (Ty);
@@ -627,7 +596,6 @@ CallInst *IRBuilderBase::CreateMaskedStore(Value *Val, Value *Ptr,
627
596
auto *PtrTy = cast<PointerType>(Ptr->getType ());
628
597
Type *DataTy = Val->getType ();
629
598
assert (DataTy->isVectorTy () && " Val should be a vector" );
630
- assert (PtrTy->isOpaqueOrPointeeTypeMatches (DataTy) && " Wrong element type" );
631
599
assert (Mask && " Mask should not be all-ones (null)" );
632
600
Type *OverloadedTypes[] = { DataTy, PtrTy };
633
601
Value *Ops[] = {Val, Ptr, getInt32 (Alignment.value ()), Mask};
@@ -662,10 +630,6 @@ CallInst *IRBuilderBase::CreateMaskedGather(Type *Ty, Value *Ptrs,
662
630
auto *VecTy = cast<VectorType>(Ty);
663
631
ElementCount NumElts = VecTy->getElementCount ();
664
632
auto *PtrsTy = cast<VectorType>(Ptrs->getType ());
665
- assert (cast<PointerType>(PtrsTy->getElementType ())
666
- ->isOpaqueOrPointeeTypeMatches (
667
- cast<VectorType>(Ty)->getElementType ()) &&
668
- " Element type mismatch" );
669
633
assert (NumElts == PtrsTy->getElementCount () && " Element count mismatch" );
670
634
671
635
if (!Mask)
@@ -696,13 +660,6 @@ CallInst *IRBuilderBase::CreateMaskedScatter(Value *Data, Value *Ptrs,
696
660
auto *DataTy = cast<VectorType>(Data->getType ());
697
661
ElementCount NumElts = PtrsTy->getElementCount ();
698
662
699
- #ifndef NDEBUG
700
- auto *PtrTy = cast<PointerType>(PtrsTy->getElementType ());
701
- assert (NumElts == DataTy->getElementCount () &&
702
- PtrTy->isOpaqueOrPointeeTypeMatches (DataTy->getElementType ()) &&
703
- " Incompatible pointer and data types" );
704
- #endif
705
-
706
663
if (!Mask)
707
664
Mask = getAllOnesMask (NumElts);
708
665
@@ -725,12 +682,7 @@ CallInst *IRBuilderBase::CreateMaskedScatter(Value *Data, Value *Ptrs,
725
682
CallInst *IRBuilderBase::CreateMaskedExpandLoad (Type *Ty, Value *Ptr,
726
683
Value *Mask, Value *PassThru,
727
684
const Twine &Name) {
728
- auto *PtrTy = cast<PointerType>(Ptr->getType ());
729
685
assert (Ty->isVectorTy () && " Type should be vector" );
730
- assert (PtrTy->isOpaqueOrPointeeTypeMatches (
731
- cast<FixedVectorType>(Ty)->getElementType ()) &&
732
- " Wrong element type" );
733
- (void )PtrTy;
734
686
assert (Mask && " Mask should not be all-ones (null)" );
735
687
if (!PassThru)
736
688
PassThru = PoisonValue::get (Ty);
@@ -747,13 +699,8 @@ CallInst *IRBuilderBase::CreateMaskedExpandLoad(Type *Ty, Value *Ptr,
747
699
// / be accessed in memory
748
700
CallInst *IRBuilderBase::CreateMaskedCompressStore (Value *Val, Value *Ptr,
749
701
Value *Mask) {
750
- auto *PtrTy = cast<PointerType>(Ptr->getType ());
751
702
Type *DataTy = Val->getType ();
752
703
assert (DataTy->isVectorTy () && " Val should be a vector" );
753
- assert (PtrTy->isOpaqueOrPointeeTypeMatches (
754
- cast<FixedVectorType>(DataTy)->getElementType ()) &&
755
- " Wrong element type" );
756
- (void )PtrTy;
757
704
assert (Mask && " Mask should not be all-ones (null)" );
758
705
Type *OverloadedTypes[] = {DataTy};
759
706
Value *Ops[] = {Val, Ptr, Mask};
@@ -1174,9 +1121,6 @@ Value *IRBuilderBase::CreatePtrDiff(Type *ElemTy, Value *LHS, Value *RHS,
1174
1121
const Twine &Name) {
1175
1122
assert (LHS->getType () == RHS->getType () &&
1176
1123
" Pointer subtraction operand types must match!" );
1177
- assert (cast<PointerType>(LHS->getType ())
1178
- ->isOpaqueOrPointeeTypeMatches (ElemTy) &&
1179
- " Pointer type must match element type" );
1180
1124
Value *LHS_int = CreatePtrToInt (LHS, Type::getInt64Ty (Context));
1181
1125
Value *RHS_int = CreatePtrToInt (RHS, Type::getInt64Ty (Context));
1182
1126
Value *Difference = CreateSub (LHS_int, RHS_int);
@@ -1187,50 +1131,34 @@ Value *IRBuilderBase::CreatePtrDiff(Type *ElemTy, Value *LHS, Value *RHS,
1187
1131
Value *IRBuilderBase::CreateLaunderInvariantGroup (Value *Ptr) {
1188
1132
assert (isa<PointerType>(Ptr->getType ()) &&
1189
1133
" launder.invariant.group only applies to pointers." );
1190
- // FIXME: we could potentially avoid casts to/from i8*.
1191
1134
auto *PtrType = Ptr->getType ();
1192
- auto *Int8PtrTy = getInt8PtrTy (PtrType->getPointerAddressSpace ());
1193
- if (PtrType != Int8PtrTy)
1194
- Ptr = CreateBitCast (Ptr, Int8PtrTy);
1195
1135
Module *M = BB->getParent ()->getParent ();
1196
1136
Function *FnLaunderInvariantGroup = Intrinsic::getDeclaration (
1197
- M, Intrinsic::launder_invariant_group, {Int8PtrTy });
1137
+ M, Intrinsic::launder_invariant_group, {PtrType });
1198
1138
1199
- assert (FnLaunderInvariantGroup->getReturnType () == Int8PtrTy &&
1139
+ assert (FnLaunderInvariantGroup->getReturnType () == PtrType &&
1200
1140
FnLaunderInvariantGroup->getFunctionType ()->getParamType (0 ) ==
1201
- Int8PtrTy &&
1141
+ PtrType &&
1202
1142
" LaunderInvariantGroup should take and return the same type" );
1203
1143
1204
- CallInst *Fn = CreateCall (FnLaunderInvariantGroup, {Ptr});
1205
-
1206
- if (PtrType != Int8PtrTy)
1207
- return CreateBitCast (Fn, PtrType);
1208
- return Fn;
1144
+ return CreateCall (FnLaunderInvariantGroup, {Ptr});
1209
1145
}
1210
1146
1211
1147
Value *IRBuilderBase::CreateStripInvariantGroup (Value *Ptr) {
1212
1148
assert (isa<PointerType>(Ptr->getType ()) &&
1213
1149
" strip.invariant.group only applies to pointers." );
1214
1150
1215
- // FIXME: we could potentially avoid casts to/from i8*.
1216
1151
auto *PtrType = Ptr->getType ();
1217
- auto *Int8PtrTy = getInt8PtrTy (PtrType->getPointerAddressSpace ());
1218
- if (PtrType != Int8PtrTy)
1219
- Ptr = CreateBitCast (Ptr, Int8PtrTy);
1220
1152
Module *M = BB->getParent ()->getParent ();
1221
1153
Function *FnStripInvariantGroup = Intrinsic::getDeclaration (
1222
- M, Intrinsic::strip_invariant_group, {Int8PtrTy });
1154
+ M, Intrinsic::strip_invariant_group, {PtrType });
1223
1155
1224
- assert (FnStripInvariantGroup->getReturnType () == Int8PtrTy &&
1156
+ assert (FnStripInvariantGroup->getReturnType () == PtrType &&
1225
1157
FnStripInvariantGroup->getFunctionType ()->getParamType (0 ) ==
1226
- Int8PtrTy &&
1158
+ PtrType &&
1227
1159
" StripInvariantGroup should take and return the same type" );
1228
1160
1229
- CallInst *Fn = CreateCall (FnStripInvariantGroup, {Ptr});
1230
-
1231
- if (PtrType != Int8PtrTy)
1232
- return CreateBitCast (Fn, PtrType);
1233
- return Fn;
1161
+ return CreateCall (FnStripInvariantGroup, {Ptr});
1234
1162
}
1235
1163
1236
1164
Value *IRBuilderBase::CreateVectorReverse (Value *V, const Twine &Name) {
@@ -1326,8 +1254,6 @@ Value *IRBuilderBase::CreatePreserveArrayAccessIndex(
1326
1254
auto *BaseType = Base->getType ();
1327
1255
assert (isa<PointerType>(BaseType) &&
1328
1256
" Invalid Base ptr type for preserve.array.access.index." );
1329
- assert (cast<PointerType>(BaseType)->isOpaqueOrPointeeTypeMatches (ElTy) &&
1330
- " Pointer element type mismatch" );
1331
1257
1332
1258
Value *LastIndexV = getInt32 (LastIndex);
1333
1259
Constant *Zero = ConstantInt::get (Type::getInt32Ty (Context), 0 );
@@ -1377,8 +1303,6 @@ Value *IRBuilderBase::CreatePreserveStructAccessIndex(
1377
1303
auto *BaseType = Base->getType ();
1378
1304
assert (isa<PointerType>(BaseType) &&
1379
1305
" Invalid Base ptr type for preserve.struct.access.index." );
1380
- assert (cast<PointerType>(BaseType)->isOpaqueOrPointeeTypeMatches (ElTy) &&
1381
- " Pointer element type mismatch" );
1382
1306
1383
1307
Value *GEPIndex = getInt32 (Index);
1384
1308
Constant *Zero = ConstantInt::get (Type::getInt32Ty (Context), 0 );
0 commit comments