llvm/llvm/test/Transforms/Attributor/phi_bug_pointer_info.ll

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes --check-globals --version 2
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -debug-only=attributor -attributor-manifest-internal -attributor-annotate-decl-cs  -S < %s 2>&1 | FileCheck %s
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -debug-only=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s 2>&1 | FileCheck %s
; REQUIRES: asserts


@globalBytes = internal global [1024 x i8] zeroinitializer

; CHECK: Accesses by bin after update:
; CHECK: [8-12] : 2
; CHECK:    - 9 -   store i32 %0, ptr %field2, align 4
; CHECK:      - c:   %0 = load i32, ptr %val, align 4
; CHECK:    - 6 -   %ret = load i32, ptr %x, align 4
; CHECK:      - c: <unknown>
; CHECK: [32-36] : 2
; CHECK:    - 9 -   store i32 %1, ptr %field8, align 4
; CHECK:      - c:   %1 = load i32, ptr %val2, align 4
; CHECK:    - 6 -   %ret = load i32, ptr %x, align 4
; CHECK:      - c: <unknown>
;.
; CHECK: @globalBytes = internal global [1024 x i8] zeroinitializer
;.
define dso_local i32 @phi_different_offsets(ptr nocapture %val, ptr nocapture %val2, i1 %cmp) {
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
; CHECK-LABEL: define dso_local i32 @phi_different_offsets
; CHECK-SAME: (ptr nocapture nofree readonly [[VAL:%.*]], ptr nocapture nofree readonly [[VAL2:%.*]], i1 noundef [[CMP:%.*]]) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
; CHECK:       then:
; CHECK-NEXT:    [[FIELD2:%.*]] = getelementptr i32, ptr @globalBytes, i32 2
; CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr [[VAL]], align 4
; CHECK-NEXT:    store i32 [[TMP0]], ptr [[FIELD2]], align 8
; CHECK-NEXT:    br label [[END:%.*]]
; CHECK:       else:
; CHECK-NEXT:    [[FIELD8:%.*]] = getelementptr i32, ptr @globalBytes, i32 8
; CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr [[VAL2]], align 4
; CHECK-NEXT:    store i32 [[TMP1]], ptr [[FIELD8]], align 16
; CHECK-NEXT:    br label [[END]]
; CHECK:       end:
; CHECK-NEXT:    [[X:%.*]] = phi ptr [ [[FIELD2]], [[THEN]] ], [ [[FIELD8]], [[ELSE]] ]
; CHECK-NEXT:    [[RET:%.*]] = load i32, ptr [[X]], align 8
; CHECK-NEXT:    ret i32 [[RET]]
;
entry:
  br i1 %cmp, label %then, label %else

then:
  %field2 = getelementptr i32, ptr @globalBytes, i32 2
  %1 = load i32, ptr %val
  store i32 %1, ptr %field2
  br label %end

else:
  %field8 = getelementptr i32, ptr @globalBytes, i32 8
  %2 = load i32, ptr %val2
  store i32 %2, ptr %field8
  br label %end

end:
  %x = phi ptr [ %field2, %then ], [ %field8, %else ]
  %ret = load i32, ptr %x
  ret i32 %ret

}
;.
; CHECK: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn }
;.