[clang] [lld] [llvm] Compute GUIDs once and store in metadata (PR #184065)
Owen Rodley via llvm-commits
llvm-commits at lists.llvm.org
Sun May 10 21:27:28 PDT 2026
================
@@ -576,10 +577,31 @@ class LLVM_ABI Module {
// Use global_size() to get the total number of global variables.
// Use globals() to get the range of all global variables.
+ std::optional<GlobalValue::GUID> getGUID(const Value *V) const {
+ const auto It = ValueToGUIDMap.find(V);
+ if (It == ValueToGUIDMap.end())
+ return std::nullopt;
+
+ return It->getSecond();
+ }
+
+ void insertGUID(const Value *V, GlobalValue::GUID GUID) {
+ const auto [It, WasInserted] = ValueToGUIDMap.insert({V, GUID});
+
+ (void)It, (void)WasInserted;
+#ifndef NDEBUG
+ if (!WasInserted) {
+ assert((It->second == GUID) && "insertGUID called with different value");
+ }
+#endif
+ }
+
private:
-/// @}
-/// @name Direct access to the globals list, functions list, and symbol table
-/// @{
+ DenseMap<const Value *, GlobalValue::GUID> ValueToGUIDMap;
----------------
orodley wrote:
Added a comment.
https://github.com/llvm/llvm-project/pull/184065
More information about the llvm-commits
mailing list