33 lines · plain
1; RUN: opt -S -passes=globalopt < %s | FileCheck %s2 3; PR6112 - When globalopt does RAUW(@G, %G), the metadata reference should drop4; to null. Function local metadata that references @G from a different function5; to that containing %G should likewise drop to null.6@G = internal global ptr null7 8define i32 @main(i32 %argc, ptr %argv) norecurse {9; CHECK-LABEL: @main(10; CHECK: %G = alloca11 store ptr %argv, ptr @G12 ret i32 013}14 15define void @foo(i32 %x) {16; Note: these arguments look like MDNodes, but they're really syntactic sugar17; for 'MetadataAsValue::get(ValueAsMetadata::get(Value*))'. When @G drops to18; null, the ValueAsMetadata instance gets replaced by metadata !{}, or19; MDNode::get({}).20 call void @llvm.foo(metadata ptr @G, metadata i32 %x)21; CHECK: call void @llvm.foo(metadata ![[EMPTY:[0-9]+]], metadata i32 %x)22 ret void23}24 25declare void @llvm.foo(metadata, metadata) nounwind readnone26 27!named = !{!0}28; CHECK: !named = !{![[NULL:[0-9]+]]}29 30!0 = !{ptr @G}31; CHECK-DAG: ![[NULL]] = distinct !{null}32; CHECK-DAG: ![[EMPTY]] = !{}33