// Part of the Carbon Language project, under the Apache License v2.0 with LLVM // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon // // AUTOUPDATE // TIP: To test this file alone, run: // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/var/nested.carbon // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/var/nested.carbon fn Run() -> i32 { var a: i32 = 1; while (true) { var b: i32 = a; a = b; } return a; } // CHECK:STDOUT: ; --- // CHECK:STDOUT: ; ModuleID = 'nested.carbon' // CHECK:STDOUT: source_filename = "nested.carbon" // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define i32 @main() #0 !dbg !25 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %a.var = alloca i32, align 4, !dbg !28 // CHECK:STDOUT: %b.var = alloca i32, align 4, !dbg !31 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %a.var), !dbg !28 // CHECK:STDOUT: store i32 1, ptr %a.var, align 4, !dbg !28 // CHECK:STDOUT: br label %while.cond, !dbg !30 // CHECK:STDOUT: // CHECK:STDOUT: while.cond: ; preds = %while.body, %entry // CHECK:STDOUT: br i1 true, label %while.body, label %while.done, !dbg !30 // CHECK:STDOUT: // CHECK:STDOUT: while.body: ; preds = %while.cond // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %b.var), !dbg !31 // CHECK:STDOUT: %.loc16 = load i32, ptr %a.var, align 4, !dbg !32 // CHECK:STDOUT: store i32 %.loc16, ptr %b.var, align 4, !dbg !31 // CHECK:STDOUT: %.loc17 = load i32, ptr %b.var, align 4, !dbg !35 // CHECK:STDOUT: store i32 %.loc17, ptr %a.var, align 4, !dbg !34 // CHECK:STDOUT: call void @"_COp.f58524831c37807e:core.Destroy.Core"(ptr %b.var), !dbg !31 // CHECK:STDOUT: br label %while.cond, !dbg !36 // CHECK:STDOUT: // CHECK:STDOUT: while.done: ; preds = %while.cond // CHECK:STDOUT: %.loc19 = load i32, ptr %a.var, align 4, !dbg !37 // CHECK:STDOUT: call void @"_COp.f58524831c37807e:core.Destroy.Core"(ptr %a.var), !dbg !28 // CHECK:STDOUT: ret i32 %.loc19, !dbg !38 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.f58524831c37807e:core.Destroy.Core"(ptr %self) #0 !dbg !39 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !41 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1 // CHECK:STDOUT: // CHECK:STDOUT: ; uselistorder directives // CHECK:STDOUT: uselistorder ptr @"_COp.f58524831c37807e:core.Destroy.Core", { 1, 0 } // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 1, 0 } // CHECK:STDOUT: // CHECK:STDOUT: attributes #0 = { nounwind } // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) } // CHECK:STDOUT: // CHECK:STDOUT: !llvm.dbg.cu = !{!19} // CHECK:STDOUT: !llvm.module.flags = !{!2, !3} // CHECK:STDOUT: // CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5} // CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3} // CHECK:STDOUT: !18 = !DIFile(filename: "nested.carbon", directory: "") // CHECK:STDOUT: !19 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !18, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) // CHECK:STDOUT: !20 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) // CHECK:STDOUT: !21 = !{!20} // CHECK:STDOUT: !22 = !DISubroutineType(types: !21) // CHECK:STDOUT: !23 = !{null, !20} // CHECK:STDOUT: !24 = !DISubroutineType(types: !23) // CHECK:STDOUT: !25 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !18, line: 13, type: !22, spFlags: DISPFlagDefinition, unit: !19) // CHECK:STDOUT: !28 = !DILocation(line: 14, column: 3, scope: !25) // CHECK:STDOUT: !30 = !DILocation(line: 15, column: 9, scope: !25) // CHECK:STDOUT: !31 = !DILocation(line: 16, column: 5, scope: !25) // CHECK:STDOUT: !32 = !DILocation(line: 16, column: 18, scope: !25) // CHECK:STDOUT: !34 = !DILocation(line: 17, column: 5, scope: !25) // CHECK:STDOUT: !35 = !DILocation(line: 17, column: 9, scope: !25) // CHECK:STDOUT: !36 = !DILocation(line: 15, column: 3, scope: !25) // CHECK:STDOUT: !37 = !DILocation(line: 19, column: 10, scope: !25) // CHECK:STDOUT: !38 = !DILocation(line: 19, column: 3, scope: !25) // CHECK:STDOUT: !39 = distinct !DISubprogram(name: "Op", linkageName: "_COp.f58524831c37807e:core.Destroy.Core", scope: null, file: !18, line: 16, type: !24, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !42) // CHECK:STDOUT: !40 = !DILocalVariable(arg: 1, scope: !39, type: !20) // CHECK:STDOUT: !41 = !DILocation(line: 16, column: 5, scope: !39) // CHECK:STDOUT: !42 = !{!40} // CHECK:STDOUT: