Skip to content

Conversation

arrowten
Copy link

No description provided.

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Jul 28, 2025

@llvm/pr-subscribers-debuginfo

@llvm/pr-subscribers-llvm-ir

Author: None (arrowten)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/150928.diff

2 Files Affected:

  • (modified) llvm/include/llvm/IR/Metadata.h (+1-1)
  • (modified) llvm/unittests/IR/MetadataTest.cpp (+25)
diff --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h
index af252aa24567a..9cd8533069c21 100644
--- a/llvm/include/llvm/IR/Metadata.h
+++ b/llvm/include/llvm/IR/Metadata.h
@@ -237,7 +237,7 @@ class DebugValueUser {
   /// `resetDebugValue(Idx, NewDebugValue)` should be used instead.
   LLVM_ABI void handleChangedValue(void *Old, Metadata *NewDebugValue);
   DebugValueUser() = default;
-  explicit DebugValueUser(std::array<Metadata *, 3> DebugValues)
+  explicit DebugValueUser(const std::array<Metadata *, 3> &DebugValues)
       : DebugValues(DebugValues) {
     trackDebugValues();
   }
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp
index ba8367f4a396e..0e8e0831ac9d6 100644
--- a/llvm/unittests/IR/MetadataTest.cpp
+++ b/llvm/unittests/IR/MetadataTest.cpp
@@ -5497,4 +5497,29 @@ TEST_F(MDTupleAllocationDeathTest, ResizeRejected) {
 }
 #endif
 
+typedef MetadataTest DebugValueUserTest;
+
+namespace {
+struct DebugValueUserTestHelper: public llvm::DebugValueUser {
+  using llvm::DebugValueUser::DebugValueUser;
+  using llvm::DebugValueUser::getDebugValues;
+};
+}
+
+TEST_F(DebugValueUserTest, GetDebugValues) {
+  auto *V = getConstantAsMetadata();
+  auto *V2 = getConstantAsMetadata();
+  auto *V3 = getConstantAsMetadata();
+  std::array<Metadata *, 3> Debugs = {V, V2, V3};
+  DebugValueUserTestHelper User(Debugs);
+  ArrayRef<Metadata *> Result = User.getDebugValues();
+
+  // Verify the size of the returned array is correct,
+  // and each element is correctly stored and returned.
+  EXPECT_EQ(Result.size(), 3u);
+  EXPECT_EQ(Result[0], V);
+  EXPECT_EQ(Result[1], V2);
+  EXPECT_EQ(Result[2], V3);
+}
+
 } // end namespace

@zwuis zwuis requested a review from dcb314 September 3, 2025 00:50
@dcb314
Copy link

dcb314 commented Sep 3, 2025 via email

@arrowten
Copy link
Author

arrowten commented Sep 3, 2025

@dcb314 Well thank you for that, but who accepts the PR?

@nikic nikic added the debuginfo label Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants