Chris Lattner | c1c4595 | 2010-04-28 22:34:35 +0000 | [diff] [blame] | 1 | ; RUN: opt -S -globalopt < %s | FileCheck %s |
Chris Lattner | f3f325b | 2010-04-28 20:16:12 +0000 | [diff] [blame] | 2 | |
| 3 | ; PR6112 - When globalopt does RAUW(@G, %G), the metadata reference should drop |
Duncan Sands | 203f7cb | 2010-05-04 12:43:36 +0000 | [diff] [blame] | 4 | ; to null. Function local metadata that references @G from a different function |
| 5 | ; to that containing %G should likewise drop to null. |
Chris Lattner | f3f325b | 2010-04-28 20:16:12 +0000 | [diff] [blame] | 6 | @G = internal global i8** null |
| 7 | |
| 8 | define i32 @main(i32 %argc, i8** %argv) { |
| 9 | ; CHECK: @main |
| 10 | ; CHECK: %G = alloca |
| 11 | store i8** %argv, i8*** @G |
| 12 | ret i32 0 |
| 13 | } |
| 14 | |
Duncan Sands | 203f7cb | 2010-05-04 12:43:36 +0000 | [diff] [blame] | 15 | define void @foo(i32 %x) { |
Duncan Sands | 55cd6cb | 2010-05-04 20:09:25 +0000 | [diff] [blame] | 16 | call void @llvm.foo(metadata !{i8*** @G, i32 %x}) |
| 17 | ; CHECK: call void @llvm.foo(metadata !{null, i32 %x}) |
Duncan Sands | 203f7cb | 2010-05-04 12:43:36 +0000 | [diff] [blame] | 18 | ret void |
| 19 | } |
| 20 | |
Duncan Sands | 55cd6cb | 2010-05-04 20:09:25 +0000 | [diff] [blame] | 21 | declare void @llvm.foo(metadata) nounwind readnone |
Duncan Sands | 203f7cb | 2010-05-04 12:43:36 +0000 | [diff] [blame] | 22 | |
Chris Lattner | f3f325b | 2010-04-28 20:16:12 +0000 | [diff] [blame] | 23 | !named = !{!0} |
| 24 | |
Chris Lattner | f3f325b | 2010-04-28 20:16:12 +0000 | [diff] [blame] | 25 | !0 = metadata !{i8*** @G} |
Duncan Sands | 203f7cb | 2010-05-04 12:43:36 +0000 | [diff] [blame] | 26 | ; CHECK: !0 = metadata !{null} |