mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 08:25:49 +01:00
Move `--output-last-file-only` and output filename synthesis logic out of the general-purpose compile driver and into the `carbon compile` subcommand, which is the only thing that should be using them. Track on CompilationUnit whether it is being lowered, or whether it exists only to be imported into other units. `carbon compile` now never lowers inputs that it discovered for itself, only inputs that were specified on the command line. In particular, it doesn't lower (and throw away the result of lowering) the prelude any more. This makes the toolchain tests about 10% faster in my crude measurements. Also, we now do not create a clang `CodeGenerator` for input files that we are not lowering, similarly saving compilation time for units that exist only to be imported, not lowered. One minor change: we use the same mechanism to determine whether an input is being lowered and to determine what the output filename is. This means that `--phase=lower` and `--phase=optimize`, which lower but don't produce an output file, still need an output filename to be specified now in some cases. Given those are just debugging tools, I think that's fine. Assisted-by: Gemini via Antigravity
117 lines
5.3 KiB
Plaintext
117 lines
5.3 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
|
|
//
|
|
// This is checking that the stdin filename is handled consistently across
|
|
// dump flags.
|
|
// TODO: Align lex/parse with check/lower.
|
|
//
|
|
// ARGS: compile - --output=- --phase=lower --no-prelude-import --target=x86_64-linux-gnu --dump-tokens --dump-parse-tree --parse-dump-format=yaml-postorder --dump-sem-ir --dump-raw-sem-ir --dump-llvm-ir
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/driver/testdata/stdin.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/driver/testdata/stdin.carbon
|
|
|
|
// CHECK:STDOUT: - filename: <stdin>
|
|
// CHECK:STDOUT: tokens:
|
|
// CHECK:STDOUT: - { index: 0, kind: "FileStart", line: 1, column: 1, indent: 1, spelling: "" }
|
|
// CHECK:STDOUT: - { index: 1, kind: "FileEnd", line: 1, column: 1, indent: 1, spelling: "", has_leading_space: true }
|
|
// CHECK:STDOUT: - filename: <stdin>
|
|
// CHECK:STDOUT: parse_tree: [
|
|
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
|
|
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
|
// CHECK:STDOUT: ]
|
|
// CHECK:STDOUT: ---
|
|
// CHECK:STDOUT: filename: '-'
|
|
// CHECK:STDOUT: sem_ir:
|
|
// CHECK:STDOUT: names: {}
|
|
// CHECK:STDOUT: import_irs:
|
|
// CHECK:STDOUT: 'import_ir(ApiForImpl)': {decl_id: inst<none>, is_export: false}
|
|
// CHECK:STDOUT: 'import_ir(Cpp)': {decl_id: inst<none>, is_export: false}
|
|
// CHECK:STDOUT: import_ir_insts: {}
|
|
// CHECK:STDOUT: clang_decls: {}
|
|
// CHECK:STDOUT: clang_decl_signatures: {}
|
|
// CHECK:STDOUT: name_scopes:
|
|
// CHECK:STDOUT: name_scope0: {inst: instF, parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {}}
|
|
// CHECK:STDOUT: entity_names: {}
|
|
// CHECK:STDOUT: functions: {}
|
|
// CHECK:STDOUT: classes: {}
|
|
// CHECK:STDOUT: interfaces: {}
|
|
// CHECK:STDOUT: associated_constants: {}
|
|
// CHECK:STDOUT: impls: {}
|
|
// CHECK:STDOUT: generics: {}
|
|
// CHECK:STDOUT: specifics: {}
|
|
// CHECK:STDOUT: specific_interfaces: {}
|
|
// CHECK:STDOUT: struct_type_fields:
|
|
// CHECK:STDOUT: struct_type_fields_empty: {}
|
|
// CHECK:STDOUT: types:
|
|
// CHECK:STDOUT: 'type(TypeType)':
|
|
// CHECK:STDOUT: value_repr: {kind: copy, type: type(TypeType)}
|
|
// CHECK:STDOUT: object_layout:
|
|
// CHECK:STDOUT: size: 0
|
|
// CHECK:STDOUT: alignment: 1
|
|
// CHECK:STDOUT: 'type(inst(FormType))':
|
|
// CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(FormType))}
|
|
// CHECK:STDOUT: object_layout:
|
|
// CHECK:STDOUT: size: 0
|
|
// CHECK:STDOUT: alignment: 1
|
|
// CHECK:STDOUT: 'type(Error)':
|
|
// CHECK:STDOUT: value_repr: {kind: copy, type: type(Error)}
|
|
// CHECK:STDOUT: object_layout:
|
|
// CHECK:STDOUT: size: 0
|
|
// CHECK:STDOUT: alignment: 1
|
|
// CHECK:STDOUT: 'type(inst(InstType))':
|
|
// CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(InstType))}
|
|
// CHECK:STDOUT: object_layout:
|
|
// CHECK:STDOUT: size: 0
|
|
// CHECK:STDOUT: alignment: 1
|
|
// CHECK:STDOUT: 'type(inst(NamespaceType))':
|
|
// CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(NamespaceType))}
|
|
// CHECK:STDOUT: object_layout:
|
|
// CHECK:STDOUT: size: 0
|
|
// CHECK:STDOUT: alignment: 1
|
|
// CHECK:STDOUT: declared_facet_types: {}
|
|
// CHECK:STDOUT: insts:
|
|
// CHECK:STDOUT: instF: {kind: Namespace, arg0: name_scope0, type: type(inst(NamespaceType))}
|
|
// CHECK:STDOUT: bundles: {}
|
|
// CHECK:STDOUT: constant_values:
|
|
// CHECK:STDOUT: values:
|
|
// CHECK:STDOUT: instF: concrete_constant(instF)
|
|
// CHECK:STDOUT: symbolic_constants: {}
|
|
// CHECK:STDOUT: inst_blocks:
|
|
// CHECK:STDOUT: inst_block_empty: {}
|
|
// CHECK:STDOUT: exports: {}
|
|
// CHECK:STDOUT: generated: {}
|
|
// CHECK:STDOUT: imports: {}
|
|
// CHECK:STDOUT: global_init: {}
|
|
// CHECK:STDOUT: inst_block60000005:
|
|
// CHECK:STDOUT: 0: instF
|
|
// CHECK:STDOUT: value_stores:
|
|
// CHECK:STDOUT: shared_values:
|
|
// CHECK:STDOUT: ints: {}
|
|
// CHECK:STDOUT: reals: {}
|
|
// CHECK:STDOUT: floats: {}
|
|
// CHECK:STDOUT: identifiers: {}
|
|
// CHECK:STDOUT: strings: {}
|
|
// CHECK:STDOUT: ...
|
|
// CHECK:STDOUT: --- -
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; ---
|
|
// CHECK:STDOUT: ; ModuleID = '-'
|
|
// CHECK:STDOUT: source_filename = "-"
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !llvm.dbg.cu = !{!0}
|
|
// CHECK:STDOUT: !llvm.module.flags = !{!2, !3}
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
|
|
// CHECK:STDOUT: !1 = !DIFile(filename: "-", directory: "")
|
|
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
|
|
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
|
|
// CHECK:STDOUT:
|