llvm/test/Transforms/InstCombine/load-combine-metadata.ll
Sanjoy Das a942d77488 [Verifier] Add verification for TBAA metadata
Summary:
This change adds some verification in the IR verifier around struct path
TBAA metadata.

Other than some basic sanity checks (e.g. we get constant integers where
we expect constant integers), this checks:

 - That by the time an struct access tuple `(base-type, offset)` is
   "reduced" to a scalar base type, the offset is `0`.  For instance, in
   C++ you can't start from, say `("struct-a", 16)`, and end up with
   `("int", 4)` -- by the time the base type is `"int"`, the offset
   better be zero.  In particular, a variant of this invariant is needed
   for `llvm::getMostGenericTBAA` to be correct.

 - That there are no cycles in a struct path.

 - That struct type nodes have their offsets listed in an ascending
   order.

 - That when generating the struct access path, you eventually reach the
   access type listed in the tbaa tag node.

Reviewers: dexonsmith, chandlerc, reames, mehdi_amini, manmanren

Subscribers: mcrosier, llvm-commits

Differential Revision: https://reviews.llvm.org/D26438

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289402 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-11 20:07:15 +00:00

31 lines
881 B
LLVM

; RUN: opt -instcombine -S < %s | FileCheck %s
target datalayout = "e-m:e-p:64:64:64-i64:64-f80:128-n8:16:32:64-S128"
; CHECK-LABEL: @test_load_load_combine_metadata(
; Check that range and AA metadata is combined
; CHECK: %[[V:.*]] = load i32, i32* %0
; CHECK-SAME: !tbaa !{{[0-9]+}}
; CHECK-SAME: !range ![[RANGE:[0-9]+]]
; CHECK: store i32 %[[V]], i32* %1
; CHECK: store i32 %[[V]], i32* %2
define void @test_load_load_combine_metadata(i32*, i32*, i32*) {
%a = load i32, i32* %0, !tbaa !8, !range !0, !alias.scope !5, !noalias !6
%b = load i32, i32* %0, !tbaa !8, !range !1
store i32 %a, i32* %1
store i32 %b, i32* %2
ret void
}
; CHECK: ![[RANGE]] = !{i32 0, i32 5, i32 7, i32 9}
!0 = !{ i32 0, i32 5 }
!1 = !{ i32 7, i32 9 }
!2 = !{!2}
!3 = !{!3, !2}
!4 = !{!4, !2}
!5 = !{!3}
!6 = !{!4}
!7 = !{ !"tbaa root" }
!8 = !{ !9, !9, i64 0 }
!9 = !{ !"scalar type", !7}