Skip to content

Commit 39bfde4

Browse files
committed
Fix the metadata deduplication
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
1 parent 75ebdf6 commit 39bfde4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

llvmlite/ir/values.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,13 @@ class DIToken:
705705
706706
Use this to wrap known constants, e.g. the DW_* enumerations.
707707
"""
708+
_instance = None
709+
710+
def __new__(cls, value):
711+
if not cls._instance or cls._instance.value != value:
712+
cls._instance = super().__new__(cls)
713+
cls._instance.value = value
714+
return cls._instance
708715

709716
def __init__(self, value):
710717
self.value = value

0 commit comments

Comments
 (0)