diff --git a/llvm/utils/opt-viewer/opt-viewer.py b/llvm/utils/opt-viewer/opt-viewer.py index 7fd93600f005..d29b74f0023f 100755 --- a/llvm/utils/opt-viewer/opt-viewer.py +++ b/llvm/utils/opt-viewer/opt-viewer.py @@ -24,6 +24,8 @@ def demangle(name): return p.stdout.readline().rstrip() class Remark(yaml.YAMLObject): + max_hotness = 0 + @property def File(self): return self.DebugLoc['File'] @@ -60,6 +62,10 @@ class Remark(yaml.YAMLObject): values = [self.getArgString(mapping.items()[0]) for mapping in self.Args] return demangle("".join(values)) + @property + def RelativeHotness(self): + return int(round(self.Hotness * 100 / Remark.max_hotness)) + class Analysis(Remark): yaml_tag = '!Analysis' @@ -102,7 +108,7 @@ class SourceFileRenderer: print('''