llvm/llvm/test/Transforms/InstCombine/struct-assign-tbaa-2.ll

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
; RUN: opt -passes=instcombine -S < %s | FileCheck %s

target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"

declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture, i64, i1) nounwind

%struct.T = type { %struct.Wrapper, %struct.Wrapper }
%struct.Wrapper = type { i16 }

define void @test1(ptr %a1, ptr %a2) {
; CHECK-LABEL: @test1(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[B:%.*]] = getelementptr inbounds i8, ptr [[A2:%.*]], i64 2
; CHECK-NEXT:    [[TMP0:%.*]] = load i16, ptr [[A2]], align 2, !tbaa [[TBAA0:![0-9]+]]
; CHECK-NEXT:    store i16 [[TMP0]], ptr [[A1:%.*]], align 2, !tbaa [[TBAA0]]
; CHECK-NEXT:    [[B2:%.*]] = getelementptr inbounds i8, ptr [[A1]], i64 2
; CHECK-NEXT:    [[TMP1:%.*]] = load i16, ptr [[B]], align 2, !tbaa [[TBAA6:![0-9]+]]
; CHECK-NEXT:    store i16 [[TMP1]], ptr [[B2]], align 2, !tbaa [[TBAA6]]
; CHECK-NEXT:    ret void
;
entry:
  %b = getelementptr inbounds i8, ptr %a2, i64 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %a1, ptr align 2 %a2, i64 2, i1 false), !tbaa !0, !tbaa.struct !6
  %b2 = getelementptr inbounds %struct.T, ptr %a1, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %b2, ptr align 2 %b, i64 2, i1 false), !tbaa !8, !tbaa.struct !6
  ret void
}

!0 = !{!1, !4, i64 0, i64 2}
!1 = !{!2, i64 4, !"_ZTS1T", !4, i64 0, i64 2, !4, i64 2, i64 2}
!2 = !{!3, i64 1, !"omnipotent char"}
!3 = !{!"Simple C++ TBAA"}
!4 = !{!2, i64 2, !"_ZTS7Wrapper", !5, i64 0, i64 2}
!5 = !{!2, i64 2, !"short"}
!6 = !{i64 0, i64 2, !7}
!7 = !{!5, !5, i64 0, i64 2}
!8 = !{!1, !4, i64 2, i64 2}

;.
; CHECK: [[TBAA0]] = !{[[META1:![0-9]+]], [[META4:![0-9]+]], i64 0, i64 2}
; CHECK: [[META1]] = !{[[META2:![0-9]+]], i64 4, !"_ZTS1T", [[META4]], i64 0, i64 2, [[META4]], i64 2, i64 2}
; CHECK: [[META2]] = !{[[META3:![0-9]+]], i64 1, !"omnipotent char"}
; CHECK: [[META3]] = !{!"Simple C++ TBAA"}
; CHECK: [[META4]] = !{[[META2]], i64 2, !"_ZTS7Wrapper", [[META5:![0-9]+]], i64 0, i64 2}
; CHECK: [[META5]] = !{[[META2]], i64 2, !"short"}
; CHECK: [[TBAA6]] = !{[[META1]], [[META4]], i64 2, i64 2}
;.