Skip to content

Commit

Permalink
Merge pull request swiftlang#39048 from meg-gupta/viewcfgfix
Browse files Browse the repository at this point in the history
Add a flag to only view the shape of the cfg and disable instruction printing in viewcfg
  • Loading branch information
meg-gupta authored Aug 26, 2021
2 parents a35ae7a + 37e9c7b commit 5357a1d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions utils/viewcfg
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def parse_args():
Simple regex based transform of SIL and LLVM-IR into graphviz form.
""")
parser.add_argument("output_suffix", nargs='?')
parser.add_argument("--disable_inst_dump", action='store_true')
parser.add_argument("--input_file", type=argparse.FileType('r'),
default=sys.stdin)
parser.add_argument("--renderer", choices=["Graphviz", "dot"],
Expand Down Expand Up @@ -159,15 +160,15 @@ def main():
node [fontname = "{font}"];
edge [fontname = "{font}"];""".format(font=fontname))
for block in block_list:
if block.content is not None:
if block.content is None or args.disable_inst_dump:
out_file.write(
"\tNode" + str(block.index) +
" [shape=record,label=\"{" + block.content + "}\"];\n")
" [shape=record,color=gray,fontcolor=gray,label=\"{" +
block.name + "}\"];\n")
else:
out_file.write(
"\tNode" + str(block.index) +
" [shape=record,color=gray,fontcolor=gray,label=\"{" +
block.name + "}\"];\n")
" [shape=record,label=\"{" + block.content + "}\"];\n")

for succ_name in block.get_succs():
succ_block = block_map[succ_name]
Expand Down

0 comments on commit 5357a1d

Please sign in to comment.