class_with_fun.carbon 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/global/class_with_fun.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/global/class_with_fun.carbon
  10. class A {}
  11. fn ret_a() -> A {
  12. return {};
  13. }
  14. var a: A = {};
  15. // CHECK:STDOUT: ; ModuleID = 'class_with_fun.carbon'
  16. // CHECK:STDOUT: source_filename = "class_with_fun.carbon"
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: @a = internal global {}
  19. // CHECK:STDOUT: @struct.loc13_12 = internal constant {} zeroinitializer
  20. // CHECK:STDOUT: @struct.loc16_14 = internal constant {} zeroinitializer
  21. // CHECK:STDOUT: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 0, ptr @__global_init, ptr null }]
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: define void @ret_a(ptr sret({}) %return) {
  24. // CHECK:STDOUT: entry:
  25. // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %return, ptr align 1 @struct.loc13_12, i64 0, i1 false)
  26. // CHECK:STDOUT: ret void
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: define void @__global_init() {
  30. // CHECK:STDOUT: entry:
  31. // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 @a, ptr align 1 @struct.loc16_14, i64 0, i1 false)
  32. // CHECK:STDOUT: ret void
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
  36. // CHECK:STDOUT: declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: ; uselistorder directives
  39. // CHECK:STDOUT: uselistorder ptr @llvm.memcpy.p0.p0.i64, { 1, 0 }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }