1 ; RUN: opt -S -passes=globalopt < %s | FileCheck %s
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 ptr null
8 define i32 @main(i32 %argc, ptr %argv) norecurse {
11 store ptr %argv, ptr @G
15 define void @foo(i32 %x) {
16 ; Note: these arguments look like MDNodes, but they're really syntactic sugar
17 ; for 'MetadataAsValue::get(ValueAsMetadata::get(Value*))'. When @G drops to
18 ; null, the ValueAsMetadata instance gets replaced by metadata !{}, or
20 call void @llvm.foo(metadata ptr @G, metadata i32 %x)
21 ; CHECK: call void @llvm.foo(metadata ![[EMPTY:[0-9]+]], metadata i32 %x)
25 declare void @llvm.foo(metadata, metadata) nounwind readnone
28 ; CHECK: !named = !{![[NULL:[0-9]+]]}
31 ; CHECK-DAG: ![[NULL]] = distinct !{null}
32 ; CHECK-DAG: ![[EMPTY]] = !{}