[DWARF] Fix DW_OP_LLVM_user sub-operation name lookup. - #217480
Merged
Conversation
LlvmUserOperationEncodingString returns a name with a "DW_OP_LLVM_" prefix, but getLlvmUserOperationEncoding matched the suffix (subop) name. This patch updates the latter to match the full name. Assisted-by: LLM
|
@llvm/pr-subscribers-debuginfo @llvm/pr-subscribers-llvm-binary-utilities Author: Matt Davis (enferex) ChangesLlvmUserOperationEncodingString returns a name with a "DW_OP_LLVM_" prefix, but getLlvmUserOperationEncoding matched the suffix (subop) name. This patch updates the latter to match the full name. Assisted-by: LLM Full diff: https://github.com/llvm/llvm-project/pull/217480.diff 2 Files Affected:
diff --git a/llvm/lib/BinaryFormat/Dwarf.cpp b/llvm/lib/BinaryFormat/Dwarf.cpp
index 0027f1bbf0d9b..d130af6cc3adc 100644
--- a/llvm/lib/BinaryFormat/Dwarf.cpp
+++ b/llvm/lib/BinaryFormat/Dwarf.cpp
@@ -192,7 +192,8 @@ static StringRef LlvmUserOperationEncodingString(unsigned Encoding) {
static unsigned
getLlvmUserOperationEncoding(StringRef LlvmUserOperationEncodingString) {
unsigned E = StringSwitch<unsigned>(LlvmUserOperationEncodingString)
-#define HANDLE_DW_OP_LLVM_USEROP(ID, NAME) .Case(#NAME, DW_OP_LLVM_##NAME)
+#define HANDLE_DW_OP_LLVM_USEROP(ID, NAME) \
+ .Case("DW_OP_LLVM_" #NAME, DW_OP_LLVM_##NAME)
#include "llvm/BinaryFormat/Dwarf.def"
.Default(0);
assert(E && "unhandled DWARF operation string with LLVM user op");
diff --git a/llvm/unittests/BinaryFormat/DwarfTest.cpp b/llvm/unittests/BinaryFormat/DwarfTest.cpp
index c9522226c6031..1b3651555dda4 100644
--- a/llvm/unittests/BinaryFormat/DwarfTest.cpp
+++ b/llvm/unittests/BinaryFormat/DwarfTest.cpp
@@ -57,6 +57,13 @@ TEST(DwarfTest, getOperationEncoding) {
EXPECT_EQ(0u, getOperationEncoding("DW_OP_hi_user"));
}
+TEST(DwarfTest, SubOperationEncoding) {
+ EXPECT_EQ("DW_OP_LLVM_nop",
+ SubOperationEncodingString(DW_OP_LLVM_user, DW_OP_LLVM_nop));
+ EXPECT_EQ(DW_OP_LLVM_nop,
+ getSubOperationEncoding(DW_OP_LLVM_user, "DW_OP_LLVM_nop"));
+}
+
TEST(DwarfTest, LanguageStringOnInvalid) {
// This is invalid, so it shouldn't be stringified.
EXPECT_EQ(StringRef(), LanguageString(0));
|
echristo
self-requested a review
August 19, 2026 22:32
echristo
reviewed
Aug 19, 2026
ayermolo
self-requested a review
August 20, 2026 18:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LlvmUserOperationEncodingString returns a name with a "DW_OP_LLVM_" prefix, but getLlvmUserOperationEncoding matched the suffix (subop) name. This patch updates the latter to match the full name.
Assisted-by: LLM