Imported Upstream version 5.18.0.205

Former-commit-id: 7f59f7e792705db773f1caecdaa823092f4e2927
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-11-16 08:20:38 +00:00
parent 5cd5df71cc
commit 8e12397d70
28486 changed files with 3867013 additions and 66 deletions

View File

@ -0,0 +1,11 @@
; Uninitialized values are not handled correctly.
;
; RUN: opt < %s -mem2reg -disable-output
;
define i32 @test() {
; To be promoted
%X = alloca i32 ; <i32*> [#uses=1]
%Y = load i32, i32* %X ; <i32> [#uses=1]
ret i32 %Y
}

View File

@ -0,0 +1,12 @@
; This input caused the mem2reg pass to die because it was trying to promote
; the %r alloca, even though it is invalid to do so in this case!
;
; RUN: opt < %s -mem2reg
define void @test() {
%r = alloca i32 ; <i32*> [#uses=2]
store i32 4, i32* %r
store i32* %r, i32** null
ret void
}

View File

@ -0,0 +1,10 @@
; RUN: opt < %s -mem2reg
define void @_Z3barv() {
%result = alloca i32 ; <i32*> [#uses=1]
ret void
; No predecessors!
store i32 0, i32* %result
ret void
}

View File

@ -0,0 +1,16 @@
; This testcases makes sure that mem2reg can handle unreachable blocks.
; RUN: opt < %s -mem2reg
define i32 @test() {
%X = alloca i32 ; <i32*> [#uses=2]
store i32 6, i32* %X
br label %Loop
Loop: ; preds = %EndOfLoop, %0
store i32 5, i32* %X
br label %EndOfLoop
Unreachable: ; No predecessors!
br label %EndOfLoop
EndOfLoop: ; preds = %Unreachable, %Loop
br label %Loop
}

View File

@ -0,0 +1,16 @@
; Mem2reg used to only add one incoming value to a PHI node, even if it had
; multiple incoming edges from a block.
;
; RUN: opt < %s -mem2reg -disable-output
define i32 @test(i1 %c1, i1 %c2) {
%X = alloca i32 ; <i32*> [#uses=2]
br i1 %c1, label %Exit, label %B2
B2: ; preds = %0
store i32 2, i32* %X
br i1 %c2, label %Exit, label %Exit
Exit: ; preds = %B2, %B2, %0
%Y = load i32, i32* %X ; <i32> [#uses=1]
ret i32 %Y
}

View File

@ -0,0 +1,16 @@
; Promoting some values allows promotion of other values.
; RUN: opt < %s -mem2reg -S | not grep alloca
define i32 @test2() {
%result = alloca i32 ; <i32*> [#uses=2]
%a = alloca i32 ; <i32*> [#uses=2]
%p = alloca i32* ; <i32**> [#uses=2]
store i32 0, i32* %a
store i32* %a, i32** %p
%tmp.0 = load i32*, i32** %p ; <i32*> [#uses=1]
%tmp.1 = load i32, i32* %tmp.0 ; <i32> [#uses=1]
store i32 %tmp.1, i32* %result
%tmp.2 = load i32, i32* %result ; <i32> [#uses=1]
ret i32 %tmp.2
}

View File

@ -0,0 +1,22 @@
; Mem2reg should not insert dead PHI nodes! The naive algorithm inserts a PHI
; node in L3, even though there is no load of %A in anything dominated by L3.
; RUN: opt < %s -mem2reg -S | not grep phi
define void @test(i32 %B, i1 %C) {
%A = alloca i32 ; <i32*> [#uses=4]
store i32 %B, i32* %A
br i1 %C, label %L1, label %L2
L1: ; preds = %0
store i32 %B, i32* %A
%D = load i32, i32* %A ; <i32> [#uses=1]
call void @test( i32 %D, i1 false )
br label %L3
L2: ; preds = %0
%E = load i32, i32* %A ; <i32> [#uses=1]
call void @test( i32 %E, i1 true )
br label %L3
L3: ; preds = %L2, %L1
ret void
}

View File

@ -0,0 +1,47 @@
; RUN: opt < %s -mem2reg -instcombine -S | grep store
; PR590
define void @zero(i8* %p, i32 %n) {
entry:
%p_addr = alloca i8* ; <i8**> [#uses=2]
%n_addr = alloca i32 ; <i32*> [#uses=2]
%i = alloca i32 ; <i32*> [#uses=6]
%out = alloca i32 ; <i32*> [#uses=2]
%undef = alloca i32 ; <i32*> [#uses=2]
store i8* %p, i8** %p_addr
store i32 %n, i32* %n_addr
store i32 0, i32* %i
br label %loopentry
loopentry: ; preds = %endif, %entry
%tmp.0 = load i32, i32* %n_addr ; <i32> [#uses=1]
%tmp.1 = add i32 %tmp.0, 1 ; <i32> [#uses=1]
%tmp.2 = load i32, i32* %i ; <i32> [#uses=1]
%tmp.3 = icmp sgt i32 %tmp.1, %tmp.2 ; <i1> [#uses=2]
%tmp.4 = zext i1 %tmp.3 to i32 ; <i32> [#uses=0]
br i1 %tmp.3, label %no_exit, label %return
no_exit: ; preds = %loopentry
%tmp.5 = load i32, i32* %undef ; <i32> [#uses=1]
store i32 %tmp.5, i32* %out
store i32 0, i32* %undef
%tmp.6 = load i32, i32* %i ; <i32> [#uses=1]
%tmp.7 = icmp sgt i32 %tmp.6, 0 ; <i1> [#uses=2]
%tmp.8 = zext i1 %tmp.7 to i32 ; <i32> [#uses=0]
br i1 %tmp.7, label %then, label %endif
then: ; preds = %no_exit
%tmp.9 = load i8*, i8** %p_addr ; <i8*> [#uses=1]
%tmp.10 = load i32, i32* %i ; <i32> [#uses=1]
%tmp.11 = sub i32 %tmp.10, 1 ; <i32> [#uses=1]
%tmp.12 = getelementptr i8, i8* %tmp.9, i32 %tmp.11 ; <i8*> [#uses=1]
%tmp.13 = load i32, i32* %out ; <i32> [#uses=1]
%tmp.14 = trunc i32 %tmp.13 to i8 ; <i8> [#uses=1]
store i8 %tmp.14, i8* %tmp.12
br label %endif
endif: ; preds = %then, %no_exit
%tmp.15 = load i32, i32* %i ; <i32> [#uses=1]
%inc = add i32 %tmp.15, 1 ; <i32> [#uses=1]
store i32 %inc, i32* %i
br label %loopentry
return: ; preds = %loopentry
ret void
}

View File

@ -0,0 +1,62 @@
; RUN: opt < %s -mem2reg -disable-output
; PR670
define void @printk(i32, ...) {
entry:
%flags = alloca i32 ; <i32*> [#uses=2]
br i1 false, label %then.0, label %endif.0
then.0: ; preds = %entry
br label %endif.0
endif.0: ; preds = %then.0, %entry
store i32 0, i32* %flags
br label %loopentry
loopentry: ; preds = %endif.3, %endif.0
br i1 false, label %no_exit, label %loopexit
no_exit: ; preds = %loopentry
br i1 false, label %then.1, label %endif.1
then.1: ; preds = %no_exit
br i1 false, label %shortcirc_done.0, label %shortcirc_next.0
shortcirc_next.0: ; preds = %then.1
br label %shortcirc_done.0
shortcirc_done.0: ; preds = %shortcirc_next.0, %then.1
br i1 false, label %shortcirc_done.1, label %shortcirc_next.1
shortcirc_next.1: ; preds = %shortcirc_done.0
br label %shortcirc_done.1
shortcirc_done.1: ; preds = %shortcirc_next.1, %shortcirc_done.0
br i1 false, label %shortcirc_done.2, label %shortcirc_next.2
shortcirc_next.2: ; preds = %shortcirc_done.1
br label %shortcirc_done.2
shortcirc_done.2: ; preds = %shortcirc_next.2, %shortcirc_done.1
br i1 false, label %then.2, label %endif.2
then.2: ; preds = %shortcirc_done.2
br label %endif.2
endif.2: ; preds = %then.2, %shortcirc_done.2
br label %endif.1
endif.1: ; preds = %endif.2, %no_exit
br i1 false, label %then.3, label %endif.3
then.3: ; preds = %endif.1
br label %endif.3
endif.3: ; preds = %then.3, %endif.1
br label %loopentry
loopexit: ; preds = %loopentry
br label %endif.4
then.4: ; No predecessors!
%tmp.61 = load i32, i32* %flags ; <i32> [#uses=0]
br label %out
dead_block_after_goto: ; No predecessors!
br label %endif.4
endif.4: ; preds = %dead_block_after_goto, %loopexit
br i1 false, label %then.5, label %else
then.5: ; preds = %endif.4
br label %endif.5
else: ; preds = %endif.4
br label %endif.5
endif.5: ; preds = %else, %then.5
br label %out
out: ; preds = %endif.5, %then.4
br label %return
after_ret: ; No predecessors!
br label %return
return: ; preds = %after_ret, %out
ret void
}

View File

@ -0,0 +1,47 @@
; RUN: opt < %s -O3 -S | grep volatile | count 3
; PR1520
; Don't promote load volatiles/stores. This is really needed to handle setjmp/lonjmp properly.
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i686-pc-linux-gnu"
%struct.__jmp_buf_tag = type { [6 x i32], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [32 x i32] }
@j = external global [1 x %struct.__jmp_buf_tag] ; <[1 x %struct.__jmp_buf_tag]*> [#uses=1]
define i32 @f() {
entry:
%retval = alloca i32, align 4 ; <i32*> [#uses=2]
%v = alloca i32, align 4 ; <i32*> [#uses=3]
%tmp = alloca i32, align 4 ; <i32*> [#uses=3]
%"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
store volatile i32 0, i32* %v, align 4
%tmp1 = call i32 @_setjmp( %struct.__jmp_buf_tag* getelementptr ([1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* @j, i32 0, i32 0) ) ; <i32> [#uses=1]
%tmp2 = icmp ne i32 %tmp1, 0 ; <i1> [#uses=1]
%tmp23 = zext i1 %tmp2 to i8 ; <i8> [#uses=1]
%toBool = icmp ne i8 %tmp23, 0 ; <i1> [#uses=1]
br i1 %toBool, label %bb, label %bb5
bb: ; preds = %entry
%tmp4 = load volatile i32, i32* %v, align 4 ; <i32> [#uses=1]
store i32 %tmp4, i32* %tmp, align 4
br label %bb6
bb5: ; preds = %entry
store volatile i32 1, i32* %v, align 4
call void @g( )
store i32 0, i32* %tmp, align 4
br label %bb6
bb6: ; preds = %bb5, %bb
%tmp7 = load i32, i32* %tmp, align 4 ; <i32> [#uses=1]
store i32 %tmp7, i32* %retval, align 4
br label %return
return: ; preds = %bb6
%retval8 = load i32, i32* %retval ; <i32> [#uses=1]
ret i32 %retval8
}
declare i32 @_setjmp(%struct.__jmp_buf_tag*) returns_twice
declare void @g()

View File

@ -0,0 +1,52 @@
; RUN: opt < %s -mem2reg -S | FileCheck %s
define double @testfunc(i32 %i, double %j) nounwind ssp !dbg !1 {
entry:
%i_addr = alloca i32 ; <i32*> [#uses=2]
%j_addr = alloca double ; <double*> [#uses=2]
%retval = alloca double ; <double*> [#uses=2]
%0 = alloca double ; <double*> [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
call void @llvm.dbg.declare(metadata i32* %i_addr, metadata !0, metadata !DIExpression()), !dbg !8
; CHECK: call void @llvm.dbg.value(metadata i32 %i, metadata ![[IVAR:[0-9]*]], metadata {{.*}})
; CHECK: call void @llvm.dbg.value(metadata double %j, metadata ![[JVAR:[0-9]*]], metadata {{.*}})
; CHECK: ![[IVAR]] = !DILocalVariable(name: "i"
; CHECK: ![[JVAR]] = !DILocalVariable(name: "j"
store i32 %i, i32* %i_addr
call void @llvm.dbg.declare(metadata double* %j_addr, metadata !9, metadata !DIExpression()), !dbg !8
store double %j, double* %j_addr
%1 = load i32, i32* %i_addr, align 4, !dbg !10 ; <i32> [#uses=1]
%2 = add nsw i32 %1, 1, !dbg !10 ; <i32> [#uses=1]
%3 = sitofp i32 %2 to double, !dbg !10 ; <double> [#uses=1]
%4 = load double, double* %j_addr, align 8, !dbg !10 ; <double> [#uses=1]
%5 = fadd double %3, %4, !dbg !10 ; <double> [#uses=1]
store double %5, double* %0, align 8, !dbg !10
%6 = load double, double* %0, align 8, !dbg !10 ; <double> [#uses=1]
store double %6, double* %retval, align 8, !dbg !10
br label %return, !dbg !10
return: ; preds = %entry
%retval1 = load double, double* %retval, !dbg !10 ; <double> [#uses=1]
ret double %retval1, !dbg !10
}
declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
!llvm.dbg.cu = !{!3}
!llvm.module.flags = !{!14}
!0 = !DILocalVariable(name: "i", line: 2, arg: 1, scope: !1, file: !2, type: !7)
!1 = distinct !DISubprogram(name: "testfunc", linkageName: "testfunc", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scopeLine: 2, file: !12, scope: !2, type: !4)
!2 = !DIFile(filename: "testfunc.c", directory: "/tmp")
!3 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: FullDebug, file: !12, enums: !13, retainedTypes: !13)
!4 = !DISubroutineType(types: !5)
!5 = !{!6, !7, !6}
!6 = !DIBasicType(tag: DW_TAG_base_type, name: "double", size: 64, align: 64, encoding: DW_ATE_float)
!7 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
!8 = !DILocation(line: 2, scope: !1)
!9 = !DILocalVariable(name: "j", line: 2, arg: 2, scope: !1, file: !2, type: !6)
!10 = !DILocation(line: 3, scope: !11)
!11 = distinct !DILexicalBlock(line: 2, column: 0, file: !12, scope: !1)
!12 = !DIFile(filename: "testfunc.c", directory: "/tmp")
!13 = !{}
!14 = !{i32 1, !"Debug Info Version", i32 3}

View File

@ -0,0 +1,67 @@
; RUN: opt -S -mem2reg <%s | FileCheck %s
declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
declare void @foo(i32, i64, i8*)
define void @baz(i32 %a) nounwind ssp !dbg !1 {
; CHECK-LABEL: entry:
; CHECK-NEXT: %"alloca point" = bitcast i32 0 to i32{{$}}
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 %a,{{.*}}, !dbg
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 %a,{{.*}}, !dbg
; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 55,{{.*}}, !dbg
; CHECK-NEXT: call void @llvm.dbg.value(metadata i8* bitcast (void (i32)* @baz to i8*),{{.*}}, !dbg
; CHECK-NEXT: call void @foo({{.*}}, !dbg
; CHECK-NEXT: br label %return, !dbg
entry:
%x_addr.i = alloca i32 ; <i32*> [#uses=2]
%y_addr.i = alloca i64 ; <i64*> [#uses=2]
%z_addr.i = alloca i8* ; <i8**> [#uses=2]
%a_addr = alloca i32 ; <i32*> [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
call void @llvm.dbg.declare(metadata i32* %a_addr, metadata !0, metadata !DIExpression()), !dbg !7
store i32 %a, i32* %a_addr
%0 = load i32, i32* %a_addr, align 4, !dbg !8 ; <i32> [#uses=1]
call void @llvm.dbg.declare(metadata i32* %x_addr.i, metadata !9, metadata !DIExpression()) nounwind, !dbg !15
store i32 %0, i32* %x_addr.i
call void @llvm.dbg.declare(metadata i64* %y_addr.i, metadata !16, metadata !DIExpression()) nounwind, !dbg !15
store i64 55, i64* %y_addr.i
call void @llvm.dbg.declare(metadata i8** %z_addr.i, metadata !17, metadata !DIExpression()) nounwind, !dbg !15
store i8* bitcast (void (i32)* @baz to i8*), i8** %z_addr.i
%1 = load i32, i32* %x_addr.i, align 4, !dbg !18 ; <i32> [#uses=1]
%2 = load i64, i64* %y_addr.i, align 8, !dbg !18 ; <i64> [#uses=1]
%3 = load i8*, i8** %z_addr.i, align 8, !dbg !18 ; <i8*> [#uses=1]
call void @foo(i32 %1, i64 %2, i8* %3) nounwind, !dbg !18
br label %return, !dbg !19
; CHECK-LABEL: return:
; CHECK-NEXT: ret void, !dbg
return: ; preds = %entry
ret void, !dbg !19
}
!llvm.dbg.cu = !{!3}
!llvm.module.flags = !{!22}
!0 = !DILocalVariable(name: "a", line: 8, arg: 1, scope: !1, file: !2, type: !6)
!1 = distinct !DISubprogram(name: "baz", linkageName: "baz", line: 8, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scopeLine: 8, file: !20, scope: !2, type: !4)
!2 = !DIFile(filename: "bar.c", directory: "/tmp/")
!3 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: FullDebug, file: !20, enums: !21, retainedTypes: !21)
!4 = !DISubroutineType(types: !5)
!5 = !{null, !6}
!6 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
!7 = !DILocation(line: 8, scope: !1)
!8 = !DILocation(line: 9, scope: !1)
!9 = !DILocalVariable(name: "x", line: 4, arg: 1, scope: !10, file: !2, type: !6)
!10 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: true, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scopeLine: 4, file: !20, scope: !2, type: !11)
!11 = !DISubroutineType(types: !12)
!12 = !{null, !6, !13, !14}
!13 = !DIBasicType(tag: DW_TAG_base_type, name: "long int", size: 64, align: 64, encoding: DW_ATE_signed)
!14 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, file: !20, scope: !2, baseType: null)
!15 = !DILocation(line: 4, scope: !10, inlinedAt: !8)
!16 = !DILocalVariable(name: "y", line: 4, arg: 2, scope: !10, file: !2, type: !13)
!17 = !DILocalVariable(name: "z", line: 4, arg: 3, scope: !10, file: !2, type: !14)
!18 = !DILocation(line: 5, scope: !10, inlinedAt: !8)
!19 = !DILocation(line: 10, scope: !1)
!20 = !DIFile(filename: "bar.c", directory: "/tmp/")
!21 = !{}
!22 = !{i32 1, !"Debug Info Version", i32 3}

View File

@ -0,0 +1,21 @@
; Simple sanity check testcase. Both alloca's should be eliminated.
; RUN: opt < %s -debugify -mem2reg -check-debugify -S | FileCheck %s
; CHECK-NOT: alloca
; CHECK: CheckDebugify: PASS
define double @testfunc(i32 %i, double %j) {
%I = alloca i32 ; <i32*> [#uses=4]
%J = alloca double ; <double*> [#uses=2]
store i32 %i, i32* %I
store double %j, double* %J
%t1 = load i32, i32* %I ; <i32> [#uses=1]
%t2 = add i32 %t1, 1 ; <i32> [#uses=1]
store i32 %t2, i32* %I
%t3 = load i32, i32* %I ; <i32> [#uses=1]
%t4 = sitofp i32 %t3 to double ; <double> [#uses=1]
%t5 = load double, double* %J ; <double> [#uses=1]
%t6 = fmul double %t4, %t5 ; <double> [#uses=1]
ret double %t6
}

View File

@ -0,0 +1,13 @@
; RUN: opt < %s -mem2reg -S | not grep phi
define i32 @testfunc(i1 %C, i32 %i, i8 %j) {
%I = alloca i32 ; <i32*> [#uses=2]
br i1 %C, label %T, label %Cont
T: ; preds = %0
store i32 %i, i32* %I
br label %Cont
Cont: ; preds = %T, %0
%Y = load i32, i32* %I ; <i32> [#uses=1]
ret i32 %Y
}

View File

@ -0,0 +1,12 @@
; RUN: opt -mem2reg < %s -S | FileCheck %s
; mem2reg is allowed with arbitrary atomic operations (although we only support
; it for atomic load and store at the moment).
define i32 @test1(i32 %x) {
; CHECK-LABEL: @test1(
; CHECK: ret i32 %x
%a = alloca i32
store atomic i32 %x, i32* %a seq_cst, align 4
%r = load atomic i32, i32* %a seq_cst, align 4
ret i32 %r
}

View File

@ -0,0 +1,44 @@
; RUN: opt < %s -mem2reg -S
; PR5023
declare i32 @test1f()
define i32 @test1() personality i32 (...)* @__gxx_personality_v0 {
entry:
%whichFlag = alloca i32
%A = invoke i32 @test1f()
to label %invcont2 unwind label %lpad86
invcont2:
store i32 %A, i32* %whichFlag
br label %bb15
bb15:
%B = load i32, i32* %whichFlag
ret i32 %B
lpad86:
%exn = landingpad {i8*, i32}
cleanup
br label %bb15
}
declare i32 @__gxx_personality_v0(...)
define i32 @test2() {
entry:
%whichFlag = alloca i32
br label %bb15
bb15:
%B = load i32, i32* %whichFlag
ret i32 %B
invcont2:
%C = load i32, i32* %whichFlag
store i32 %C, i32* %whichFlag
br label %bb15
}

View File

@ -0,0 +1,94 @@
; RUN: opt -mem2reg -S < %s | FileCheck %s -implicit-check-not="call void @llvm.dbg.addr"
; This example is intended to simulate this pass pipeline, which may not exist
; in practice:
; 1. DSE f from the original C source
; 2. Inline escape
; 3. mem2reg
; This exercises the corner case of multiple llvm.dbg.addr intrinsics.
; C source:
;
; void escape(int *px) { ++*px; }
; extern int global;
; void f(int x) {
; escape(&x);
; x = 1; // DSE should delete and insert dbg.value(i32 1)
; global = x;
; x = 2; // DSE should insert dbg.addr
; escape(&x);
; }
; ModuleID = 'dse.c'
source_filename = "dse.c"
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc19.0.24215"
declare void @llvm.dbg.addr(metadata, metadata, metadata) #2
declare void @llvm.dbg.value(metadata, metadata, metadata) #2
@global = external global i32, align 4
; Function Attrs: nounwind uwtable
define void @f(i32 %x) #0 !dbg !8 {
entry:
%x.addr = alloca i32, align 4
store i32 %x, i32* %x.addr, align 4
call void @llvm.dbg.addr(metadata i32* %x.addr, metadata !13, metadata !DIExpression()), !dbg !18
%ld.1 = load i32, i32* %x.addr, align 4, !dbg !19
%inc.1 = add nsw i32 %ld.1, 1, !dbg !19
store i32 %inc.1, i32* %x.addr, align 4, !dbg !19
call void @llvm.dbg.value(metadata i32 1, metadata !13, metadata !DIExpression()), !dbg !20
store i32 1, i32* @global, align 4, !dbg !22
call void @llvm.dbg.addr(metadata i32* %x.addr, metadata !13, metadata !DIExpression()), !dbg !23
store i32 2, i32* %x.addr, align 4, !dbg !23
%ld.2 = load i32, i32* %x.addr, align 4, !dbg !19
%inc.2 = add nsw i32 %ld.2, 1, !dbg !19
store i32 %inc.2, i32* %x.addr, align 4, !dbg !19
ret void, !dbg !25
}
; CHECK-LABEL: define void @f(i32 %x)
; CHECK: call void @llvm.dbg.value(metadata i32 %x, metadata !13, metadata !DIExpression())
; CHECK: %inc.1 = add nsw i32 %x, 1
; CHECK: call void @llvm.dbg.value(metadata i32 %inc.1, metadata !13, metadata !DIExpression())
; CHECK: call void @llvm.dbg.value(metadata i32 1, metadata !13, metadata !DIExpression())
; CHECK: store i32 1, i32* @global, align 4
; CHECK: call void @llvm.dbg.value(metadata i32 2, metadata !13, metadata !DIExpression())
; CHECK: %inc.2 = add nsw i32 2, 1
; CHECK: call void @llvm.dbg.value(metadata i32 %inc.2, metadata !13, metadata !DIExpression())
; CHECK: ret void
attributes #0 = { nounwind uwtable }
attributes #2 = { nounwind readnone speculatable }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5, !6}
!llvm.ident = !{!7}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "dse.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild")
!2 = !{}
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 2}
!6 = !{i32 7, !"PIC Level", i32 2}
!7 = !{!"clang version 6.0.0 "}
!8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !12)
!9 = !DISubroutineType(types: !10)
!10 = !{null, !11}
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!12 = !{!13}
!13 = !DILocalVariable(name: "x", arg: 1, scope: !8, file: !1, line: 3, type: !11)
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !16, i64 0}
!16 = !{!"omnipotent char", !17, i64 0}
!17 = !{!"Simple C/C++ TBAA"}
!18 = !DILocation(line: 3, column: 12, scope: !8)
!19 = !DILocation(line: 4, column: 3, scope: !8)
!20 = !DILocation(line: 5, column: 5, scope: !8)
!21 = !DILocation(line: 6, column: 12, scope: !8)
!22 = !DILocation(line: 6, column: 10, scope: !8)
!23 = !DILocation(line: 7, column: 5, scope: !8)
!24 = !DILocation(line: 8, column: 3, scope: !8)
!25 = !DILocation(line: 9, column: 1, scope: !8)

View File

@ -0,0 +1,91 @@
; RUN: opt -mem2reg -S < %s | FileCheck %s
; ModuleID = 'newvars.c'
source_filename = "newvars.c"
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc19.0.24215"
; Function Attrs: nounwind uwtable
define i32 @if_else(i32 %cond, i32 %a, i32 %b) !dbg !8 {
entry:
%x = alloca i32, align 4
call void @llvm.dbg.addr(metadata i32* %x, metadata !16, metadata !DIExpression()), !dbg !26
store i32 %a, i32* %x, align 4, !dbg !26, !tbaa !17
%tobool = icmp ne i32 %cond, 0, !dbg !28
br i1 %tobool, label %if.then, label %if.else, !dbg !30
if.then: ; preds = %entry
store i32 0, i32* %x, align 4, !dbg !31, !tbaa !17
br label %if.end, !dbg !33
if.else: ; preds = %entry
store i32 %b, i32* %x, align 4, !dbg !36, !tbaa !17
br label %if.end
if.end: ; preds = %if.else, %if.then
%rv = load i32, i32* %x, align 4, !dbg !37, !tbaa !17
ret i32 %rv, !dbg !39
}
; CHECK-LABEL: define i32 @if_else({{.*}})
; CHECK: entry:
; CHECK-NOT: alloca i32
; CHECK: call void @llvm.dbg.value(metadata i32 %a, metadata ![[X_LOCAL:[0-9]+]], metadata !DIExpression())
; CHECK: if.then: ; preds = %entry
; CHECK: call void @llvm.dbg.value(metadata i32 0, metadata ![[X_LOCAL]], metadata !DIExpression())
; CHECK: if.else: ; preds = %entry
; CHECK: call void @llvm.dbg.value(metadata i32 %b, metadata ![[X_LOCAL]], metadata !DIExpression())
; CHECK: if.end: ; preds = %if.else, %if.then
; CHECK: %[[PHI:[^ ]*]] = phi i32 [ 0, %if.then ], [ %b, %if.else ]
; CHECK: call void @llvm.dbg.value(metadata i32 %[[PHI]], metadata ![[X_LOCAL]], metadata !DIExpression())
; CHECK: ret i32
; CHECK: ![[X_LOCAL]] = !DILocalVariable(name: "x", {{.*}})
; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.declare(metadata, metadata, metadata)
declare void @llvm.dbg.addr(metadata, metadata, metadata)
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5, !6}
!llvm.ident = !{!7}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "newvars.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild")
!2 = !{}
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 2}
!6 = !{i32 7, !"PIC Level", i32 2}
!7 = !{!"clang version 6.0.0 "}
!8 = distinct !DISubprogram(name: "if_else", scope: !1, file: !1, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !12)
!9 = !DISubroutineType(types: !10)
!10 = !{!11, !11, !11, !11}
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!12 = !{!13, !14, !15, !16}
!13 = !DILocalVariable(name: "b", arg: 3, scope: !8, file: !1, line: 1, type: !11)
!14 = !DILocalVariable(name: "a", arg: 2, scope: !8, file: !1, line: 1, type: !11)
!15 = !DILocalVariable(name: "cond", arg: 1, scope: !8, file: !1, line: 1, type: !11)
!16 = !DILocalVariable(name: "x", scope: !8, file: !1, line: 2, type: !11)
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !19, i64 0}
!19 = !{!"omnipotent char", !20, i64 0}
!20 = !{!"Simple C/C++ TBAA"}
!22 = !DILocation(line: 1, column: 34, scope: !8)
!23 = !DILocation(line: 1, column: 27, scope: !8)
!24 = !DILocation(line: 1, column: 17, scope: !8)
!25 = !DILocation(line: 2, column: 3, scope: !8)
!26 = !DILocation(line: 2, column: 7, scope: !8)
!27 = !DILocation(line: 2, column: 11, scope: !8)
!28 = !DILocation(line: 3, column: 7, scope: !29)
!29 = distinct !DILexicalBlock(scope: !8, file: !1, line: 3, column: 7)
!30 = !DILocation(line: 3, column: 7, scope: !8)
!31 = !DILocation(line: 4, column: 7, scope: !32)
!32 = distinct !DILexicalBlock(scope: !29, file: !1, line: 3, column: 13)
!33 = !DILocation(line: 5, column: 3, scope: !32)
!34 = !DILocation(line: 6, column: 9, scope: !35)
!35 = distinct !DILexicalBlock(scope: !29, file: !1, line: 5, column: 10)
!36 = !DILocation(line: 6, column: 7, scope: !35)
!37 = !DILocation(line: 8, column: 10, scope: !8)
!38 = !DILocation(line: 9, column: 1, scope: !8)
!39 = !DILocation(line: 8, column: 3, scope: !8)

View File

@ -0,0 +1,46 @@
; RUN: opt < %s -mem2reg -S | FileCheck %s
source_filename = "bugpoint-output.bc"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.12.0"
define void @scan() #0 !dbg !12 {
entry:
%entry1 = alloca i8, align 8
call void @llvm.dbg.declare(metadata i8* %entry1, metadata !18, metadata !19), !dbg !20
store i8 0, i8* %entry1, align 8, !dbg !20
br label %for.cond, !dbg !20
for.cond:
; CHECK: %[[PHI:.*]] = phi i8 [ 0, %entry ], [ %0, %for.cond ]
%entryN = load i8, i8* %entry1, align 8, !dbg !20
; CHECK: call void @llvm.dbg.value(metadata i8 %[[PHI]],
; CHECK-SAME: metadata !DIExpression())
%0 = add i8 %entryN, 1
; CHECK: %0 = add i8 %[[PHI]], 1
; CHECK: call void @llvm.dbg.value(metadata i8 %0,
; CHECK-SAME: metadata !DIExpression())
store i8 %0, i8* %entry1, align 8, !dbg !20
br label %for.cond, !dbg !20
}
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
attributes #0 = { nounwind ssp uwtable }
attributes #1 = { nounwind readnone }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!10, !11}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "adrian", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
!1 = !DIFile(filename: "<stdin>", directory: "/")
!2 = !{}
!4 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
!10 = !{i32 2, !"Debug Info Version", i32 3}
!11 = !{i32 1, !"PIC Level", i32 2}
!12 = distinct !DISubprogram(name: "scan", scope: !1, file: !1, line: 4, type: !13, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !15)
!13 = !DISubroutineType(types: !14)
!14 = !{null, !4, !4}
!15 = !{!18}
!18 = !DILocalVariable(name: "entry", scope: !12, file: !1, line: 6, type: !4)
!19 = !DIExpression()
!20 = !DILocation(line: 6, scope: !12)

View File

@ -0,0 +1,26 @@
; RUN: opt -mem2reg -S -o - < %s | FileCheck %s
declare void @llvm.lifetime.start.p0i8(i64 %size, i8* nocapture %ptr)
declare void @llvm.lifetime.end.p0i8(i64 %size, i8* nocapture %ptr)
define void @test1() {
; CHECK: test1
; CHECK-NOT: alloca
%A = alloca i32
%B = bitcast i32* %A to i8*
call void @llvm.lifetime.start.p0i8(i64 2, i8* %B)
store i32 1, i32* %A
call void @llvm.lifetime.end.p0i8(i64 2, i8* %B)
ret void
}
define void @test2() {
; CHECK: test2
; CHECK-NOT: alloca
%A = alloca {i8, i16}
%B = getelementptr {i8, i16}, {i8, i16}* %A, i32 0, i32 0
call void @llvm.lifetime.start.p0i8(i64 2, i8* %B)
store {i8, i16} zeroinitializer, {i8, i16}* %A
call void @llvm.lifetime.end.p0i8(i64 2, i8* %B)
ret void
}

Some files were not shown because too many files have changed in this diff Show More