llvm

1 LLVM Design & Overview 3
1.1 LLVM Language Reference Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 User Guides 245
2.1 Building LLVM with CMake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
2.2 CMake Primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
2.3 Advanced Build Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
2.4 How To Build On ARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
2.5 How to Cross Compile Compiler-rt Builtins For Arm . . . . . . . . . . . . . . . . . . . . . . . . . . 266
2.6 How To Cross-Compile Clang/LLVM using Clang/LLVM . . . . . . . . . . . . . . . . . . . . . . . 269
2.7 LLVM Command Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
2.8 Getting Started with the LLVM System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
2.9 Getting Started with the LLVM System using Microsoft Visual Studio . . . . . . . . . . . . . . . . . 358
2.10 Frequently Asked Questions (FAQ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
2.11 The LLVM Lexicon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
2.12 How To Add Your Build Configuration To LLVM Buildbot Infrastructure . . . . . . . . . . . . . . . 371
2.13 yaml2obj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
2.14 How to submit an LLVM bug report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
2.15 Sphinx Quickstart Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
2.16 Code Reviews with Phabricator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
2.17 LLVM Testing Infrastructure Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
2.18 LLVM Tutorial: Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
2.19 LLVM 7.0.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 768
2.20 LLVM’s Analysis and Transform Passes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 770
2.21 YAML I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 790
2.22 The Often Misunderstood GEP Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805
2.23 Performance Tips for Frontend Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 813
2.24 MCJIT Design and Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818
2.25 LLVM Community Code of Conduct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 823
2.26 Compiling CUDA with clang . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 825
2.27 Reporting Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 833
2.28 Benchmarking tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 835
2.29 A guide to Dockerfiles for building LLVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 836
3 Programming Documentation 841
3.1 LLVM Atomic Instructions and Concurrency Guide . . . . . . . . . . . . . . . . . . . . . . . . . . 841
3.2 LLVM Coding Standards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 849
3.3 CommandLine 2.0 Library Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874
3.4 Architecture & Platform Information for Compiler Writers . . . . . . . . . . . . . . . . . . . . . . . 897
3.5 Extending LLVM: Adding instructions, intrinsics, types, etc. . . . . . . . . . . . . . . . . . . . . . . 901
3.6 How to set up LLVM-style RTTI for your class hierarchy . . . . . . . . . . . . . . . . . . . . . . . . 905
3.7 LLVM Programmer’s Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 911
3.8 LLVM Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 968
3.9 libFuzzer – a library for coverage-guided fuzz testing. . . . . . . . . . . . . . . . . . . . . . . . . . 974
3.10 Fuzzing LLVM libraries and tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 986
3.11 Scudo Hardened Allocator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 990
3.12 Using -opt-bisect-limit to debug optimization errors . . . . . . . . . . . . . . . . . . . . . . . . . . 993
4 Subsystem Documentation 997
4.1 LLVM Alias Analysis Infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 997//指针分析,已有的pass,接口用以写新的analysis pass
4.2 MemorySSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1008
4.3 LLVM Bitcode File Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1014
4.4 LLVM Block Frequency Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1035
4.5 LLVM Branch Weight Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1037
4.6 LLVM bugpoint tool: design and usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1040
4.7 The LLVM Target-Independent Code Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1043
4.8 Exception Handling in LLVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1077
4.9 LLVM Link Time Optimization: Design and Implementation . . . . . . . . . . . . . . . . . . . . . 1090
4.10 Segmented Stacks in LLVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1094
4.11 TableGen Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1095
4.12 TableGen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1095
4.13 Debugging JIT-ed Code With GDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1125
4.14 The LLVM gold plugin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1127
4.15 LLVM’s Optional Rich Disassembly Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1129
4.16 System Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1131
4.17 Source Level Debugging with LLVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1134
4.18 Auto-Vectorization in LLVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1156
4.19 Writing an LLVM Backend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1167
4.20 Garbage Collection with LLVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1198
4.21 Writing an LLVM Pass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1213
4.22 How To Use Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1233
4.23 User Guide for NVPTX Back-end . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1234
4.24 User Guide for AMDGPU Backend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1249
4.25 Stack maps and patch points in LLVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1326
4.26 Design and Usage of the InAlloca Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1333
4.27 Using ARM NEON instructions in big endian mode . . . . . . . . . . . . . . . . . . . . . . . . . . 1335
4.28 LLVM Code Coverage Mapping Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1341
4.29 Garbage Collection Safepoints in LLVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1350
4.30 MergeFunctions pass, how it works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1362
4.31 Type Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1374
4.32 FaultMaps and implicit checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1377
4.33 Machine IR (MIR) Format Reference Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1379
4.34 Coroutines in LLVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1390
4.35 Global Instruction Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1410
4.36 XRay Instrumentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1419
4.37 Debugging with XRay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1424
4.38 XRay Flight Data Recorder Trace Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1431
4.39 The PDB File Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1436
4.40 Control Flow Verification Tool Design Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1451
5 Development Process Documentation 1455
5.1 Contributing to LLVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1455
5.2 LLVM Developer Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1457
5.3 Creating an LLVM Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1467
5.4 LLVMBuild Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1471
5.5 How To Release LLVM To The Public . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1475
5.6 Advice on Packaging LLVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1481
5.7 How To Validate a New Release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1482
6 Community 1487
6.1 Mailing Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1487
6.2 IRC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1487
6.3 Community wide proposals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1488

7 Indices and tables 1503



基于llvm我们可以做什么,同时又是通过哪些方式来做的。

显然是通过那些指令来做的,llvm-**,clang,opt,lli,llc

主要是这三个指令,然后通过这三个指令搭配我们编写的文件搭配不同的选项就可以完成不同的功能。

预处理 -> 词法分析 -> Token -> 语法分析 -> AST -> 代码生成 -> LLVM IR -> 优化 -> 生成汇编代码 -> Link -> 目标文件。

优化用opt加上pass,

前面的用clang

后面的用llvm之类的东西。

说的不一定对,但是是这么个框架。从这么个思路去看。


可以用llvm写前端吗,写优化吗,写后端吗。

什么意思呢?其实你不用llvm你一样可以做这些事。

但是有了llvm之后,它给你提供了一些接口,一个框架,让你在这个基础上进行。

比如它的pass,你按部就班地写,其他的部分你不用管你就可以进行优化。

前端似乎没有,它好像就给了一个,clangplugin相当于一个clang的插件,你可以写一些功能。当然了,你完全地自己写一个前端也可以,只要你的中间语言是ir就行,它也为你提供了一系列的api你可以自己写前端到生成ir

至于写后端,似乎有一节专门讲怎么写后端的。

总之,它提供了框架,提供了接口,我们用这些就可以搭建一个编译器。

它的框架和接口都是围绕着ir来的。

pass:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值