Index: include/llvm/IR/Intrinsics.td =================================================================== --- include/llvm/IR/Intrinsics.td +++ include/llvm/IR/Intrinsics.td @@ -617,14 +617,17 @@ // invariant.group.barrier can't be marked with 'readnone' (IntrNoMem), // because it would cause CSE of two barriers with the same argument. -// Readonly and argmemonly says that barrier only reads its argument and -// it can be CSE only if memory didn't change between 2 barriers call, -// which is valid. +// Readonly and inaccessiblememonly says that barrier only reads memory +// inaccessible to this module, so it can be CSE only if memory didn't change +// between 2 barriers call, which is valid. +// Since the barrier doesn't read the argument, we can perform DSE through +// the barrier. // The argument also can't be marked with 'returned' attribute, because // it would remove barrier. def int_invariant_group_barrier : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty], - [IntrReadMem, IntrArgMemOnly]>; + [IntrReadMem, + IntrInaccessibleMemOnly]>; //===------------------------ Stackmap Intrinsics -------------------------===// // Index: test/Analysis/MemorySSA/invariant-groups.ll =================================================================== --- test/Analysis/MemorySSA/invariant-groups.ll +++ test/Analysis/MemorySSA/invariant-groups.ll @@ -16,7 +16,7 @@ store i32 1, i32* @g, align 4 %1 = bitcast i32* %a to i8* -; CHECK: MemoryUse(2) +; CHECK: MemoryUse(liveOnEntry) ; CHECK-NEXT: %a8 = call i8* @llvm.invariant.group.barrier(i8* %1) %a8 = call i8* @llvm.invariant.group.barrier(i8* %1) %a32 = bitcast i8* %a8 to i32* @@ -35,7 +35,7 @@ store i32 0, i32* %a, align 4, !invariant.group !0 %1 = bitcast i32* %a to i8* -; CHECK: MemoryUse(1) +; CHECK: MemoryUse(liveOnEntry) ; CHECK-NEXT: %a8 = call i8* @llvm.invariant.group.barrier(i8* %1) %a8 = call i8* @llvm.invariant.group.barrier(i8* %1) %a32 = bitcast i8* %a8 to i32* @@ -85,7 +85,7 @@ ; CHECK-NEXT: store i32 1 store i32 1, i32* @g, align 4 %1 = bitcast i32* %a to i8* -; CHECK: MemoryUse(2) +; CHECK: MemoryUse(liveOnEntry) ; CHECK-NEXT: %a8 = call i8* @llvm.invariant.group.barrier(i8* %1) %a8 = call i8* @llvm.invariant.group.barrier(i8* %1) %a32 = bitcast i8* %a8 to i32* Index: test/Other/invariant.group.barrier.ll =================================================================== --- test/Other/invariant.group.barrier.ll +++ test/Other/invariant.group.barrier.ll @@ -54,7 +54,7 @@ declare void @use(i8* readonly) declare void @clobber(i8*) -; CHECK: Function Attrs: argmemonly nounwind readonly +; CHECK: Function Attrs: inaccessiblememonly nounwind readonly ; CHECK-NEXT: declare i8* @llvm.invariant.group.barrier(i8*) declare i8* @llvm.invariant.group.barrier(i8*)