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

Should share code for viewing dot graphs #1173

Closed
lattner opened this issue Jun 5, 2006 · 17 comments
Closed

Should share code for viewing dot graphs #1173

lattner opened this issue Jun 5, 2006 · 17 comments
Labels
bugzilla Issues migrated from bugzilla code-cleanup

Comments

@lattner
Copy link
Collaborator

lattner commented Jun 5, 2006

Bugzilla Link 801
Resolution FIXED
Resolved on Feb 22, 2010 12:51
Version trunk
OS All
CC @asl

Extended Description

There are now several copies of the code for viewing a dot graph with dot&gv/dotty/Graphviz. This
should all be shared in one place in libsupport.

-Chris

@lattner
Copy link
Collaborator Author

lattner commented Jun 5, 2006

Specifically, see all the files that implementing #1170 had to change :(

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 5, 2006

We need to check to make sure all the usages are the same and if not make sure
the shared code can handle the variant usages via arguments to the function.

@asl
Copy link
Collaborator

asl commented Jun 5, 2006

All files actually use WriteGraph() call to output graph to stream. I'll
refactor code.

@asl
Copy link
Collaborator

asl commented Jun 5, 2006

Code cleanup
Moved graph printing to Support/GraphWriter.h, fixed the correspondent calls.

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 5, 2006

Anton,

The patch looks fine, except: I don't like having ViewGraph implementation in a
header file. This is going to get replicated in all those other files which
doesn't buy us anything for code size. I understand the need to put it in a .h
because of the template. But, the template doesn't use GraphType& G except in
the call to WriteGraph.

So, could you please refactor this so that the common parts are put in separate
functions in a .cpp file. Here's what I'd like to see:

  1. Make an overload of WriteGraph that takes the same arguments as the ViewGraph
    function (GraphType, Name, Title). This would create its own temporary file
    and return that file name as its result (sys::Path). This is the first part
    of your patch (up to the #ifdef).

  2. Create a new function, DisplayGraph, which takes a sys::Path that is presumed
    to be the postscript file to view. This function incorporates the second
    part of your patch (everything after #ifdef).

  3. Reduce the ViewGraph template to just:

template
void ViewGraph(const GraphType& G,
const std::string& Name,
const std::string& Title = "") {
sys::Path path = WriteGraph(G,Name,Title)
if (path.empty())
return;
DisplayGraph(path)
}

Reid.

@lattner
Copy link
Collaborator Author

lattner commented Jun 5, 2006

Another cleanup that might be required before this can be done: we should make the GraphWriter
interface not be a big template with traits to allow customization. Instead we should use inheritance, and
subclassing to customize writing. This would allow the huge template to come out of the header, and
would reduce code size.

-Chris

@asl
Copy link
Collaborator

asl commented Jun 10, 2006

Refactored code
Reid, this patch implements the functionality you've mentioned.

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 16, 2006

Mine.

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 17, 2006

The patch did not apply correctly. In particular,
lib/Analysis/DataStructure/Pringer.cpp failed. It looks like this code has
changed since the patch.

Could you update to CVS head, fix any merge/conflict problems and then provide a
new patch. I'll try to apply it as soon as possible to avoid this problem.

Thanks,

Reid.

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 23, 2006

Anton,

Any updates on this bug?

Reid.

@asl
Copy link
Collaborator

asl commented Jun 23, 2006

Reid!

As you know already, I'm in the process of migration to new system. I'm
managing to start working on this issue on monday.

@asl
Copy link
Collaborator

asl commented Jun 27, 2006

Patch over latest CVS snapshot
Reid,

this is the updated patch. Hope it will apply fine.

@asl
Copy link
Collaborator

asl commented Jun 27, 2006

cvs diff -u output
Due to unknown reason new file lib/Support/GraphWriter.cpp wasn't included to
cvs diff output ("-N" switch was used). I'll upload it separately.

@asl
Copy link
Collaborator

asl commented Jun 27, 2006

cvs diff -u output

@asl
Copy link
Collaborator

asl commented Jun 27, 2006

missed GraphWriter.cpp

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 27, 2006

The new patches applied correctly. I'm building and checking to make sure it
breaks nothing. If that works, I'll commit the patches.

Thanks, Anton.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla code-cleanup
Projects
None yet
Development

No branches or pull requests

3 participants