xref: /llvm-project/llvm/test/Transforms/LowerTypeTests/layout.ll (revision d3d7ba12033f20dfbc8eb6c60954478cff0d0182)
1; RUN: opt -S -passes=lowertypetests %s | FileCheck %s
2
3target datalayout = "e-p:32:32"
4
5; Tests that this set of globals is laid out according to our layout algorithm
6; (see GlobalLayoutBuilder in include/llvm/Transforms/IPO/LowerTypeTests.h).
7; The chosen layout in this case is a, e, b, d, c.
8
9; CHECK: private constant { i32, [0 x i8], i32, [0 x i8], i32, [0 x i8], i32, [0 x i8], i32 } { i32 1, [0 x i8] zeroinitializer, i32 5, [0 x i8] zeroinitializer, i32 2, [0 x i8] zeroinitializer, i32 4, [0 x i8] zeroinitializer, i32 3 }
10@a = constant i32 1, !type !0, !type !2
11@b = constant i32 2, !type !0, !type !1
12@c = constant i32 3, !type !0
13@d = constant i32 4, !type !1
14@e = constant i32 5, !type !2
15
16!0 = !{i32 0, !"typeid1"}
17!1 = !{i32 0, !"typeid2"}
18!2 = !{i32 0, !"typeid3"}
19
20declare i1 @llvm.type.test(ptr %ptr, metadata %bitset) nounwind readnone
21
22define void @foo() {
23  %x = call i1 @llvm.type.test(ptr undef, metadata !"typeid1")
24  %y = call i1 @llvm.type.test(ptr undef, metadata !"typeid2")
25  %z = call i1 @llvm.type.test(ptr undef, metadata !"typeid3")
26  ret void
27}
28