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

Remove fn body pass #30

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

khoing0810
Copy link

  • LLVM transformation pass that remove a function body in IR module given an index.
  • Build instruction: run module load ninja to load ninja build package. Go into RemoveFunctionBodyPass directory (cd llvm-ir-dataset-utils-internal/llvm_ir_dataset_utils/tools/RemoveFunctionBodyPass), run ./install to build and install the out-of-tree pass.
  • Usage: opt -load build/libRemoveFunctionBody.so -load-pass-plugin=build/libRemoveFunctionBody.so -passes='remove-fn-body' -index <index in integer here> <path to bitcode module file> (inside RemoveFunctionBodyPass directory. If want to try somewhere else, modify the path after -load and -load-pass-plugin)

Copy link

vercel bot commented May 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
llvm-ir-dataset-utils ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 25, 2024 8:12am

Copy link
Contributor

@boomanaiden154 boomanaiden154 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial comments.

add_library(RemoveFunctionBody SHARED RemoveFunctionBody.cpp)
target_link_libraries(RemoveFunctionBody "$<$<PLATFORM_ID:Darwin>:-undefined dynamic_lookup>")

# separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commented sections can probably go away?


project(RemoveFunctionBodyPass)

set(LT_LLVM_INSTALL_DIR "" CACHE PATH "LLVM installation directory")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to set this path? Doesn't opt support explicitly passing the shard object path?

#include "llvm/Passes/PassPlugin.h"
#include "llvm/Support/CommandLine.h"
using namespace llvm;
using namespace std;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please to not use using namespace std.


namespace {
cl::list<int> Lists("index", cl::desc("Specify function index"), cl::OneOrMore);
struct RemoveFunctionBodyPass : PassInfoMixin<RemoveFunctionBodyPass> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a struct and not a class?

@@ -0,0 +1,3 @@
mkdir build && cd build
cmake -GNinja ..
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script doesn't seem to be particularly useful and I don't think it needs to be in-tree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants