aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_stmt.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-12-27 12:48:25 +0000
committergingerBill <gingerBill@users.noreply.github.com>2025-12-27 12:48:25 +0000
commit14a60adefe005d09066f420b1a24f11e365d9cec (patch)
tree6918d21dba776e97441acc61f28e17cfee3de806 /src/llvm_backend_stmt.cpp
parent4e40b808c4ab5f29fe6c50c9dccbf4acd99c8c45 (diff)
LLVM IR: Improve type switch case names for better debuggability when generating LLVM IR
Diffstat (limited to 'src/llvm_backend_stmt.cpp')
-rw-r--r--src/llvm_backend_stmt.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/llvm_backend_stmt.cpp b/src/llvm_backend_stmt.cpp
index 3dbcea4fb..a8cc459c3 100644
--- a/src/llvm_backend_stmt.cpp
+++ b/src/llvm_backend_stmt.cpp
@@ -1962,7 +1962,7 @@ gb_internal void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss
num_cases += cc->list.count;
if (cc->list.count == 0) {
GB_ASSERT(default_block == nullptr);
- default_block = lb_create_block(p, "typeswitch.default.body");
+ default_block = lb_create_block(p, "typeswitch.case.default");
else_block = default_block;
}
}
@@ -2042,7 +2042,16 @@ gb_internal void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss
continue;
}
- lbBlock *body = lb_create_block(p, "typeswitch.body");
+ char const *body_name = "typeswitch.case";
+
+ if (!are_types_identical(case_entity->type, parent_base_type)) {
+ gbString canonical_name = temp_canonical_string(case_entity->type);
+ gbString bn = gb_string_make(heap_allocator(), "typeswitch.case.");
+ bn = gb_string_append_length(bn, canonical_name, gb_string_length(canonical_name));
+ body_name = cast(char const *)bn;
+ }
+
+ lbBlock *body = lb_create_block(p, body_name);
if (p->debug_info != nullptr) {
LLVMSetCurrentDebugLocation2(p->builder, lb_debug_location_from_ast(p, clause));
}