Skip to content

Commit 91585d7

Browse files
mmereckiZuul
authored andcommitted
Fix the order of function attributes in auto-generated file IntrinsicGenISA.gen. Python code generator was nondeterministic, potentially generating different code for the same input.
Change-Id: I7043ef38784c167c2713f175fe25e9c12365a976
1 parent d2ab545 commit 91585d7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

IGC/GenISAIntrinsics/Intrinsics.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,18 @@
9090
"InaccessibleMemOnly": set(["NoUnwind","InaccessibleMemOnly"]),
9191
}
9292

93+
# order taken from IntrinsicEmitter::EmitAttributes to match attribute order used for llvm intrinsics
94+
attribute_order = ("NoUnwind", "NoReturn", "NoDuplicate", "Convergent", "ReadNone", "ReadOnly", "ArgMemOnly", "InaccessibleMemOnly")
95+
9396
def getAttributeList(Attrs):
9497
"""
9598
Takes a list of attribute names, calculates the union,
9699
and returns a list of the the given attributes
97100
"""
98101
s = reduce(lambda acc, v: attribute_map[v] | acc, Attrs, set())
99-
return ['Attribute::'+x for x in s]
102+
# sort attributes to generate the same code each time
103+
l = sorted(list(s), key=attribute_order.index)
104+
return ['Attribute::'+x for x in l]
100105

101106
Intrinsics = dict()
102107
parse = sys.argv

0 commit comments

Comments
 (0)