Call slot optimization currently merges the metadata between the call and the load. However, we also need to merge in the metadata of the store. Part of the reason why we might have gotten away with this previously is that usually the load and the store are the same instruction (a memcpy), this can only happen if call slot optimization occurs on an actual load/store pair. This addresses the issue reported in https://reviews.llvm.org/D115615#3251386. Differential Revision: https://reviews.llvm.org/D117679
27 lines
847 B
LLVM
27 lines
847 B
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt -S -memcpyopt < %s | FileCheck %s
|
|
|
|
declare void @func(i8* %dst)
|
|
|
|
; The noalias metadata from the call, the load and the store should be merged,
|
|
; so that no metadata is left on the call.
|
|
define i8 @test(i8* dereferenceable(1) noalias %dst) {
|
|
; CHECK-LABEL: @test(
|
|
; CHECK-NEXT: [[TMP:%.*]] = alloca i8, align 1
|
|
; CHECK-NEXT: call void @func(i8* nocapture [[DST:%.*]]) #[[ATTR0:[0-9]+]]{{$}}
|
|
; CHECK-NEXT: [[V2:%.*]] = load i8, i8* [[DST]], align 1, !alias.scope !0
|
|
; CHECK-NEXT: ret i8 [[V2]]
|
|
;
|
|
%tmp = alloca i8
|
|
call void @func(i8* nocapture %tmp) nounwind, !noalias !0
|
|
%v = load i8, i8* %tmp, !noalias !0
|
|
store i8 %v, i8* %dst, !alias.scope !0
|
|
%v2 = load i8, i8* %dst, !alias.scope !0
|
|
ret i8 %v2
|
|
}
|
|
|
|
!0 = !{!1}
|
|
!1 = !{!1, !2}
|
|
!2 = !{!2}
|
|
|