Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rudimentary name mangling support #4267

Merged
merged 46 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
450a2a2
Refactor name mangling into a separate class
dwblaikie Aug 27, 2024
5ef42c7
Add a name mangling prefix.
dwblaikie Aug 28, 2024
b879dc7
Namespace mangling
dwblaikie Aug 28, 2024
b692032
Mangle class scopes
dwblaikie Aug 29, 2024
69d25d7
Manually update assembly test for name mangling prefix
dwblaikie Aug 29, 2024
21a6391
Add impl/interface mangling
dwblaikie Aug 29, 2024
c31e8c2
Append name components directly
dwblaikie Aug 29, 2024
d6d2263
Mangle impls
dwblaikie Aug 29, 2024
5feca3d
Match parameter names
dwblaikie Sep 3, 2024
04b6dc3
Add vertical whitespace to toolchain/lower/mangler.h
dwblaikie Sep 3, 2024
12f35d4
Rename class_node -> class_info
dwblaikie Sep 3, 2024
26f1b4b
Avoid unnecessary package namespace lookup
dwblaikie Sep 3, 2024
6d6b07e
Keep a comment about needing to remap the return type for Run with vo…
dwblaikie Sep 3, 2024
c064332
Add a comment for MangleInverseQualifiedNameScope
dwblaikie Sep 3, 2024
c56c4f9
Rename parent to name_scope
dwblaikie Sep 3, 2024
7438817
Add helper functions for containers
dwblaikie Sep 3, 2024
adc0aba
Use sem_ir() helper.
dwblaikie Sep 3, 2024
2c5cf62
Switch to a CARBON_KIND_SWITCH
dwblaikie Sep 4, 2024
248ca95
Add comments for Mangler
dwblaikie Sep 4, 2024
c835a9e
Use data iteration instead of a while loop for name printing.
dwblaikie Sep 4, 2024
b86c11c
More data iteration stuff
dwblaikie Sep 4, 2024
08c2576
Remove recursion and add qualification for impl's interface name
dwblaikie Sep 4, 2024
e08c432
Remove commented out code, add a helper lambda
dwblaikie Sep 4, 2024
e169dc7
Simplify the code a bit
dwblaikie Sep 4, 2024
7d81cb5
Minor simplification
dwblaikie Sep 4, 2024
6ab771e
Fix name to match naming convention
dwblaikie Sep 4, 2024
6e199a0
Use const ref to avoid accidental copy
dwblaikie Sep 5, 2024
e9f2cdd
Rename name_id to name_scope_id
dwblaikie Sep 5, 2024
a73c68e
Add comment
dwblaikie Sep 5, 2024
2468626
Clarify entry point return type comment
dwblaikie Sep 5, 2024
004099a
Remove out-of-place comment
dwblaikie Sep 5, 2024
c4d4be0
Spelling fix
dwblaikie Sep 5, 2024
cbdb9cf
Rephrase comment, avoiding 'extern' terminology
dwblaikie Sep 5, 2024
89e1301
Add package name to mangling
dwblaikie Sep 5, 2024
fb13336
Document the 'prefix' member
dwblaikie Sep 5, 2024
2a25c6f
Fixes for renamed member
dwblaikie Sep 5, 2024
071f514
Add FIXME comment for generics
dwblaikie Sep 5, 2024
7cec2ef
Continue mangling, even once reaching the package name
dwblaikie Sep 5, 2024
c99163d
Comment formatting/sentencification
dwblaikie Sep 6, 2024
24ba431
Ignore the scope an impl is defined in
dwblaikie Sep 6, 2024
3d7f262
Merge branch 'trunk' into mangle_symbols
dwblaikie Sep 6, 2024
843b021
Line wrapping
dwblaikie Sep 6, 2024
2ea5b0c
Remove unnecessary clear() call
dwblaikie Sep 6, 2024
1c215f2
Simplify code with pop_back_val()
dwblaikie Sep 6, 2024
10f0633
Remove empty line
dwblaikie Sep 6, 2024
0fefc7d
Update tests
dwblaikie Sep 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion toolchain/codegen/testdata/assembly/basic.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
// ARGS: compile --no-prelude-import --target=x86_64-unknown-linux-gnu --output=- %s
// NOAUTOUPDATE
// SET-CHECK-SUBSET
// CHECK:STDOUT: Main:
// CHECK:STDOUT: _CMain.Main:

fn Main() {}
2 changes: 2 additions & 0 deletions toolchain/lower/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ cc_library(
"constant.h",
"file_context.cpp",
"function_context.cpp",
"mangler.cpp",
"mangler.h",
] +
# Glob handler files to avoid missing any.
glob([
Expand Down
16 changes: 5 additions & 11 deletions toolchain/lower/file_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "toolchain/base/kind_switch.h"
#include "toolchain/lower/constant.h"
#include "toolchain/lower/function_context.h"
#include "toolchain/lower/mangler.h"
#include "toolchain/sem_ir/entry_point.h"
#include "toolchain/sem_ir/file.h"
#include "toolchain/sem_ir/function.h"
Expand Down Expand Up @@ -233,22 +234,15 @@ auto FileContext::BuildFunctionDecl(SemIR::FunctionId function_id)

// Compute the return type to use for the LLVM function. If the initializing
// representation doesn't produce a value, set the return type to void.
// TODO: For the `Run` entry point, remap return type to i32 if it doesn't
// return a value.
llvm::Type* function_return_type =
return_info.init_repr.kind == SemIR::InitRepr::ByCopy
? return_type
: llvm::Type::getVoidTy(llvm_context());

std::string mangled_name;
if (SemIR::IsEntryPoint(sem_ir(), function_id)) {
// TODO: Add an implicit `return 0` if `Run` doesn't return `i32`.
jonmeow marked this conversation as resolved.
Show resolved Hide resolved
mangled_name = "main";
} else {
// TODO: Decide on a name mangling scheme.
auto name = sem_ir().names().GetAsStringIfIdentifier(function.name_id);
CARBON_CHECK(name) << "Unexpected special name for function: "
<< function.name_id;
mangled_name = *name;
}
Mangler m(*this);
std::string mangled_name = m.Mangle(function_id);

llvm::FunctionType* function_type = llvm::FunctionType::get(
function_return_type, param_types, /*isVarArg=*/false);
Expand Down
116 changes: 116 additions & 0 deletions toolchain/lower/mangler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// 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 "toolchain/lower/mangler.h"

#include "toolchain/base/kind_switch.h"
#include "toolchain/sem_ir/entry_point.h"

namespace Carbon::Lower {

auto Mangler::MangleInverseQualifiedNameScope(llvm::raw_ostream& os,
SemIR::NameScopeId name_scope_id)
-> void {
// Maintain a stack of names for delayed rendering of interface impls.
struct NameEntry {
dwblaikie marked this conversation as resolved.
Show resolved Hide resolved
SemIR::NameScopeId name_scope_id;

// The prefix emitted before this name component. If '\0', no prefix will be
// emitted.
// - Namespace components are separated by '.'.
// - The two components of an interface are separated by ':'.
char prefix;
jonmeow marked this conversation as resolved.
Show resolved Hide resolved
};
llvm::SmallVector<NameEntry> names_to_render;
names_to_render.push_back({.name_scope_id = name_scope_id, .prefix = '.'});
while (!names_to_render.empty()) {
auto [name_scope_id, prefix] = names_to_render.pop_back_val();
if (prefix) {
os << prefix;
}
if (name_scope_id == SemIR::NameScopeId::Package) {
if (auto package_id = sem_ir().package_id(); package_id.is_valid()) {
os << sem_ir().identifiers().Get(package_id);
} else {
os << "Main";
}
continue;
}
const auto& name_scope = sem_ir().name_scopes().Get(name_scope_id);
CARBON_KIND_SWITCH(sem_ir().insts().Get(name_scope.inst_id)) {
case CARBON_KIND(SemIR::ImplDecl impl_decl): {

dwblaikie marked this conversation as resolved.
Show resolved Hide resolved
const auto& impl = sem_ir().impls().Get(impl_decl.impl_id);

auto interface_type =
types().GetAs<SemIR::InterfaceType>(impl.constraint_id);
const auto& interface =
sem_ir().interfaces().Get(interface_type.interface_id);
names_to_render.push_back(
{.name_scope_id = interface.scope_id, .prefix = ':'});

CARBON_KIND_SWITCH(types().GetAsInst(impl.self_id)) {
case CARBON_KIND(SemIR::ClassType class_type): {
auto next_name_scope_id =
sem_ir().classes().Get(class_type.class_id).scope_id;
names_to_render.push_back(
{.name_scope_id = next_name_scope_id, .prefix = '\0'});
break;
}
case CARBON_KIND(SemIR::BuiltinInst builtin_inst): {
os << builtin_inst.builtin_inst_kind.label();
break;
}
default:
CARBON_FATAL() << "Attempting to mangle unsupported SemIR.";
break;
}
// Skip the tail of the loop that adds the parent name scope to the
// stack - the scope in which the impl was defined is not part of the
// mangling, the constraint and interface alone uniquelify identify an
// impl.
continue;
}
case CARBON_KIND(SemIR::ClassDecl class_decl): {
os << names().GetAsStringIfIdentifier(
sem_ir().classes().Get(class_decl.class_id).name_id);
break;
}
case CARBON_KIND(SemIR::InterfaceDecl interface_decl): {
os << names().GetAsStringIfIdentifier(
sem_ir().interfaces().Get(interface_decl.interface_id).name_id);
break;
}
case SemIR::Namespace::Kind: {
os << names().GetAsStringIfIdentifier(name_scope.name_id);
break;
}
default:
CARBON_FATAL() << "Attempting to mangle unsupported SemIR.";
break;
}
names_to_render.push_back(
{.name_scope_id = name_scope.parent_scope_id, .prefix = '.'});
}
}

auto Mangler::Mangle(SemIR::FunctionId function_id) -> std::string {
// FIXME: Add support for generic entities.

const auto& function = sem_ir().functions().Get(function_id);
if (SemIR::IsEntryPoint(sem_ir(), function_id)) {
return "main";
}
std::string result;
llvm::raw_string_ostream os(result);
os << "_C";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was kind of hoping @chandlerc would review and handle this in particular. I know we'd discussed _C as an option, but actually, considering swift mangling uses $s, should we consider a similar $c? I think one of the concerns with _C might've been too high a risk of conflicting with a C-based name, but maybe using a special character in mangling is a good way to avoid that problem entirely? Or maybe c. if we think we can use . in names?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to other ideas - The "_" form seems to be dominant, though (LLVM's demangler supports _Z for C++, _R for Rust, and _D for the D programming language).

Just looking at LLVM's demangler makes the fair point that a . prefix would be problematic (not that that's what you were suggesting) - because of the leading . in ELF symbol names, so the demangler strips those off by default.

Work backwards from _Z and use _Y (or perhaps _X, because X is cool)?

Though I'm really OK with whatever everyone else wants - and wouldn't totally object to using something following swift's pattern. So if $c is best for you, happy to switch to that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can separate this out if you want to start with _C as probably good.

I was actually thinking further, and if C. or C$ were an option (upper or lower case), particularly using a non-identifier character as separators instead of prefix, it might both (a) make the name easy to read and (b) offer a name that couldn't conflict with a C name.

But I'm realizing the difference between _C and $c isn't actually that big for us: we should be suffixing all mangled names with the package scope (e.g., _CFoo.Main), which should already avoid name conflicts with C names if we're using . separators. So if you don't think C<char> is a good choice, let's stick with _C for cross-language consistency.


os << names().GetAsStringIfIdentifier(function.name_id);

MangleInverseQualifiedNameScope(os, function.parent_scope_id);

return os.str();
}

} // namespace Carbon::Lower
48 changes: 48 additions & 0 deletions toolchain/lower/mangler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// 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

#ifndef CARBON_TOOLCHAIN_LOWER_MANGLER_H_
#define CARBON_TOOLCHAIN_LOWER_MANGLER_H_

#include <string>

#include "toolchain/lower/file_context.h"
#include "toolchain/sem_ir/ids.h"

namespace Carbon::Lower {

// A class for producing mangled (deterministically unique, at least partially
// human readable) names for externally referenceable entities such as
// functions.
class Mangler {
jonmeow marked this conversation as resolved.
Show resolved Hide resolved
public:
// Initialize a new Mangler instance for mangling entities within the
// specified `FileContext`.
explicit Mangler(FileContext& file_context) : file_context_(file_context) {}

// Produce a deterministically unique mangled name for the function specified
// by `function_id`.
auto Mangle(SemIR::FunctionId function_id) -> std::string;

private:
// Mangle this qualified name with inner scope first, working outwards. This
// may reduce the incidence of common prefixes in the name mangling. (i.e.:
// every standard library name won't have a common prefix that has to be
// skipped and compared before getting to the interesting part)
auto MangleInverseQualifiedNameScope(llvm::raw_ostream& os,
SemIR::NameScopeId name_scope_id)
-> void;

auto sem_ir() const -> const SemIR::File& { return file_context_.sem_ir(); }

auto names() const -> SemIR::NameStoreWrapper { return sem_ir().names(); }

auto types() const -> SemIR::TypeStore { return sem_ir().types(); }

FileContext& file_context_;
};

} // namespace Carbon::Lower

#endif // CARBON_TOOLCHAIN_LOWER_MANGLER_H_
4 changes: 2 additions & 2 deletions toolchain/lower/testdata/alias/local.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn F() -> i32 {
// CHECK:STDOUT: ; ModuleID = 'local.carbon'
// CHECK:STDOUT: source_filename = "local.carbon"
// CHECK:STDOUT:
// CHECK:STDOUT: define i32 @F() !dbg !4 {
// CHECK:STDOUT: define i32 @_CF.Main() !dbg !4 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: %a.var = alloca i32, align 4, !dbg !7
// CHECK:STDOUT: store i32 0, ptr %a.var, align 4, !dbg !8
Expand All @@ -32,7 +32,7 @@ fn F() -> i32 {
// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !3 = !DIFile(filename: "local.carbon", directory: "")
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
// CHECK:STDOUT: !6 = !{}
// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
Expand Down
10 changes: 5 additions & 5 deletions toolchain/lower/testdata/array/array_in_place.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ fn G() {
// CHECK:STDOUT: ; ModuleID = 'array_in_place.carbon'
// CHECK:STDOUT: source_filename = "array_in_place.carbon"
// CHECK:STDOUT:
// CHECK:STDOUT: declare void @F(ptr sret({ i32, i32, i32 }))
// CHECK:STDOUT: declare void @_CF.Main(ptr sret({ i32, i32, i32 }))
// CHECK:STDOUT:
// CHECK:STDOUT: define void @G() !dbg !4 {
// CHECK:STDOUT: define void @_CG.Main() !dbg !4 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: %v.var = alloca [2 x { i32, i32, i32 }], align 8, !dbg !7
// CHECK:STDOUT: %.loc14_42.2.array.index = getelementptr inbounds [2 x { i32, i32, i32 }], ptr %v.var, i32 0, i32 0, !dbg !8
// CHECK:STDOUT: call void @F(ptr %.loc14_42.2.array.index), !dbg !9
// CHECK:STDOUT: call void @_CF.Main(ptr %.loc14_42.2.array.index), !dbg !9
// CHECK:STDOUT: %.loc14_42.5.array.index = getelementptr inbounds [2 x { i32, i32, i32 }], ptr %v.var, i32 0, i32 1, !dbg !8
// CHECK:STDOUT: call void @F(ptr %.loc14_42.5.array.index), !dbg !10
// CHECK:STDOUT: call void @_CF.Main(ptr %.loc14_42.5.array.index), !dbg !10
// CHECK:STDOUT: ret void, !dbg !11
// CHECK:STDOUT: }
// CHECK:STDOUT:
Expand All @@ -36,7 +36,7 @@ fn G() {
// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !3 = !DIFile(filename: "array_in_place.carbon", directory: "")
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", linkageName: "G", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
// CHECK:STDOUT: !6 = !{}
// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 7, scope: !4)
Expand Down
6 changes: 3 additions & 3 deletions toolchain/lower/testdata/array/assign_return_value.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn Run() {
// CHECK:STDOUT:
// CHECK:STDOUT: @tuple.loc11_39 = internal constant { i32, i32 } { i32 12, i32 24 }
// CHECK:STDOUT:
// CHECK:STDOUT: define void @F(ptr sret({ i32, i32 }) %return) !dbg !4 {
// CHECK:STDOUT: define void @_CF.Main(ptr sret({ i32, i32 }) %return) !dbg !4 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: %.loc11_38.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 0, !dbg !7
// CHECK:STDOUT: %.loc11_38.4.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 1, !dbg !7
Expand All @@ -31,7 +31,7 @@ fn Run() {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: %t.var = alloca [2 x i32], align 4, !dbg !10
// CHECK:STDOUT: %.loc14_22.1.temp = alloca { i32, i32 }, align 8, !dbg !11
// CHECK:STDOUT: call void @F(ptr %.loc14_22.1.temp), !dbg !11
// CHECK:STDOUT: call void @_CF.Main(ptr %.loc14_22.1.temp), !dbg !11
// CHECK:STDOUT: %.loc14_22.3.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc14_22.1.temp, i32 0, i32 0, !dbg !11
// CHECK:STDOUT: %.loc14_22.4 = load i32, ptr %.loc14_22.3.tuple.elem, align 4, !dbg !11
// CHECK:STDOUT: %.loc14_22.6.array.index = getelementptr inbounds [2 x i32], ptr %t.var, i32 0, i32 0, !dbg !11
Expand All @@ -55,7 +55,7 @@ fn Run() {
// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !3 = !DIFile(filename: "assign_return_value.carbon", directory: "")
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
// CHECK:STDOUT: !6 = !{}
// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 31, scope: !4)
Expand Down
10 changes: 5 additions & 5 deletions toolchain/lower/testdata/array/function_param.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ fn G() -> i32 {
// CHECK:STDOUT:
// CHECK:STDOUT: @array.loc16_11.1 = internal constant [3 x i32] [i32 1, i32 2, i32 3]
// CHECK:STDOUT:
// CHECK:STDOUT: define i32 @F(ptr %arr, i32 %i) !dbg !4 {
// CHECK:STDOUT: define i32 @_CF.Main(ptr %arr, i32 %i) !dbg !4 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: %.loc12_15.2.array.index = getelementptr inbounds [3 x i32], ptr %arr, i32 0, i32 %i, !dbg !7
// CHECK:STDOUT: %.loc12_15.3 = load i32, ptr %.loc12_15.2.array.index, align 4, !dbg !7
// CHECK:STDOUT: ret i32 %.loc12_15.3, !dbg !8
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: define i32 @G() !dbg !9 {
// CHECK:STDOUT: define i32 @_CG.Main() !dbg !9 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: %.loc16_20.2.temp = alloca [3 x i32], align 4, !dbg !10
// CHECK:STDOUT: %.loc16_20.4.array.index = getelementptr inbounds [3 x i32], ptr %.loc16_20.2.temp, i32 0, i32 0, !dbg !10
// CHECK:STDOUT: %.loc16_20.7.array.index = getelementptr inbounds [3 x i32], ptr %.loc16_20.2.temp, i32 0, i32 1, !dbg !10
// CHECK:STDOUT: %.loc16_20.10.array.index = getelementptr inbounds [3 x i32], ptr %.loc16_20.2.temp, i32 0, i32 2, !dbg !10
// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %.loc16_20.2.temp, ptr align 4 @array.loc16_11.1, i64 12, i1 false), !dbg !11
// CHECK:STDOUT: %F.call = call i32 @F(ptr %.loc16_20.2.temp, i32 1), !dbg !11
// CHECK:STDOUT: %F.call = call i32 @_CF.Main(ptr %.loc16_20.2.temp, i32 1), !dbg !11
// CHECK:STDOUT: ret i32 %F.call, !dbg !12
// CHECK:STDOUT: }
// CHECK:STDOUT:
Expand All @@ -51,12 +51,12 @@ fn G() -> i32 {
// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !3 = !DIFile(filename: "function_param.carbon", directory: "")
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
// CHECK:STDOUT: !6 = !{}
// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 10, scope: !4)
// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4)
// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "G", linkageName: "G", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !10 = !DILocation(line: 16, column: 12, scope: !9)
// CHECK:STDOUT: !11 = !DILocation(line: 16, column: 10, scope: !9)
// CHECK:STDOUT: !12 = !DILocation(line: 16, column: 3, scope: !9)
8 changes: 4 additions & 4 deletions toolchain/lower/testdata/basics/false_true.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ fn T() -> bool {
// CHECK:STDOUT: ; ModuleID = 'false_true.carbon'
// CHECK:STDOUT: source_filename = "false_true.carbon"
// CHECK:STDOUT:
// CHECK:STDOUT: define i1 @F() !dbg !4 {
// CHECK:STDOUT: define i1 @_CF.Main() !dbg !4 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: ret i1 false, !dbg !7
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: define i1 @T() !dbg !8 {
// CHECK:STDOUT: define i1 @_CT.Main() !dbg !8 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: ret i1 true, !dbg !9
// CHECK:STDOUT: }
Expand All @@ -36,9 +36,9 @@ fn T() -> bool {
// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !3 = !DIFile(filename: "false_true.carbon", directory: "")
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
// CHECK:STDOUT: !6 = !{}
// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4)
// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "T", linkageName: "T", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "T", linkageName: "_CT.Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 3, scope: !8)
Loading
Loading