[llvm] [DWARF] Support Roc Language (PR #225631)
Will Hawkins via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 07:02:31 PDT 2026
https://github.com/hawkinsw updated https://github.com/llvm/llvm-project/pull/225631
>From 8a47d6d1bcb704e1df732aaca6b36b11561eae92 Mon Sep 17 00:00:00 2001
From: Will Hawkins <hawkinsw at obs.cr>
Date: Wed, 23 Sep 2026 03:55:46 -0400
Subject: [PATCH] [DWARF] Support Roc Language
The Roc language has been assigned language codes for DWARF v5 and v6.
See [DWARF Issue 260821.1](https://dwarfstd.org/issues/260828.1.html).
---
llvm/include/llvm-c/DebugInfo.h | 1 +
llvm/include/llvm/BinaryFormat/Dwarf.def | 2 ++
llvm/include/llvm/BinaryFormat/Dwarf.h | 7 +++++
.../compileunit-source-language-name-roc.ll | 29 +++++++++++++++++++
4 files changed, 39 insertions(+)
create mode 100644 llvm/test/DebugInfo/Generic/compileunit-source-language-name-roc.ll
diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index 2f7afa3f16aba1..dd7e43445ae3a1 100644
--- a/llvm/include/llvm-c/DebugInfo.h
+++ b/llvm/include/llvm-c/DebugInfo.h
@@ -151,6 +151,7 @@ typedef enum {
LLVMDWARFSourceLanguageErlang,
LLVMDWARFSourceLanguageElixir,
LLVMDWARFSourceLanguageGleam,
+ LLVMDWARFSourceLanguageRoc,
// Vendor extensions:
LLVMDWARFSourceLanguageMips_Assembler,
diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.def b/llvm/include/llvm/BinaryFormat/Dwarf.def
index 4c8ced7f7a87d1..f83f86c9bf9e43 100644
--- a/llvm/include/llvm/BinaryFormat/Dwarf.def
+++ b/llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -1068,6 +1068,7 @@ HANDLE_DW_LANG(0x0045, Nim, 0, 0, DWARF)
HANDLE_DW_LANG(0x0046, Erlang, 1, 0, DWARF)
HANDLE_DW_LANG(0x0047, Elixir, 1, 0, DWARF)
HANDLE_DW_LANG(0x0048, Gleam, 0, 0, DWARF)
+HANDLE_DW_LANG(0x0049, Roc, 0, 0, DWARF)
// Vendor extensions:
HANDLE_DW_LANG(0x8001, Mips_Assembler, std::nullopt, 0, MIPS)
@@ -1140,6 +1141,7 @@ HANDLE_DW_LNAME(0x002f, Nim, "Nim", 0) // VVMMPP
HANDLE_DW_LNAME(0x0030, Erlang, "Erlang", 1) // VVMMPP
HANDLE_DW_LNAME(0x0031, Elixir, "Elixir", 1) // VVMMPP
HANDLE_DW_LNAME(0x0032, Gleam, "Gleam", 0) // VVMMPP
+HANDLE_DW_LNAME(0x0033, Roc, "Roc", 0) // VVMMPP
// DWARF attribute type encodings.
HANDLE_DW_ATE(0x01, address, 2, DWARF)
diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.h b/llvm/include/llvm/BinaryFormat/Dwarf.h
index fe2c73b28ad207..503efdfc0a999c 100644
--- a/llvm/include/llvm/BinaryFormat/Dwarf.h
+++ b/llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -391,6 +391,8 @@ inline std::optional<SourceLanguage> toDW_LANG(SourceLanguageName name,
return DW_LANG_Elixir;
case DW_LNAME_Gleam:
return DW_LANG_Gleam;
+ case DW_LNAME_Roc:
+ return DW_LANG_Roc;
}
return {};
}
@@ -541,6 +543,8 @@ toDW_LNAME(SourceLanguage language) {
return {{DW_LNAME_Elixir, 0}};
case DW_LANG_Gleam:
return {{DW_LNAME_Gleam, 0}};
+ case DW_LANG_Roc:
+ return {{DW_LNAME_Roc, 0}};
case DW_LANG_BORLAND_Delphi:
case DW_LANG_CPP_for_OpenCL:
case DW_LANG_lo_user:
@@ -643,6 +647,7 @@ inline bool isCPlusPlus(SourceLanguage S) {
case DW_LANG_Erlang:
case DW_LANG_Elixir:
case DW_LANG_Gleam:
+ case DW_LANG_Roc:
result = false;
break;
}
@@ -734,6 +739,7 @@ inline bool isFortran(SourceLanguage S) {
case DW_LANG_Erlang:
case DW_LANG_Elixir:
case DW_LANG_Gleam:
+ case DW_LANG_Roc:
result = false;
break;
}
@@ -823,6 +829,7 @@ inline bool isC(SourceLanguage S) {
case DW_LANG_Erlang:
case DW_LANG_Elixir:
case DW_LANG_Gleam:
+ case DW_LANG_Roc:
return false;
}
diff --git a/llvm/test/DebugInfo/Generic/compileunit-source-language-name-roc.ll b/llvm/test/DebugInfo/Generic/compileunit-source-language-name-roc.ll
new file mode 100644
index 00000000000000..984301c71ec435
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/compileunit-source-language-name-roc.ll
@@ -0,0 +1,29 @@
+; AIX doesn't have support for DWARF 6 DW_AT_language_name
+; XFAIL: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
+; RUN: %llc_dwarf --dwarf-version=6 -filetype=obj -O0 < %s | llvm-dwarfdump -debug-info -v - | FileCheck %s --implicit-check-not "DW_AT_language"
+
+; CHECK: DW_AT_language_name [DW_FORM_data2] (DW_LNAME_Roc)
+; CHECK-NOT: DW_AT_language_version
+
+ at x = global i32 0, align 4, !dbg !0
+
+; Function Attrs: mustprogress noinline nounwind optnone ssp uwtable(sync)
+define void @_Z4funcv() !dbg !8 {
+ ret void, !dbg !11
+}
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!6, !7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 1, type: !5, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(sourceLanguageName: DW_LNAME_Roc, sourceLanguageVersion: 0, file: !3, producer: "handwritten", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: Apple, sysroot: "/")
+!3 = !DIFile(filename: "cu.roc", directory: "/tmp")
+!4 = !{!0}
+!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!6 = !{i32 7, !"Dwarf Version", i32 6}
+!7 = !{i32 2, !"Debug Info Version", i32 3}
+!8 = distinct !DISubprogram(name: "func", linkageName: "_Z4funcv", scope: !3, file: !3, line: 2, type: !9, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2)
+!9 = !DISubroutineType(types: !10)
+!10 = !{null}
+!11 = !DILocation(line: 2, column: 14, scope: !8)
More information about the llvm-commits
mailing list