Skip to content

Commit 3ff8ae8

Browse files
committed
Local: Handle noalias_addrspace in combineMetadata
This should act like range.
1 parent 29b8b60 commit 3ff8ae8

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3361,6 +3361,10 @@ void llvm::combineMetadata(Instruction *K, const Instruction *J,
33613361
if (DoesKMove)
33623362
K->setMetadata(Kind, MDNode::getMergedProfMetadata(KMD, JMD, K, J));
33633363
break;
3364+
case LLVMContext::MD_noalias_addrspace:
3365+
if (DoesKMove)
3366+
K->setMetadata(Kind, MDNode::getMostGenericRange(JMD, KMD));
3367+
break;
33643368
}
33653369
}
33663370
// Set !invariant.group from J if J has it. If both instructions have it
@@ -3402,7 +3406,8 @@ void llvm::combineMetadataForCSE(Instruction *K, const Instruction *J,
34023406
LLVMContext::MD_prof,
34033407
LLVMContext::MD_nontemporal,
34043408
LLVMContext::MD_noundef,
3405-
LLVMContext::MD_mmra};
3409+
LLVMContext::MD_mmra,
3410+
LLVMContext::MD_noalias_addrspace};
34063411
combineMetadata(K, J, KnownIDs, KDominatesJ);
34073412
}
34083413

llvm/test/Transforms/SimplifyCFG/hoist-with-metadata.ll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ out:
319319
define void @hoist_noalias_addrspace_both(i1 %c, ptr %p, i64 %val) {
320320
; CHECK-LABEL: @hoist_noalias_addrspace_both(
321321
; CHECK-NEXT: if:
322-
; CHECK-NEXT: [[T:%.*]] = atomicrmw add ptr [[P:%.*]], i64 [[VAL:%.*]] seq_cst, align 8
322+
; CHECK-NEXT: [[T:%.*]] = atomicrmw add ptr [[P:%.*]], i64 [[VAL:%.*]] seq_cst, align 8, !noalias.addrspace [[META7:![0-9]+]]
323323
; CHECK-NEXT: ret void
324324
;
325325
if:
@@ -361,7 +361,7 @@ out:
361361
define void @hoist_noalias_addrspace_switch(i64 %i, ptr %p, i64 %val) {
362362
; CHECK-LABEL: @hoist_noalias_addrspace_switch(
363363
; CHECK-NEXT: out:
364-
; CHECK-NEXT: [[T:%.*]] = atomicrmw add ptr [[P:%.*]], i64 [[VAL:%.*]] seq_cst, align 8
364+
; CHECK-NEXT: [[T:%.*]] = atomicrmw add ptr [[P:%.*]], i64 [[VAL:%.*]] seq_cst, align 8, !noalias.addrspace [[META8:![0-9]+]]
365365
; CHECK-NEXT: ret void
366366
;
367367
switch i64 %i, label %bb0 [
@@ -398,4 +398,6 @@ out:
398398
; CHECK: [[RNG4]] = !{i32 0, i32 10}
399399
; CHECK: [[META5]] = !{i64 4}
400400
; CHECK: [[META6]] = !{float 2.500000e+00}
401+
; CHECK: [[META7]] = !{i32 5, i32 6}
402+
; CHECK: [[META8]] = !{i32 4, i32 8}
401403
;.

0 commit comments

Comments
 (0)