mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 06:41:06 +01:00
132 lines
8.1 KiB
Plaintext
132 lines
8.1 KiB
Plaintext
// 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/full.carbon
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/operators/increment.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/operators/increment.carbon
|
|
|
|
// --- increment.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
fn IncrSigned() {
|
|
var from: i32 = 0;
|
|
++from;
|
|
}
|
|
|
|
// CHECK:STDOUT: ; ---
|
|
// CHECK:STDOUT: ; ModuleID = 'increment.carbon'
|
|
// CHECK:STDOUT: source_filename = "increment.carbon"
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nounwind
|
|
// CHECK:STDOUT: define void @_CIncrSigned.Main() #0 !dbg !11 {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: %from.var = alloca i32, align 4, !dbg !12
|
|
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %from.var), !dbg !12
|
|
// CHECK:STDOUT: store i32 0, ptr %from.var, align 4, !dbg !12
|
|
// CHECK:STDOUT: call void @"_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8"(ptr %from.var), !dbg !15
|
|
// CHECK:STDOUT: call void @"_CSelfDestruct.f58524831c37807e:core.Destroy.Core"(ptr %from.var), !dbg !12
|
|
// CHECK:STDOUT: ret void, !dbg !16
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nounwind
|
|
// CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.6dae29ece9a708c4:core.Destroy.Core"(ptr %self) #0 !dbg !17 {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: ret void, !dbg !19
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nounwind
|
|
// CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.f58524831c37807e:core.Destroy.Core"(ptr %self) #0 !dbg !21 {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: ret void, !dbg !23
|
|
// 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: ; Function Attrs: nounwind
|
|
// CHECK:STDOUT: define linkonce_odr void @"_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8"(ptr %self) #0 !dbg !26 {
|
|
// CHECK:STDOUT: call void @"_COp:thunk:AddAssignWith.39e2e78a3c2e036d.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.83481f1872d67895"(ptr %self, i32 1), !dbg !29
|
|
// CHECK:STDOUT: ret void, !dbg !32
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
|
|
// CHECK:STDOUT: define linkonce_odr void @"_COp:thunk:AddAssignWith.39e2e78a3c2e036d.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.83481f1872d67895"(ptr %self, i32 %other) #2 !dbg !34 {
|
|
// CHECK:STDOUT: %1 = call i32 @"_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.bb469f8924cce044"(i32 %other), !dbg !37
|
|
// CHECK:STDOUT: %2 = load i32, ptr %self, align 4, !dbg !38
|
|
// CHECK:STDOUT: %3 = add i32 %2, %1, !dbg !38
|
|
// CHECK:STDOUT: store i32 %3, ptr %self, align 4, !dbg !38
|
|
// CHECK:STDOUT: ret void, !dbg !38
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nounwind
|
|
// CHECK:STDOUT: define linkonce_odr i32 @"_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.bb469f8924cce044"(i32 %self) #0 !dbg !42 {
|
|
// CHECK:STDOUT: %1 = call i32 @"_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8"(i32 %self), !dbg !47
|
|
// CHECK:STDOUT: ret i32 %1, !dbg !49
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nounwind
|
|
// CHECK:STDOUT: define linkonce_odr i32 @"_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8"(i32 %self) #0 !dbg !51 {
|
|
// CHECK:STDOUT: ret i32 %self, !dbg !57
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: attributes #0 = { nounwind }
|
|
// CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
|
|
// CHECK:STDOUT: attributes #2 = { alwaysinline nounwind }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !llvm.dbg.cu = !{!5}
|
|
// 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: !4 = !DIFile(filename: "increment.carbon", directory: "")
|
|
// CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !4, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
|
|
// CHECK:STDOUT: !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
|
// CHECK:STDOUT: !7 = !{null}
|
|
// CHECK:STDOUT: !8 = !DISubroutineType(types: !7)
|
|
// CHECK:STDOUT: !9 = !{null, !6}
|
|
// CHECK:STDOUT: !10 = !DISubroutineType(types: !9)
|
|
// CHECK:STDOUT: !11 = distinct !DISubprogram(name: "IncrSigned", linkageName: "_CIncrSigned.Main", scope: null, file: !4, line: 4, type: !8, spFlags: DISPFlagDefinition, unit: !5)
|
|
// CHECK:STDOUT: !12 = !DILocation(line: 5, column: 3, scope: !11)
|
|
// CHECK:STDOUT: !15 = !DILocation(line: 6, column: 3, scope: !11)
|
|
// CHECK:STDOUT: !16 = !DILocation(line: 4, column: 1, scope: !11)
|
|
// CHECK:STDOUT: !17 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.6dae29ece9a708c4:core.Destroy.Core", scope: null, file: !4, line: 5, type: !10, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !20)
|
|
// CHECK:STDOUT: !18 = !DILocalVariable(arg: 1, scope: !17, type: !6)
|
|
// CHECK:STDOUT: !19 = !DILocation(line: 5, column: 3, scope: !17)
|
|
// CHECK:STDOUT: !20 = !{!18}
|
|
// CHECK:STDOUT: !21 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.f58524831c37807e:core.Destroy.Core", scope: null, file: !4, line: 5, type: !10, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !24)
|
|
// CHECK:STDOUT: !22 = !DILocalVariable(arg: 1, scope: !21, type: !6)
|
|
// CHECK:STDOUT: !23 = !DILocation(line: 5, column: 3, scope: !21)
|
|
// CHECK:STDOUT: !24 = !{!22}
|
|
// CHECK:STDOUT: !25 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "")
|
|
// CHECK:STDOUT: !26 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !25, line: 396, type: !10, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !33)
|
|
// CHECK:STDOUT: !27 = !DILocalVariable(arg: 1, scope: !26, type: !6)
|
|
// CHECK:STDOUT: !29 = !DILocation(line: 398, column: 5, scope: !26)
|
|
// CHECK:STDOUT: !30 = !{null, !6, !6}
|
|
// CHECK:STDOUT: !31 = !DISubroutineType(types: !30)
|
|
// CHECK:STDOUT: !32 = !DILocation(line: 396, column: 3, scope: !26)
|
|
// CHECK:STDOUT: !33 = !{!27}
|
|
// CHECK:STDOUT: !34 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.39e2e78a3c2e036d.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.83481f1872d67895", scope: null, file: !25, line: 331, type: !31, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !41)
|
|
// CHECK:STDOUT: !35 = !DILocalVariable(arg: 1, scope: !34, type: !6)
|
|
// CHECK:STDOUT: !36 = !DILocalVariable(arg: 2, scope: !34, type: !6)
|
|
// CHECK:STDOUT: !37 = !DILocation(line: 0, scope: !34)
|
|
// CHECK:STDOUT: !38 = !DILocation(line: 331, column: 3, scope: !34)
|
|
// CHECK:STDOUT: !39 = !{!6, !6}
|
|
// CHECK:STDOUT: !40 = !DISubroutineType(types: !39)
|
|
// CHECK:STDOUT: !41 = !{!35, !36}
|
|
// CHECK:STDOUT: !42 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.bb469f8924cce044", scope: null, file: !25, line: 64, type: !40, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !50)
|
|
// CHECK:STDOUT: !43 = !DILocalVariable(arg: 1, scope: !42, type: !6)
|
|
// CHECK:STDOUT: !47 = !DILocation(line: 66, column: 17, scope: !42)
|
|
// CHECK:STDOUT: !49 = !DILocation(line: 66, column: 5, scope: !42)
|
|
// CHECK:STDOUT: !50 = !{!43}
|
|
// CHECK:STDOUT: !51 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !25, line: 59, type: !40, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !58)
|
|
// CHECK:STDOUT: !52 = !DILocalVariable(arg: 1, scope: !51, type: !6)
|
|
// CHECK:STDOUT: !57 = !DILocation(line: 59, column: 28, scope: !51)
|
|
// CHECK:STDOUT: !58 = !{!52}
|
|
// CHECK:STDOUT:
|