• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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) norecurse {
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; 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
19; MDNode::get({}).
20  call void @llvm.foo(metadata i8*** @G, metadata i32 %x)
21; CHECK: call void @llvm.foo(metadata ![[EMPTY:[0-9]+]], metadata i32 %x)
22  ret void
23}
24
25declare void @llvm.foo(metadata, metadata) nounwind readnone
26
27!named = !{!0}
28; CHECK: !named = !{![[NULL:[0-9]+]]}
29
30!0 = !{i8*** @G}
31; CHECK-DAG: ![[NULL]] = !{null}
32; CHECK-DAG: ![[EMPTY]] = !{}
33