Skip to content

Commit a85c314

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. Solution is to 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, stringify DIToken is made to fix the problem. This solved llvmlite issue #1164
1 parent 39bfde4 commit a85c314

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

llvmlite/ir/module.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ def _fix_di_operands(self, operands):
4242
fixed_ops.append((name, op))
4343
return fixed_ops
4444

45+
def str_ditok_operands(self, operands):
46+
str_ops = []
47+
for name, op in operands:
48+
if name == 'encoding' and isinstance(op, values.DIToken):
49+
# use string value instead of address of object
50+
op = op.value
51+
str_ops.append((name, op))
52+
return str_ops
53+
4554
def add_metadata(self, operands):
4655
"""
4756
Add an unnamed metadata to the module with the given *operands*

llvmlite/ir/values.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -705,13 +705,6 @@ 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
715708

716709
def __init__(self, value):
717710
self.value = value

0 commit comments

Comments
 (0)