2016-06-16 10:33:42 +08:00
|
|
|
; RUN: opt -S -instcombine < %s 2>&1 | FileCheck %s
|
|
|
|
|
|
|
|
define i64 @f(i64* %p1, i64* %p2) {
|
|
|
|
top:
|
|
|
|
; check that the tbaa is preserved
|
|
|
|
; CHECK-LABEL: @f(
|
|
|
|
; CHECK: %v1 = load i64, i64* %p1, align 8, !tbaa !0
|
|
|
|
; CHECK: store i64 %v1, i64* %p2, align 8
|
|
|
|
; CHECK: ret i64 %v1
|
|
|
|
%v1 = load i64, i64* %p1, align 8, !tbaa !0
|
|
|
|
store i64 %v1, i64* %p2, align 8
|
|
|
|
%v2 = load i64, i64* %p2, align 8
|
|
|
|
ret i64 %v2
|
|
|
|
}
|
|
|
|
|
|
|
|
!0 = !{!1, !1, i64 0}
|
[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
llvm-svn: 289402
2016-12-12 04:07:15 +08:00
|
|
|
!1 = !{!"scalar type", !2}
|
|
|
|
!2 = !{!"load_tbaa"}
|