Coder Social home page Coder Social logo

guohaoyu110 / clang-llvm-tutorial Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lijiansong/clang-llvm-tutorial

0.0 2.0 0.0 24.23 MB

clang & llvm examples, e.g. AST Interpreter, Function Pointer Analysis, Value Range Analysis, Data-Flow Analysis, Andersen Pointer Analysis, LLVM Backend...

License: Do What The F*ck You Want To Public License

C++ 73.79% Makefile 1.35% C 6.35% LLVM 17.55% Shell 0.96%

clang-llvm-tutorial's Introduction

Clang and LLVM Tutorial

License: WTFPL

This archieve is mainly about some interesting examples of clang and llvm... Some of them are the homework of my postgraduate course, some of them are others, most of them are toy code : )

Contents

AST Interpreter

An interpreter of clang abstract syntax tree, toy code, now it only support integer type. It supports basic modules of programming language, e.g. ifstmt, whilestmt, function call, malloc and array... For more info, see here...

Function Pointer Pass

Implement of use-def chains based on the LLVM IR and bitcode, now it supports direct function calls and function pointer. For the case of function pointer, calculate the functions that may call, if it is determined, replace it with direct function call and write into the bitcode file. Also take the situation that the function pointers are stored in memory into consideration.

Value Range Analysis

Value range analysis is a type of data flow analysis that tracks the range (interval) of values that a numeric variable can take on at each point of a program's execution.
The resulting information can be used in optimizations such as redundancy elimination, dead code elimination, instruction selection, etc. But can also be used to improve the safety of programs, e.g. in the detection of buffer overruns. Techniques for value range analysis typically use symbolic analysis extensively. When it comes to the detailed implement, for each basic block, define the following data-flow equation:

in[B] = ∪ out[A] | A∈ pred(B) && A!=S
out[B] = in[B]∪gen[B]

Data Flow Analysis

Homework of foreign CS course --- Advanced Compilers, for more detail, see here...

Andersen Pointer Analysis

Implement of Andersen's pointer analysis algorithm, for more info, see here...

LLVM Backend

For a compiling system, I think the most complex part is the back end, you have to be proficient in instruction sets of the target processor and familiar with its architecture. Lots of things have to be done, e.g. instruction selection, instruction scheduling, register allocation, code emission and etc. Here i will provide you will an example, for more details, see here

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.