Coder Social home page Coder Social logo

llvm-pass-skeleton's Introduction

LLVM_Pass_Skeleton

TODO : new PM 소스 추가

llvm-toolkits 명령어

.c 소스파일 to .ll llvm IR코드 -O0 -O1 -O2 Optimization 필요단계에 따라 적용해야함.

clang -S -emit-llvm -O0 <sample.c> -o <sample.ll>

.ll llvm IR코드 to .bc llvm 비트코드

llvm-as <sample.ll> -o <sample.bc>

.bc llvm 비트코드 to .ll llvm IR코드

llvm-dis <sample.bc> -o <sample.ll>

.ll IR코드 to <.Func.dot> to CFG pdf 파일

sudo apt-get install graphviz

opt -dot-cfg -enable-new-pm=0 <sample.ll>
===> ./.func1.dot ./.func2.dot ./.func3.dot 생성 

dot -Tpdf <./.func1.dot> -o <func.pdf>

LLVM-13 설치 및 PATH 설정

Ubuntu 20.04.4 LTS apt 패키지를 이용한 설치.

apt-get update && apt-get install -y \
    git \
    cmake \
    ninja-build \
    build-essential \
    wget \
    software-properties-common
    
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -

apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main" 

apt-get update

apt-get install -y llvm-13 llvm-13-dev libllvm13 clang-13 llvm-13-tools libmlir-13 libmlir-13-dev

github llvm-projcet를 직접 컴파일하기

apt-get update && apt-get install -y \
    git \
    cmake \
    ninja-build \
    build-essential \

git clone --branch release/13.x --depth 1 https://github.com/llvm/llvm-project

mkdir <install dir>

mkdir llvm-project/build

cd llvm-project/build

cmake -G Ninja \
        -DLLVM_ENABLE_PROJECTS=clang \
        -DLLVM_TARGETS_TO_BUILD=X86 \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=<install dir> \
        -DLLVM_INSTALL_UTILS=ON \
        ../llvm

cmake --build . --target install

(option) rm -r /llvm-project

apt-repository 참고 : https://apt.llvm.org/

설치 dir : 본인 지정.

PATH 환경변수에 "/bin" 추가

How to build

mkdir ./src/<legacyPM or newPM>/build

cd ./src/<legacyPM or newPM>//build

cmake ..

make

How to use

use legacy Pass-Manager

opt -load ./libSamplePass.so --samplepass -enable-new-pm=0 -disable-output ../../sample/sample.ll

use new Pass-Manager

opt -load-pass-plugin ./libSamplePass.so -passes=sample-pass -disable-output ../../sample/sample.ll

llvm-pass-skeleton's People

Contributors

kordood avatar o-sehwan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.