[llvm] Compute GUIDs once and store in metadata (PR #184065)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 7 17:19:22 PST 2026
================
@@ -576,7 +577,22 @@ 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 {};
+ }
+
+ return It->getSecond();
+ }
+
+ void insertGUID(const Value* V, GlobalValue::GUID GUID) {
+ ValueToGUIDMap[V] = GUID;
----------------
mtrofin wrote:
do we want to
```
auto [_, inserted] = ValueToGUIDMap.insert({V, GUID})
(void)inserted;
assert(inserted && "expected to only insert once")
```
(or if there's a reason for repeated calls, we can assert the present value has same GUID)
https://github.com/llvm/llvm-project/pull/184065
More information about the llvm-commits
mailing list