Skip to content

Commit

Permalink
Fix the metadata deduplication
Browse files Browse the repository at this point in the history
The llvmlite debug metadata cache does not work as expected due to
the encoding value using address of DIToken instance and serves as
part of the key.

Solutions could be either singleton the DIToken class, or extract
the string value from the encoding object.

Since the DIToken class is designed to be a wrapper of enumeration
value, e.g. the DW_* enumerations, that should appear bare in the
emitted metadata, in this change, singleton DIToken is made to fix
the problem.

This solves llvmlit issue #1164
#1164
  • Loading branch information
jiel-nv committed Mar 3, 2025
1 parent 75ebdf6 commit 39bfde4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions llvmlite/ir/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,13 @@ class DIToken:
Use this to wrap known constants, e.g. the DW_* enumerations.
"""
_instance = None

def __new__(cls, value):
if not cls._instance or cls._instance.value != value:
cls._instance = super().__new__(cls)
cls._instance.value = value
return cls._instance

def __init__(self, value):
self.value = value
Expand Down

0 comments on commit 39bfde4

Please sign in to comment.