Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phi instructions should invalidate their string cache when new incomings are added #661

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions llvmlite/ir/instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def replace_callee(self, newfunc):
if newfunc.function_type != self.callee.function_type:
raise TypeError("New function has incompatible type")
self.callee = newfunc
self._clear_string_cache()

@property
def called_function(self):
Expand Down Expand Up @@ -182,6 +183,7 @@ def set_weights(self, weights):
operands.append(Constant(types.IntType(32), w))
md = self.module.add_metadata(operands)
self.set_metadata("prof", md)
self._clear_string_cache()


class Ret(Terminator):
Expand Down Expand Up @@ -228,6 +230,7 @@ def address(self):
def add_destination(self, block):
assert isinstance(block, Block)
self.destinations.append(block)
self._clear_string_cache()

def descr(self, buf):
destinations = ["label {0}".format(blk.get_reference())
Expand Down Expand Up @@ -256,6 +259,7 @@ def add_case(self, val, block):
if not isinstance(val, Value):
val = Constant(self.value.type, val)
self.cases.append((val, block))
self._clear_string_cache()

def descr(self, buf):
cases = ["{0} {1}, label {2}".format(val.type, val.get_reference(),
Expand Down Expand Up @@ -544,10 +548,12 @@ def descr(self, buf):
def add_incoming(self, value, block):
assert isinstance(block, Block)
self.incomings.append((value, block))
self._clear_string_cache()

def replace_usage(self, old, new):
self.incomings = [((new if val is old else val), blk)
for (val, blk) in self.incomings]
self._clear_string_cache()


class ExtractElement(Instruction):
Expand Down Expand Up @@ -793,6 +799,7 @@ def __init__(self, parent, typ, name='', cleanup=False):
def add_clause(self, clause):
assert isinstance(clause, _LandingPadClause)
self.clauses.append(clause)
self._clear_string_cache()

def descr(self, buf):
fmt = "landingpad {type}{cleanup}{clauses}\n"
Expand Down