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

Add rudimentry debug info metadata emission #4225

Merged
20 changes: 18 additions & 2 deletions toolchain/driver/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,14 @@ Excludes files with the given prefix from dumps.
)""",
},
[&](auto& arg_b) { arg_b.Set(&exclude_dump_file_prefix); });
b.AddFlag(
{
.name = "debug-info",
.help = R"""(
Emit DWARF debug information.
)""",
},
[&](auto& arg_b) { arg_b.Set(&include_debug_info); });
}

Phase phase;
Expand All @@ -358,6 +366,7 @@ Excludes files with the given prefix from dumps.
bool preorder_parse_tree = false;
bool builtin_sem_ir = false;
bool prelude_import = false;
bool include_debug_info = false;

llvm::StringRef exclude_dump_file_prefix;
};
Expand Down Expand Up @@ -523,6 +532,12 @@ auto Driver::ValidateCompileOptions(const CompileOptions& options) const
<< options.phase << "'.\n";
return false;
}
if (options.include_debug_info) {
error_stream_
<< "ERROR: Requested debug info but compile phase is limited to '"
<< options.phase << "'.\n";
return false;
}
[[fallthrough]];
case Phase::Lower:
case Phase::CodeGen:
Expand Down Expand Up @@ -676,8 +691,9 @@ class Driver::CompilationUnit {
// TODO: Consider disabling instruction naming by default if we're not
// producing textual LLVM IR.
SemIR::InstNamer inst_namer(*tokens_, *parse_tree_, *sem_ir_);
module_ = Lower::LowerToLLVM(*llvm_context_, input_filename_, *sem_ir_,
&inst_namer, vlog_stream_);
module_ = Lower::LowerToLLVM(*llvm_context_, options_.include_debug_info,
input_filename_, *sem_ir_, &inst_namer,
vlog_stream_);
});
if (vlog_stream_) {
CARBON_VLOG() << "*** llvm::Module ***\n";
Expand Down
24 changes: 22 additions & 2 deletions toolchain/lower/file_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@
namespace Carbon::Lower {

FileContext::FileContext(llvm::LLVMContext& llvm_context,
llvm::StringRef module_name, const SemIR::File& sem_ir,
bool include_debug_info, llvm::StringRef module_name,
const SemIR::File& sem_ir,
const SemIR::InstNamer* inst_namer,
llvm::raw_ostream* vlog_stream)
: llvm_context_(&llvm_context),
llvm_module_(std::make_unique<llvm::Module>(module_name, llvm_context)),
di_builder_(*llvm_module_),
sem_ir_(&sem_ir),
inst_namer_(inst_namer),
vlog_stream_(vlog_stream) {
vlog_stream_(vlog_stream),
include_debug_info_(include_debug_info) {
CARBON_CHECK(!sem_ir.has_errors())
<< "Generating LLVM IR from invalid SemIR::File is unsupported.";
BuildCompileUnit(module_name);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rename this to BuildDICompileUnit? I was having trouble seeing where di_compile_unit_ was initialized -- but maybe it'd be even better to have the method be static and return the DICompileUnit* instead of void, allowing initializing as di_compile_unit_(BuildDICompileUnit(module_name))?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, renamed to BuildDICompileUnit.
It'd take a few more parameters to make it static (include_debug_info_ (though we could move that out into the call site), di_builder_, and llvm_module_)) - I'll give it a go and you can see whether it feels better that way.

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good, I think one nice thing about static is it's harder to accidentally use uninitialized members.

}

// TODO: Move this to lower.cpp.
Expand Down Expand Up @@ -66,6 +70,22 @@ auto FileContext::Run() -> std::unique_ptr<llvm::Module> {
return std::move(llvm_module_);
}

auto FileContext::BuildCompileUnit(llvm::StringRef module_name) -> void {
if (!include_debug_info_)
dwblaikie marked this conversation as resolved.
Show resolved Hide resolved
return;
// FIXME: Include directory path in the cu_file.
dwblaikie marked this conversation as resolved.
Show resolved Hide resolved
llvm::DIFile* cu_file = di_builder_.createFile(module_name, "");
jonmeow marked this conversation as resolved.
Show resolved Hide resolved
// FIXME: Introduce a new language code for Carbon. C works well for now since
// it's something debuggers will already know/have support for at least.
// Probably have to bump to C++ at some point for virtual functions,
// templates, etc.
di_compile_unit_ = di_builder_.createCompileUnit(
llvm::dwarf::DW_LANG_C, cu_file, "carbon", false, "", 0, "");
dwblaikie marked this conversation as resolved.
Show resolved Hide resolved
llvm_module_->addModuleFlag(llvm::Module::Max, "Dwarf Version", 5);
llvm_module_->addModuleFlag(llvm::Module::Warning, "Debug Info Version",
llvm::DEBUG_METADATA_VERSION);
}

auto FileContext::GetGlobal(SemIR::InstId inst_id) -> llvm::Value* {
auto inst = sem_ir().insts().Get(inst_id);

Expand Down
11 changes: 10 additions & 1 deletion toolchain/lower/file_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define CARBON_TOOLCHAIN_LOWER_FILE_CONTEXT_H_

#include "llvm/IR/Constants.h"
#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "toolchain/sem_ir/file.h"
Expand All @@ -16,7 +17,7 @@ namespace Carbon::Lower {
// Context and shared functionality for lowering handlers.
class FileContext {
public:
explicit FileContext(llvm::LLVMContext& llvm_context,
explicit FileContext(llvm::LLVMContext& llvm_context, bool include_debug_info,
llvm::StringRef module_name, const SemIR::File& sem_ir,
const SemIR::InstNamer* inst_namer,
llvm::raw_ostream* vlog_stream);
Expand All @@ -25,6 +26,9 @@ class FileContext {
// the main execution loop.
auto Run() -> std::unique_ptr<llvm::Module>;

// Create the DICompileUnit metadata for this compilation.
auto BuildCompileUnit(llvm::StringRef module_name) -> void;

// Gets a callable's function. Returns nullptr for a builtin.
auto GetFunction(SemIR::FunctionId function_id) -> llvm::Function* {
return functions_[function_id.index];
Expand Down Expand Up @@ -76,6 +80,8 @@ class FileContext {
// State for building the LLVM IR.
llvm::LLVMContext* llvm_context_;
std::unique_ptr<llvm::Module> llvm_module_;
llvm::DIBuilder di_builder_;
llvm::DICompileUnit *di_compile_unit_;
dwblaikie marked this conversation as resolved.
Show resolved Hide resolved

// The input SemIR.
const SemIR::File* const sem_ir_;
Expand All @@ -101,6 +107,9 @@ class FileContext {
// Maps constants to their lowered values.
// We resize this directly to the (often large) correct size.
llvm::SmallVector<llvm::Constant*, 0> constants_;

// Specify whether to include debug info metadata in the generated LLVM IR.
bool include_debug_info_;
jonmeow marked this conversation as resolved.
Show resolved Hide resolved
};

} // namespace Carbon::Lower
Expand Down
1 change: 1 addition & 0 deletions toolchain/lower/handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
Expand Down
9 changes: 5 additions & 4 deletions toolchain/lower/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

namespace Carbon::Lower {

auto LowerToLLVM(llvm::LLVMContext& llvm_context, llvm::StringRef module_name,
const SemIR::File& sem_ir, const SemIR::InstNamer* inst_namer,
auto LowerToLLVM(llvm::LLVMContext& llvm_context, bool include_debug_info,
llvm::StringRef module_name, const SemIR::File& sem_ir,
const SemIR::InstNamer* inst_namer,
llvm::raw_ostream* vlog_stream)
-> std::unique_ptr<llvm::Module> {
FileContext context(llvm_context, module_name, sem_ir, inst_namer,
vlog_stream);
FileContext context(llvm_context, include_debug_info, module_name, sem_ir,
inst_namer, vlog_stream);
return context.Run();
}

Expand Down
5 changes: 3 additions & 2 deletions toolchain/lower/lower.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
namespace Carbon::Lower {

// Lowers SemIR to LLVM IR.
auto LowerToLLVM(llvm::LLVMContext& llvm_context, llvm::StringRef module_name,
const SemIR::File& sem_ir, const SemIR::InstNamer* inst_namer,
auto LowerToLLVM(llvm::LLVMContext& llvm_context, bool include_debug_info,
llvm::StringRef module_name, const SemIR::File& sem_ir,
const SemIR::InstNamer* inst_namer,
llvm::raw_ostream* vlog_stream)
-> std::unique_ptr<llvm::Module>;

Expand Down
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/alias/local.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,11 @@ fn F() -> i32 {
// CHECK:STDOUT: %.loc14 = load i32, ptr %a.var, align 4
// CHECK:STDOUT: ret i32 %.loc14
// CHECK:STDOUT: }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "local.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/array/array_in_place.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@ fn G() {
// CHECK:STDOUT: call void @F(ptr %.loc14_42.5.array.index)
// CHECK:STDOUT: ret void
// CHECK:STDOUT: }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "array_in_place.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/array/assign_return_value.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,11 @@ fn Run() {
// CHECK:STDOUT: declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0
// CHECK:STDOUT:
// CHECK:STDOUT: attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "assign_return_value.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/array/base.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,11 @@ fn Run() {
// CHECK:STDOUT: uselistorder ptr @llvm.memcpy.p0.p0.i64, { 3, 2, 1, 0 }
// CHECK:STDOUT:
// CHECK:STDOUT: attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "base.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/array/function_param.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,11 @@ fn G() -> i32 {
// CHECK:STDOUT: declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0
// CHECK:STDOUT:
// CHECK:STDOUT: attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "function_param.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/basics/empty.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@

// CHECK:STDOUT: ; ModuleID = 'empty.carbon'
// CHECK:STDOUT: source_filename = "empty.carbon"
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "empty.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/basics/false_true.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@ fn T() -> bool {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: ret i1 true
// CHECK:STDOUT: }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "false_true.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/basics/int_types.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ fn F_u65536(a: u65536) -> u65536 { return a; }
// CHECK:STDOUT: entry:
// CHECK:STDOUT: ret i65536 %a
// CHECK:STDOUT: }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "int_types.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/basics/numeric_literals.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,11 @@ fn F() {
// CHECK:STDOUT: uselistorder ptr @llvm.memcpy.p0.p0.i64, { 1, 0 }
// CHECK:STDOUT:
// CHECK:STDOUT: attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "numeric_literals.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/basics/type_values.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,11 @@ fn F64() -> type {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: ret %type zeroinitializer
// CHECK:STDOUT: }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "type_values.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/basics/zero.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ fn Main() -> i32 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: ret i32 0
// CHECK:STDOUT: }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "zero.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/builtins/float.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,11 @@ fn TestGreaterEq(a: f64, b: f64) -> bool { return GreaterEq(a, b); }
// CHECK:STDOUT: %float.greater_eq = fcmp oge double %a, %b
// CHECK:STDOUT: ret i1 %float.greater_eq
// CHECK:STDOUT: }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "float.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/builtins/int.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,11 @@ fn TestGreaterEq(a: i32, b: i32) -> bool { return GreaterEq(a, b); }
// CHECK:STDOUT: %int.greater_eq = icmp sge i32 %a, %b
// CHECK:STDOUT: ret i1 %int.greater_eq
// CHECK:STDOUT: }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "int.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/builtins/method_vs_nonmethod.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@ fn TestAddMethod(a: i32, b: i32) -> i32 { return a.(AddMethod)(b); }
// CHECK:STDOUT: %int.sadd = add i32 %a, %b
// CHECK:STDOUT: ret i32 %int.sadd
// CHECK:STDOUT: }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "method_vs_nonmethod.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/builtins/overloaded_operator.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ fn AddThreeIntegers(a: i32, b: i32, c: i32) -> i32 {
// CHECK:STDOUT: %int.sadd.loc18_16 = add i32 %.loc18_12.4, %c
// CHECK:STDOUT: ret i32 %int.sadd.loc18_16
// CHECK:STDOUT: }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "overloaded_operator.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/builtins/print.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,11 @@ fn Main() {
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: declare i32 @printf(ptr, ...)
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "print.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/builtins/types.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ fn F() {
// CHECK:STDOUT: store i1 false, ptr %b.var, align 1
// CHECK:STDOUT: ret void
// CHECK:STDOUT: }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "types.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
8 changes: 8 additions & 0 deletions toolchain/lower/testdata/builtins/uint.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,11 @@ fn TestGreaterEq(a: u64, b: u64) -> bool { return GreaterEq(a, b); }
// CHECK:STDOUT: %int.greater_eq = icmp uge i64 %a, %b
// CHECK:STDOUT: ret i1 %int.greater_eq
// CHECK:STDOUT: }
// 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, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !1 = !DIFile(filename: "uint.carbon", directory: "")
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
Loading
Loading