@@ -2524,7 +2524,7 @@ class llvm::sroa::AllocaSliceRewriter
2524
2524
NewAI.getAlign (), LI.isVolatile (),
2525
2525
LI.getName ());
2526
2526
if (AATags)
2527
- NewLI->setAAMetadata (AATags);
2527
+ NewLI->setAAMetadata (AATags. shift (NewBeginOffset - BeginOffset) );
2528
2528
if (LI.isVolatile ())
2529
2529
NewLI->setAtomic (LI.getOrdering (), LI.getSyncScopeID ());
2530
2530
if (NewLI->isAtomic ())
@@ -2563,7 +2563,7 @@ class llvm::sroa::AllocaSliceRewriter
2563
2563
IRB.CreateAlignedLoad (TargetTy, getNewAllocaSlicePtr (IRB, LTy),
2564
2564
getSliceAlign (), LI.isVolatile (), LI.getName ());
2565
2565
if (AATags)
2566
- NewLI->setAAMetadata (AATags);
2566
+ NewLI->setAAMetadata (AATags. shift (NewBeginOffset - BeginOffset) );
2567
2567
if (LI.isVolatile ())
2568
2568
NewLI->setAtomic (LI.getOrdering (), LI.getSyncScopeID ());
2569
2569
@@ -2626,7 +2626,7 @@ class llvm::sroa::AllocaSliceRewriter
2626
2626
}
2627
2627
StoreInst *Store = IRB.CreateAlignedStore (V, &NewAI, NewAI.getAlign ());
2628
2628
if (AATags)
2629
- Store->setAAMetadata (AATags);
2629
+ Store->setAAMetadata (AATags. shift (NewBeginOffset - BeginOffset) );
2630
2630
Pass.DeadInsts .push_back (&SI);
2631
2631
2632
2632
LLVM_DEBUG (dbgs () << " to: " << *Store << " \n " );
@@ -2650,7 +2650,7 @@ class llvm::sroa::AllocaSliceRewriter
2650
2650
Store->copyMetadata (SI, {LLVMContext::MD_mem_parallel_loop_access,
2651
2651
LLVMContext::MD_access_group});
2652
2652
if (AATags)
2653
- Store->setAAMetadata (AATags);
2653
+ Store->setAAMetadata (AATags. shift (NewBeginOffset - BeginOffset) );
2654
2654
Pass.DeadInsts .push_back (&SI);
2655
2655
LLVM_DEBUG (dbgs () << " to: " << *Store << " \n " );
2656
2656
return true ;
@@ -2720,7 +2720,7 @@ class llvm::sroa::AllocaSliceRewriter
2720
2720
NewSI->copyMetadata (SI, {LLVMContext::MD_mem_parallel_loop_access,
2721
2721
LLVMContext::MD_access_group});
2722
2722
if (AATags)
2723
- NewSI->setAAMetadata (AATags);
2723
+ NewSI->setAAMetadata (AATags. shift (NewBeginOffset - BeginOffset) );
2724
2724
if (SI.isVolatile ())
2725
2725
NewSI->setAtomic (SI.getOrdering (), SI.getSyncScopeID ());
2726
2726
if (NewSI->isAtomic ())
@@ -2816,7 +2816,7 @@ class llvm::sroa::AllocaSliceRewriter
2816
2816
getNewAllocaSlicePtr (IRB, OldPtr->getType ()), II.getValue (), Size,
2817
2817
MaybeAlign (getSliceAlign ()), II.isVolatile ());
2818
2818
if (AATags)
2819
- New->setAAMetadata (AATags);
2819
+ New->setAAMetadata (AATags. shift (NewBeginOffset - BeginOffset) );
2820
2820
LLVM_DEBUG (dbgs () << " to: " << *New << " \n " );
2821
2821
return false ;
2822
2822
}
@@ -2885,7 +2885,7 @@ class llvm::sroa::AllocaSliceRewriter
2885
2885
StoreInst *New =
2886
2886
IRB.CreateAlignedStore (V, &NewAI, NewAI.getAlign (), II.isVolatile ());
2887
2887
if (AATags)
2888
- New->setAAMetadata (AATags);
2888
+ New->setAAMetadata (AATags. shift (NewBeginOffset - BeginOffset) );
2889
2889
LLVM_DEBUG (dbgs () << " to: " << *New << " \n " );
2890
2890
return !II.isVolatile ();
2891
2891
}
@@ -3006,7 +3006,7 @@ class llvm::sroa::AllocaSliceRewriter
3006
3006
CallInst *New = IRB.CreateMemCpy (DestPtr, DestAlign, SrcPtr, SrcAlign,
3007
3007
Size, II.isVolatile ());
3008
3008
if (AATags)
3009
- New->setAAMetadata (AATags);
3009
+ New->setAAMetadata (AATags. shift (NewBeginOffset - BeginOffset) );
3010
3010
LLVM_DEBUG (dbgs () << " to: " << *New << " \n " );
3011
3011
return false ;
3012
3012
}
@@ -3060,7 +3060,7 @@ class llvm::sroa::AllocaSliceRewriter
3060
3060
LoadInst *Load = IRB.CreateAlignedLoad (OtherTy, SrcPtr, SrcAlign,
3061
3061
II.isVolatile (), " copyload" );
3062
3062
if (AATags)
3063
- Load->setAAMetadata (AATags);
3063
+ Load->setAAMetadata (AATags. shift (NewBeginOffset - BeginOffset) );
3064
3064
Src = Load;
3065
3065
}
3066
3066
@@ -3080,7 +3080,7 @@ class llvm::sroa::AllocaSliceRewriter
3080
3080
StoreInst *Store = cast<StoreInst>(
3081
3081
IRB.CreateAlignedStore (Src, DstPtr, DstAlign, II.isVolatile ()));
3082
3082
if (AATags)
3083
- Store->setAAMetadata (AATags);
3083
+ Store->setAAMetadata (AATags. shift (NewBeginOffset - BeginOffset) );
3084
3084
LLVM_DEBUG (dbgs () << " to: " << *Store << " \n " );
3085
3085
return !II.isVolatile ();
3086
3086
}
@@ -3381,8 +3381,13 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
3381
3381
IRB.CreateInBoundsGEP (BaseTy, Ptr, GEPIndices, Name + " .gep" );
3382
3382
LoadInst *Load =
3383
3383
IRB.CreateAlignedLoad (Ty, GEP, Alignment, Name + " .load" );
3384
- if (AATags)
3385
- Load->setAAMetadata (AATags);
3384
+
3385
+ APInt Offset (
3386
+ DL.getIndexSizeInBits (Ptr->getType ()->getPointerAddressSpace ()), 0 );
3387
+ if (AATags &&
3388
+ GEPOperator::accumulateConstantOffset (BaseTy, GEPIndices, DL, Offset))
3389
+ Load->setAAMetadata (AATags.shift (Offset.getZExtValue ()));
3390
+
3386
3391
Agg = IRB.CreateInsertValue (Agg, Load, Indices, Name + " .insert" );
3387
3392
LLVM_DEBUG (dbgs () << " to: " << *Load << " \n " );
3388
3393
}
@@ -3428,8 +3433,13 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
3428
3433
IRB.CreateInBoundsGEP (BaseTy, Ptr, GEPIndices, Name + " .gep" );
3429
3434
StoreInst *Store =
3430
3435
IRB.CreateAlignedStore (ExtractValue, InBoundsGEP, Alignment);
3431
- if (AATags)
3432
- Store->setAAMetadata (AATags);
3436
+
3437
+ APInt Offset (
3438
+ DL.getIndexSizeInBits (Ptr->getType ()->getPointerAddressSpace ()), 0 );
3439
+ if (AATags &&
3440
+ GEPOperator::accumulateConstantOffset (BaseTy, GEPIndices, DL, Offset))
3441
+ Store->setAAMetadata (AATags.shift (Offset.getZExtValue ()));
3442
+
3433
3443
LLVM_DEBUG (dbgs () << " to: " << *Store << " \n " );
3434
3444
}
3435
3445
};
0 commit comments