brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · 158182c Raw
114 lines · plain
1; RUN: opt -passes='require<profile-summary>,function(codegenprepare)' -S < %s | FileCheck %s2 3; The following target lines are needed for the test to exercise what it should.4; Without these lines, CodeGenPrepare does not try to sink the bitcasts.5target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"6target triple = "x86_64-pc-windows-msvc"7 8declare i32 @__CxxFrameHandler3(...)9 10declare void @f()11 12declare void @g(ptr)13declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #214 15; CodeGenPrepare will want to sink these bitcasts, but it selects the catchpad16; blocks as the place to which the bitcast should be sunk.  Since catchpads17; do not allow non-phi instructions before the terminator, this isn't possible.18 19; CHECK-LABEL: @test(20define void @test(ptr %addr) personality ptr @__CxxFrameHandler3 {21entry:22  %x = getelementptr i32, ptr %addr, i32 123  invoke void @f()24          to label %invoke.cont unwind label %catch125 26; CHECK: invoke.cont:27; CHECK-NEXT: %y = getelementptr i32, ptr %addr, i32 228invoke.cont:29  %y = getelementptr i32, ptr %addr, i32 230  invoke void @f()31          to label %done unwind label %catch232 33done:34  ret void35 36catch1:37  %cs1 = catchswitch within none [label %handler1] unwind to caller38 39handler1:40  %cp1 = catchpad within %cs1 []41  br label %catch.shared42; CHECK: handler1:43; CHECK-NEXT: catchpad within %cs144 45catch2:46  %cs2 = catchswitch within none [label %handler2] unwind to caller47 48handler2:49  %cp2 = catchpad within %cs2 []50  br label %catch.shared51; CHECK: handler2:52; CHECK: catchpad within %cs253 54; CHECK: catch.shared:55; CHECK-NEXT: %p = phi ptr [ %x, %handler1 ], [ %y, %handler2 ]56catch.shared:57  %p = phi ptr [ %x, %handler1 ], [ %y, %handler2 ]58  call void @g(ptr %p)59  unreachable60}61 62; CodeGenPrepare will want to hoist these llvm.dbg.value calls to the phi, but63; there is no insertion point in a catchpad block.64 65; CHECK-LABEL: @test_dbg_value(66define void @test_dbg_value() personality ptr @__CxxFrameHandler3 {67entry:68  %a = alloca i869  %b = alloca i870  invoke void @f() to label %next unwind label %catch.dispatch71next:72  invoke void @f() to label %ret unwind label %catch.dispatch73ret:74  ret void75 76catch.dispatch:77  %p = phi ptr [%a, %entry], [%b, %next]78  %cs1 = catchswitch within none [label %catch] unwind to caller79 80catch:81  %cp1 = catchpad within %cs1 []82  tail call void @llvm.dbg.value(metadata ptr %p, i64 0, metadata !11, metadata !13), !dbg !1483  call void @g(ptr %p)84  catchret from %cp1 to label %ret85 86; CHECK: catch.dispatch:87; CHECK-NEXT: phi ptr88; CHECK-NEXT: catchswitch89; CHECK-NOT: #dbg_value90 91; CHECK: catch:92; CHECK-NEXT: catchpad93; CHECK-NEXT: #dbg_value94}95 96!llvm.dbg.cu = !{!0}97!llvm.module.flags = !{!7, !8, !9}98!llvm.ident = !{!10}99 100!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (trunk 254906) (llvm/trunk 254917)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: null)101!1 = !DIFile(filename: "t.c", directory: "D:\5Csrc\5Cllvm\5Cbuild")102!4 = distinct !DISubprogram(name: "test_dbg_value", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !0, retainedNodes: null)103!5 = !DISubroutineType(types: !6)104!6 = !{null}105!7 = !{i32 2, !"Dwarf Version", i32 4}106!8 = !{i32 2, !"Debug Info Version", i32 3}107!9 = !{i32 1, !"PIC Level", i32 2}108!10 = !{!"clang version 3.8.0 (trunk 254906) (llvm/trunk 254917)"}109!11 = !DILocalVariable(name: "p", scope: !4, file: !1, line: 2, type: !12)110!12 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)111!13 = !DIExpression(DW_OP_deref)112!14 = !DILocation(line: 2, column: 8, scope: !4)113!15 = !DILocation(line: 3, column: 1, scope: !4)114