@@ -2914,7 +2914,8 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
2914
2914
2915
2915
// Do this after copyMetadataForLoad() to preserve the TBAA shift.
2916
2916
if (AATags)
2917
- NewLI->setAAMetadata (AATags.shift (NewBeginOffset - BeginOffset));
2917
+ NewLI->setAAMetadata (AATags.adjustForAccess (
2918
+ NewBeginOffset - BeginOffset, NewLI->getType (), DL));
2918
2919
2919
2920
// Try to preserve nonnull metadata
2920
2921
V = NewLI;
@@ -2935,8 +2936,11 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
2935
2936
LoadInst *NewLI =
2936
2937
IRB.CreateAlignedLoad (TargetTy, getNewAllocaSlicePtr (IRB, LTy),
2937
2938
getSliceAlign (), LI.isVolatile (), LI.getName ());
2939
+
2938
2940
if (AATags)
2939
- NewLI->setAAMetadata (AATags.shift (NewBeginOffset - BeginOffset));
2941
+ NewLI->setAAMetadata (AATags.adjustForAccess (
2942
+ NewBeginOffset - BeginOffset, NewLI->getType (), DL));
2943
+
2940
2944
if (LI.isVolatile ())
2941
2945
NewLI->setAtomic (LI.getOrdering (), LI.getSyncScopeID ());
2942
2946
NewLI->copyMetadata (LI, {LLVMContext::MD_mem_parallel_loop_access,
@@ -3011,7 +3015,8 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
3011
3015
Store->copyMetadata (SI, {LLVMContext::MD_mem_parallel_loop_access,
3012
3016
LLVMContext::MD_access_group});
3013
3017
if (AATags)
3014
- Store->setAAMetadata (AATags.shift (NewBeginOffset - BeginOffset));
3018
+ Store->setAAMetadata (AATags.adjustForAccess (NewBeginOffset - BeginOffset,
3019
+ V->getType (), DL));
3015
3020
Pass.DeadInsts .push_back (&SI);
3016
3021
3017
3022
// NOTE: Careful to use OrigV rather than V.
@@ -3038,7 +3043,8 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
3038
3043
Store->copyMetadata (SI, {LLVMContext::MD_mem_parallel_loop_access,
3039
3044
LLVMContext::MD_access_group});
3040
3045
if (AATags)
3041
- Store->setAAMetadata (AATags.shift (NewBeginOffset - BeginOffset));
3046
+ Store->setAAMetadata (AATags.adjustForAccess (NewBeginOffset - BeginOffset,
3047
+ V->getType (), DL));
3042
3048
3043
3049
migrateDebugInfo (&OldAI, IsSplit, NewBeginOffset * 8 , SliceSize * 8 , &SI,
3044
3050
Store, Store->getPointerOperand (),
@@ -3098,7 +3104,8 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
3098
3104
NewSI->copyMetadata (SI, {LLVMContext::MD_mem_parallel_loop_access,
3099
3105
LLVMContext::MD_access_group});
3100
3106
if (AATags)
3101
- NewSI->setAAMetadata (AATags.shift (NewBeginOffset - BeginOffset));
3107
+ NewSI->setAAMetadata (AATags.adjustForAccess (NewBeginOffset - BeginOffset,
3108
+ V->getType (), DL));
3102
3109
if (SI.isVolatile ())
3103
3110
NewSI->setAtomic (SI.getOrdering (), SI.getSyncScopeID ());
3104
3111
if (NewSI->isAtomic ())
@@ -3200,12 +3207,14 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
3200
3207
// a single value type, just emit a memset.
3201
3208
if (!CanContinue) {
3202
3209
Type *SizeTy = II.getLength ()->getType ();
3203
- Constant *Size = ConstantInt::get (SizeTy, NewEndOffset - NewBeginOffset);
3210
+ unsigned Sz = NewEndOffset - NewBeginOffset;
3211
+ Constant *Size = ConstantInt::get (SizeTy, Sz);
3204
3212
MemIntrinsic *New = cast<MemIntrinsic>(IRB.CreateMemSet (
3205
3213
getNewAllocaSlicePtr (IRB, OldPtr->getType ()), II.getValue (), Size ,
3206
3214
MaybeAlign (getSliceAlign ()), II.isVolatile ()));
3207
3215
if (AATags)
3208
- New->setAAMetadata (AATags.shift (NewBeginOffset - BeginOffset));
3216
+ New->setAAMetadata (
3217
+ AATags.adjustForAccess (NewBeginOffset - BeginOffset, Sz));
3209
3218
3210
3219
migrateDebugInfo (&OldAI, IsSplit, NewBeginOffset * 8 , SliceSize * 8 , &II,
3211
3220
New, New->getRawDest (), nullptr , DL);
@@ -3281,7 +3290,8 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
3281
3290
New->copyMetadata (II, {LLVMContext::MD_mem_parallel_loop_access,
3282
3291
LLVMContext::MD_access_group});
3283
3292
if (AATags)
3284
- New->setAAMetadata (AATags.shift (NewBeginOffset - BeginOffset));
3293
+ New->setAAMetadata (AATags.adjustForAccess (NewBeginOffset - BeginOffset,
3294
+ V->getType (), DL));
3285
3295
3286
3296
migrateDebugInfo (&OldAI, IsSplit, NewBeginOffset * 8 , SliceSize * 8 , &II,
3287
3297
New, New->getPointerOperand (), V, DL);
@@ -3486,7 +3496,8 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
3486
3496
Load->copyMetadata (II, {LLVMContext::MD_mem_parallel_loop_access,
3487
3497
LLVMContext::MD_access_group});
3488
3498
if (AATags)
3489
- Load->setAAMetadata (AATags.shift (NewBeginOffset - BeginOffset));
3499
+ Load->setAAMetadata (AATags.adjustForAccess (NewBeginOffset - BeginOffset,
3500
+ Load->getType (), DL));
3490
3501
Src = Load;
3491
3502
}
3492
3503
@@ -3508,7 +3519,8 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
3508
3519
Store->copyMetadata (II, {LLVMContext::MD_mem_parallel_loop_access,
3509
3520
LLVMContext::MD_access_group});
3510
3521
if (AATags)
3511
- Store->setAAMetadata (AATags.shift (NewBeginOffset - BeginOffset));
3522
+ Store->setAAMetadata (AATags.adjustForAccess (NewBeginOffset - BeginOffset,
3523
+ Src->getType (), DL));
3512
3524
3513
3525
APInt Offset (DL.getIndexTypeSizeInBits (DstPtr->getType ()), 0 );
3514
3526
if (IsDest) {
@@ -3836,7 +3848,8 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
3836
3848
DL.getIndexSizeInBits (Ptr ->getType ()->getPointerAddressSpace ()), 0 );
3837
3849
if (AATags &&
3838
3850
GEPOperator::accumulateConstantOffset (BaseTy, GEPIndices, DL, Offset))
3839
- Load->setAAMetadata (AATags.shift (Offset.getZExtValue ()));
3851
+ Load->setAAMetadata (
3852
+ AATags.adjustForAccess (Offset.getZExtValue (), Load->getType (), DL));
3840
3853
3841
3854
Agg = IRB.CreateInsertValue (Agg, Load, Indices, Name + " .insert" );
3842
3855
LLVM_DEBUG (dbgs () << " to: " << *Load << " \n " );
@@ -3887,8 +3900,10 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
3887
3900
APInt Offset (
3888
3901
DL.getIndexSizeInBits (Ptr ->getType ()->getPointerAddressSpace ()), 0 );
3889
3902
GEPOperator::accumulateConstantOffset (BaseTy, GEPIndices, DL, Offset);
3890
- if (AATags)
3891
- Store->setAAMetadata (AATags.shift (Offset.getZExtValue ()));
3903
+ if (AATags) {
3904
+ Store->setAAMetadata (AATags.adjustForAccess (
3905
+ Offset.getZExtValue (), ExtractValue->getType (), DL));
3906
+ }
3892
3907
3893
3908
// migrateDebugInfo requires the base Alloca. Walk to it from this gep.
3894
3909
// If we cannot (because there's an intervening non-const or unbounded
@@ -4542,6 +4557,7 @@ bool SROA::presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS) {
4542
4557
4543
4558
Value *StoreBasePtr = SI->getPointerOperand ();
4544
4559
IRB.SetInsertPoint (SI);
4560
+ AAMDNodes AATags = SI->getAAMetadata ();
4545
4561
4546
4562
LLVM_DEBUG (dbgs () << " Splitting store of load: " << *SI << " \n " );
4547
4563
@@ -4561,6 +4577,10 @@ bool SROA::presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS) {
4561
4577
PStore->copyMetadata (*SI, {LLVMContext::MD_mem_parallel_loop_access,
4562
4578
LLVMContext::MD_access_group,
4563
4579
LLVMContext::MD_DIAssignID});
4580
+
4581
+ if (AATags)
4582
+ PStore->setAAMetadata (
4583
+ AATags.adjustForAccess (PartOffset, PLoad->getType (), DL));
4564
4584
LLVM_DEBUG (dbgs () << " +" << PartOffset << " :" << *PStore << " \n " );
4565
4585
}
4566
4586
0 commit comments