mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-25 20:10:12 +01:00
Updated patch 0006 to include new files added in https://github.com/llvm/llvm-project/pull/207543. Dropped patch 0009 which was upstreamed in: https://github.com/llvm/llvm-project/pull/190088 Minor updates to patch 0011 for changes upstream. Minor updates in export.cpp to use `llvm::FoldingSetInsertToken` instead of a void pointer.
142 lines
7.6 KiB
Plaintext
142 lines
7.6 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/int.carbon
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/interop/cpp/array.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/interop/cpp/array.carbon
|
|
|
|
// --- array_value_param.carbon
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp;
|
|
|
|
fn F(a: array(i32, 5)) -> i32 { return a[2]; }
|
|
|
|
inline Cpp '''
|
|
int G() {
|
|
int arr[5];
|
|
return Carbon::F(arr);
|
|
}
|
|
|
|
int H() {
|
|
return Carbon::F({1, 2, 3, 4, 5});
|
|
}
|
|
''';
|
|
|
|
// CHECK:STDOUT: ; ---
|
|
// CHECK:STDOUT: ; ModuleID = 'array_value_param.carbon'
|
|
// CHECK:STDOUT: source_filename = "array_value_param.carbon"
|
|
// CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
|
|
// CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: @constinit = private constant [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5], align 4
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: mustprogress uwtable
|
|
// CHECK:STDOUT: define dso_local noundef i32 @_Z1Gv() #0 {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: %arr = alloca [5 x i32], align 16
|
|
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %arr) #3
|
|
// CHECK:STDOUT: %call = call noundef i32 @_ZN6CarbonL1FERA5_Ki(ptr noundef nonnull align 4 dereferenceable(20) %arr)
|
|
// CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %arr) #3
|
|
// CHECK:STDOUT: ret i32 %call
|
|
// 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: alwaysinline mustprogress nounwind uwtable
|
|
// CHECK:STDOUT: define internal noundef i32 @_ZN6CarbonL1FERA5_Ki(ptr noundef nonnull align 4 dereferenceable(20) %0) #2 {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: %retval = alloca i32, align 4
|
|
// CHECK:STDOUT: %.addr = alloca ptr, align 8
|
|
// CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !46
|
|
// CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !46, !nonnull !47, !align !48
|
|
// CHECK:STDOUT: call void @_CF__carbon_thunk.Main(ptr noundef nonnull align 4 dereferenceable(20) %1, ptr noundef nonnull align 4 dereferenceable(4) %retval)
|
|
// CHECK:STDOUT: %2 = load i32, ptr %retval, align 4
|
|
// CHECK:STDOUT: ret i32 %2
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
|
|
// CHECK:STDOUT: declare void @llvm.lifetime.end.p0(ptr captures(none)) #1
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: mustprogress uwtable
|
|
// CHECK:STDOUT: define dso_local noundef i32 @_Z1Hv() #0 {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: %ref.tmp = alloca [5 x i32], align 4
|
|
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %ref.tmp) #3
|
|
// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %ref.tmp, ptr align 4 @constinit, i64 20, i1 false), !tbaa.struct !3
|
|
// CHECK:STDOUT: %call = call noundef i32 @_ZN6CarbonL1FERA5_Ki(ptr noundef nonnull align 4 dereferenceable(20) %ref.tmp)
|
|
// CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %ref.tmp) #3
|
|
// CHECK:STDOUT: ret i32 %call
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
|
|
// CHECK:STDOUT: declare void @llvm.memcpy.p0.p0.i64(ptr noalias writeonly captures(none), ptr noalias readonly captures(none), i64, i1 immarg) #1
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nounwind
|
|
// CHECK:STDOUT: define i32 @_CF.Main(ptr %a) #3 !dbg !30 {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: %.loc5_43.2.array.index = getelementptr inbounds [5 x i32], ptr %a, i32 0, i32 2, !dbg !35
|
|
// CHECK:STDOUT: %.loc5_43.3 = load i32, ptr %.loc5_43.2.array.index, align 4, !dbg !35
|
|
// CHECK:STDOUT: ret i32 %.loc5_43.3, !dbg !36
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nounwind
|
|
// CHECK:STDOUT: define void @_CF__carbon_thunk.Main(ptr %_, ptr %_1) #3 !dbg !38 {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: %F.call = call i32 @_CF.Main(ptr %_), !dbg !41
|
|
// CHECK:STDOUT: store i32 %F.call, ptr %_1, align 4, !dbg !41
|
|
// CHECK:STDOUT: ret void, !dbg !41
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
|
// CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
|
|
// CHECK:STDOUT: attributes #2 = { alwaysinline mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
|
// CHECK:STDOUT: attributes #3 = { nounwind }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !llvm.dbg.cu = !{!23}
|
|
// CHECK:STDOUT: !llvm.module.flags = !{!49, !50, !51, !6, !7}
|
|
// CHECK:STDOUT: !llvm.errno.tbaa = !{!53}
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !0 = !{!"Simple C++ TBAA"}
|
|
// CHECK:STDOUT: !1 = !{!"omnipotent char", !0, i64 0}
|
|
// CHECK:STDOUT: !2 = !{!1, !1, i64 0}
|
|
// CHECK:STDOUT: !3 = !{i64 0, i64 20, !2}
|
|
// CHECK:STDOUT: !6 = !{i32 7, !"Dwarf Version", i32 5}
|
|
// CHECK:STDOUT: !7 = !{i32 2, !"Debug Info Version", i32 3}
|
|
// CHECK:STDOUT: !22 = !DIFile(filename: "array_value_param.carbon", directory: "")
|
|
// CHECK:STDOUT: !23 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !22, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
|
|
// CHECK:STDOUT: !24 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
|
// CHECK:STDOUT: !25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
|
|
// CHECK:STDOUT: !26 = !{!24, !25}
|
|
// CHECK:STDOUT: !27 = !DISubroutineType(types: !26)
|
|
// CHECK:STDOUT: !28 = !{null, !25, !24}
|
|
// CHECK:STDOUT: !29 = !DISubroutineType(types: !28)
|
|
// CHECK:STDOUT: !30 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !22, line: 5, type: !27, spFlags: DISPFlagDefinition, unit: !23, retainedNodes: !37)
|
|
// CHECK:STDOUT: !31 = !DILocalVariable(arg: 1, scope: !30, type: !25)
|
|
// CHECK:STDOUT: !35 = !DILocation(line: 5, column: 40, scope: !30)
|
|
// CHECK:STDOUT: !36 = !DILocation(line: 5, column: 33, scope: !30)
|
|
// CHECK:STDOUT: !37 = !{!31}
|
|
// CHECK:STDOUT: !38 = distinct !DISubprogram(name: "F__carbon_thunk", linkageName: "_CF__carbon_thunk.Main", scope: null, file: !22, line: 5, type: !29, spFlags: DISPFlagDefinition, unit: !23, retainedNodes: !42)
|
|
// CHECK:STDOUT: !39 = !DILocalVariable(arg: 1, scope: !38, type: !25)
|
|
// CHECK:STDOUT: !40 = !DILocalVariable(arg: 2, scope: !38, type: !24)
|
|
// CHECK:STDOUT: !41 = !DILocation(line: 5, column: 1, scope: !38)
|
|
// CHECK:STDOUT: !42 = !{!39, !40}
|
|
// CHECK:STDOUT: !43 = !{!"int", !1, i64 0}
|
|
// CHECK:STDOUT: !44 = !{!"any pointer", !1, i64 0}
|
|
// CHECK:STDOUT: !45 = !{!"p1 int", !44, i64 0}
|
|
// CHECK:STDOUT: !46 = !{!45, !45, i64 0}
|
|
// CHECK:STDOUT: !47 = !{}
|
|
// CHECK:STDOUT: !48 = !{i64 4}
|
|
// CHECK:STDOUT: !49 = !{i32 8, !"PIC Level", i32 2}
|
|
// CHECK:STDOUT: !50 = !{i32 7, !"PIE Level", i32 2}
|
|
// CHECK:STDOUT: !51 = !{i32 7, !"uwtable", i32 2}
|
|
// CHECK:STDOUT: !52 = !{!"__libc_errno", !43, i64 0}
|
|
// CHECK:STDOUT: !53 = !{!52, !43, i64 0}
|
|
// CHECK:STDOUT:
|