1; RUN: opt -S -globalopt < %s | FileCheck %s
2
3; PR6112 - When globalopt does RAUW(@G, %G), the metadata reference should drop
4; to null.  Function local metadata that references @G from a different function
5; to that containing %G should likewise drop to null.
6@G = internal global i8** null
7
8define i32 @main(i32 %argc, i8** %argv) {
9; CHECK-LABEL: @main(
10; CHECK: %G = alloca
11  store i8** %argv, i8*** @G
12  ret i32 0
13}
14
15define void @foo(i32 %x) {
16  call void @llvm.foo(metadata !{i8*** @G, i32 %x})
17; CHECK: call void @llvm.foo(metadata !{null, i32 %x})
18  ret void
19}
20
21declare void @llvm.foo(metadata) nounwind readnone
22
23!named = !{!0}
24
25!0 = metadata !{i8*** @G}
26; CHECK: !0 = metadata !{null}
27