1 ; RUN: opt %s -passes=mergefunc,globalopt -S -o - | FileCheck %s
3 ; Make sure we don't crash on this example. This test is supposed to test that
4 ; MergeFunctions clears its GlobalNumbers value map. If this map still contains
5 ; entries when running globalopt and the MergeFunctions instance is still alive
6 ; the optimization of @G would cause an assert because globalopt would do an
7 ; RAUW on @G which still exists as an entry in the GlobalNumbers ValueMap which
8 ; causes an assert in the ValueHandle call back because we are RAUWing with a
9 ; different type (AllocaInst) than its key type (GlobalValue).
11 @G = internal global ptr null
12 @G2 = internal global ptr null
14 define i32 @main(i32 %argc, ptr %argv) norecurse {
16 store ptr %argv, ptr @G
20 define internal ptr @dead1(i64 %p) {
21 call void @right(i64 %p)
22 call void @right(i64 %p)
23 call void @right(i64 %p)
24 call void @right(i64 %p)
25 %tmp = load ptr, ptr @G
29 define internal ptr @dead2(i64 %p) {
30 call void @right(i64 %p)
31 call void @right(i64 %p)
32 call void @right(i64 %p)
33 call void @right(i64 %p)
34 %tmp = load ptr, ptr @G2
38 define void @left(i64 %p) {
40 call void @right(i64 %p)
41 call void @right(i64 %p)
42 call void @right(i64 %p)
43 call void @right(i64 %p)
47 define void @right(i64 %p) {
49 call void @left(i64 %p)
50 call void @left(i64 %p)
51 call void @left(i64 %p)
52 call void @left(i64 %p)