Skip to content
프로젝트

lijiansong/clang-llvm-tutorial

GitHub에서 보기

소개

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

프로그래밍 언어 및 런타임

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

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

관련 프로젝트 살펴보기

불러오는 중…