@@ -185,28 +185,14 @@ Instruction *InstCombinerImpl::SimplifyAnyMemTransfer(AnyMemTransferInst *MI) {
185
185
186
186
// If the memcpy has metadata describing the members, see if we can get the
187
187
// TBAA tag describing our copy.
188
- MDNode *CopyMD = nullptr ;
189
- if (MDNode *M = MI->getMetadata (LLVMContext::MD_tbaa)) {
190
- CopyMD = M;
191
- } else if (MDNode *M = MI->getMetadata (LLVMContext::MD_tbaa_struct)) {
192
- if (M->getNumOperands () == 3 && M->getOperand (0 ) &&
193
- mdconst::hasa<ConstantInt>(M->getOperand (0 )) &&
194
- mdconst::extract<ConstantInt>(M->getOperand (0 ))->isZero () &&
195
- M->getOperand (1 ) &&
196
- mdconst::hasa<ConstantInt>(M->getOperand (1 )) &&
197
- mdconst::extract<ConstantInt>(M->getOperand (1 ))->getValue () ==
198
- Size &&
199
- M->getOperand (2 ) && isa<MDNode>(M->getOperand (2 )))
200
- CopyMD = cast<MDNode>(M->getOperand (2 ));
201
- }
188
+ AAMDNodes AACopyMD = MI->getAAMetadata ().adjustForAccess (Size );
202
189
203
190
Value *Src = Builder.CreateBitCast (MI->getArgOperand (1 ), NewSrcPtrTy);
204
191
Value *Dest = Builder.CreateBitCast (MI->getArgOperand (0 ), NewDstPtrTy);
205
192
LoadInst *L = Builder.CreateLoad (IntType, Src);
206
193
// Alignment from the mem intrinsic will be better, so use it.
207
194
L->setAlignment (*CopySrcAlign);
208
- if (CopyMD)
209
- L->setMetadata (LLVMContext::MD_tbaa, CopyMD);
195
+ L->setAAMetadata (AACopyMD);
210
196
MDNode *LoopMemParallelMD =
211
197
MI->getMetadata (LLVMContext::MD_mem_parallel_loop_access);
212
198
if (LoopMemParallelMD)
@@ -218,8 +204,7 @@ Instruction *InstCombinerImpl::SimplifyAnyMemTransfer(AnyMemTransferInst *MI) {
218
204
StoreInst *S = Builder.CreateStore (L, Dest);
219
205
// Alignment from the mem intrinsic will be better, so use it.
220
206
S->setAlignment (*CopyDstAlign);
221
- if (CopyMD)
222
- S->setMetadata (LLVMContext::MD_tbaa, CopyMD);
207
+ S->setAAMetadata (AACopyMD);
223
208
if (LoopMemParallelMD)
224
209
S->setMetadata (LLVMContext::MD_mem_parallel_loop_access, LoopMemParallelMD);
225
210
if (AccessGroupMD)
0 commit comments