@@ -290,20 +290,19 @@ static const Value *getPointerOperand(const Instruction *I,
290
290
return nullptr ;
291
291
}
292
292
293
- // / Helper function to create a pointer of type \p ResTy, based on \p Ptr, and
294
- // / advanced by \p Offset bytes. To aid later analysis the method tries to build
293
+ // / Helper function to create a pointer based on \p Ptr, and advanced by \p
294
+ // / Offset bytes. To aid later analysis the method tries to build
295
295
// / getelement pointer instructions that traverse the natural type of \p Ptr if
296
296
// / possible. If that fails, the remaining offset is adjusted byte-wise, hence
297
297
// / through a cast to i8*.
298
298
// /
299
299
// / TODO: This could probably live somewhere more prominantly if it doesn't
300
300
// / already exist.
301
- static Value *constructPointer (Type *ResTy, Type *PtrElemTy, Value *Ptr,
302
- int64_t Offset, IRBuilder<NoFolder> &IRB,
303
- const DataLayout &DL) {
301
+ static Value *constructPointer (Type *PtrElemTy, Value *Ptr, int64_t Offset,
302
+ IRBuilder<NoFolder> &IRB, const DataLayout &DL) {
304
303
assert (Offset >= 0 && " Negative offset not supported yet!" );
305
304
LLVM_DEBUG (dbgs () << " Construct pointer: " << *Ptr << " + " << Offset
306
- << " -bytes as " << *ResTy << " \n " );
305
+ << " -bytes\n " );
307
306
308
307
if (Offset) {
309
308
Type *Ty = PtrElemTy;
@@ -327,10 +326,6 @@ static Value *constructPointer(Type *ResTy, Type *PtrElemTy, Value *Ptr,
327
326
}
328
327
}
329
328
330
- // Ensure the result has the requested type.
331
- Ptr = IRB.CreatePointerBitCastOrAddrSpaceCast (Ptr, ResTy,
332
- Ptr->getName () + " .cast" );
333
-
334
329
LLVM_DEBUG (dbgs () << " Constructed pointer: " << *Ptr << " \n " );
335
330
return Ptr;
336
331
}
@@ -7492,19 +7487,16 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
7492
7487
if (auto *PrivStructType = dyn_cast<StructType>(PrivType)) {
7493
7488
const StructLayout *PrivStructLayout = DL.getStructLayout (PrivStructType);
7494
7489
for (unsigned u = 0 , e = PrivStructType->getNumElements (); u < e; u++) {
7495
- Type *PointeeTy = PrivStructType->getElementType (u)->getPointerTo ();
7496
- Value *Ptr =
7497
- constructPointer (PointeeTy, PrivType, &Base,
7498
- PrivStructLayout->getElementOffset (u), IRB, DL);
7490
+ Value *Ptr = constructPointer (
7491
+ PrivType, &Base, PrivStructLayout->getElementOffset (u), IRB, DL);
7499
7492
new StoreInst (F.getArg (ArgNo + u), Ptr, &IP);
7500
7493
}
7501
7494
} else if (auto *PrivArrayType = dyn_cast<ArrayType>(PrivType)) {
7502
7495
Type *PointeeTy = PrivArrayType->getElementType ();
7503
- Type *PointeePtrTy = PointeeTy->getPointerTo ();
7504
7496
uint64_t PointeeTySize = DL.getTypeStoreSize (PointeeTy);
7505
7497
for (unsigned u = 0 , e = PrivArrayType->getNumElements (); u < e; u++) {
7506
- Value *Ptr = constructPointer (PointeePtrTy, PrivType, &Base,
7507
- u * PointeeTySize, IRB, DL);
7498
+ Value *Ptr =
7499
+ constructPointer (PrivType, &Base, u * PointeeTySize, IRB, DL);
7508
7500
new StoreInst (F.getArg (ArgNo + u), Ptr, &IP);
7509
7501
}
7510
7502
} else {
@@ -7524,30 +7516,23 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
7524
7516
IRBuilder<NoFolder> IRB (IP);
7525
7517
const DataLayout &DL = IP->getModule ()->getDataLayout ();
7526
7518
7527
- Type *PrivPtrType = PrivType->getPointerTo ();
7528
- if (Base->getType () != PrivPtrType)
7529
- Base = BitCastInst::CreatePointerBitCastOrAddrSpaceCast (
7530
- Base, PrivPtrType, " " , ACS.getInstruction ());
7531
-
7532
7519
// Traverse the type, build GEPs and loads.
7533
7520
if (auto *PrivStructType = dyn_cast<StructType>(PrivType)) {
7534
7521
const StructLayout *PrivStructLayout = DL.getStructLayout (PrivStructType);
7535
7522
for (unsigned u = 0 , e = PrivStructType->getNumElements (); u < e; u++) {
7536
7523
Type *PointeeTy = PrivStructType->getElementType (u);
7537
- Value *Ptr =
7538
- constructPointer (PointeeTy->getPointerTo (), PrivType, Base,
7539
- PrivStructLayout->getElementOffset (u), IRB, DL);
7524
+ Value *Ptr = constructPointer (
7525
+ PrivType, Base, PrivStructLayout->getElementOffset (u), IRB, DL);
7540
7526
LoadInst *L = new LoadInst (PointeeTy, Ptr, " " , IP);
7541
7527
L->setAlignment (Alignment);
7542
7528
ReplacementValues.push_back (L);
7543
7529
}
7544
7530
} else if (auto *PrivArrayType = dyn_cast<ArrayType>(PrivType)) {
7545
7531
Type *PointeeTy = PrivArrayType->getElementType ();
7546
7532
uint64_t PointeeTySize = DL.getTypeStoreSize (PointeeTy);
7547
- Type *PointeePtrTy = PointeeTy->getPointerTo ();
7548
7533
for (unsigned u = 0 , e = PrivArrayType->getNumElements (); u < e; u++) {
7549
- Value *Ptr = constructPointer (PointeePtrTy, PrivType, Base,
7550
- u * PointeeTySize, IRB, DL);
7534
+ Value *Ptr =
7535
+ constructPointer (PrivType, Base, u * PointeeTySize, IRB, DL);
7551
7536
LoadInst *L = new LoadInst (PointeeTy, Ptr, " " , IP);
7552
7537
L->setAlignment (Alignment);
7553
7538
ReplacementValues.push_back (L);
0 commit comments