Skip to content

Add llvm-extract support for the LLVM graph creation API #173

@ChrisCummins

Description

@ChrisCummins

🚀 Feature

This feature request is to make it easy to construct ProGraML from subsets of LLVM-IRs by integrating with llvm-extract.

Motivation

For some use cases, we may want to construct a partial graph of a program. E.g. to construct the graph for a single function. This is easy to do using llvm-extract, but is not part of the ProGraML API. Lets say we have a program with two functions 'A' and 'B'. First compile the program down to LLVM-IR:

$ echo 'int A() { return 5; } int B() { return 10; }' | clang -xc - -emit-llvm -c -S -o ir.ll

Then use llvm-extract tool to pull out only the function you want. We can then use the normal ProGraML llvm2graph tool to generate the graph of just this function (and its transitive deps):

$ llvm-extract --func=A ir.ll -S | llvm2graph

Pitch

Add a set of arguments to the LLVM creation ops that automatically invoke llvm-extract to pull out the required program fragment. E.g.

G = programl.from_llvm_ir(my_program, function="A")

Metadata

Metadata

Assignees

No one assigned

    Labels

    DatasetsGraph and text datasetsEnhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions