; RUN: opt -S < %s -mem2reg -verify | FileCheck %s target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.13.0" ; Original source (with some whitespace removed): ; ; extern int *getp(); ; extern int cond(); ; int get1() { return *getp(); } ; int get2(int *p) { return *p; } ; int bug(int *p) { ; if (cond()) return get1(); ; else return get2(p); ; } define i32 @get1() !dbg !8 { %1 = call i32* (...) @getp(), !dbg !12 %2 = load i32, i32* %1, align 4, !dbg !13 ret i32 %2, !dbg !14 } declare i32* @getp(...) define i32 @get2(i32*) !dbg !15 { %2 = alloca i32*, align 8 store i32* %0, i32** %2, align 8 call void @llvm.dbg.declare(metadata i32** %2, metadata !19, metadata !DIExpression()), !dbg !20 %3 = load i32*, i32** %2, align 8, !dbg !21 %4 = load i32, i32* %3, align 4, !dbg !22 ret i32 %4, !dbg !23 } declare void @llvm.dbg.declare(metadata, metadata, metadata) ; CHECK-LABEL: define i32 @bug define i32 @bug(i32*) !dbg !24 { %2 = alloca i32, align 4 %3 = alloca i32*, align 8 store i32* %0, i32** %3, align 8 call void @llvm.dbg.declare(metadata i32** %3, metadata !25, metadata !DIExpression()), !dbg !26 %4 = call i32 (...) @cond(), !dbg !27 %5 = icmp ne i32 %4, 0, !dbg !27 br i1 %5, label %6, label %8, !dbg !29 ;