LLVM代码研读(1)---- 安装篇

LLVM IR 实战指南:生成、解读与Windows环境下踩坑 编译器从源码到机器码的中间层,是理解程序优化与跨平台移植的关键。LLVM IR(中间表示)作为一种静态单赋值(SSA)形式的统一语言,让C/C++、Rust等不同前端共享同一套优化管道。它包含内存、位码和文本三种等价表示,其中.ll文本格式便于人类阅读与调试。通过clang -S -emit-llvm即可快速生成IR,结合-O0/-O2对比,能直观看到常量传播、死代码消除等优化pass的实际效果。理解LLVM IR不仅能帮你剖析Rust或Clang的后端行为,还能为自定义语言直接复用LLVM的优化与代码生成 阅读详情

前序:LLVM的安装

前言:这里提供了最新版本v4.0.1(2017/3)的完整安装过程,对已经有经验的LLVM/Clang完全可以忽略这些内容。相关文件与目录的组织建议尽量参考我这里的定义。以保证之后使用上的一致

1          LLVM安装前准备:

1.1         系统的选择:

    • OS:Ubuntu Linux 16.04 LTS 64Bits(可以是实际Linux系统,我使用Windows10 64Bits + VMWare)
    • 硬件:至少120G以上硬盘。因为我们这里是为了研究LLVM/Clang,在包含Debug信息下,Build完所有源码连同Linux系统大约使用硬盘空间85G;如果使用虚拟机建议更大的可用硬盘空间

1.2         安装前主要补丁:

sudo apt-get installbuild-essential zlib1g-dev python graphviz xdot cmake subversion

如果安装lldb,需要再安装(当前不建议安装):

sudo apt-get install swigpython2.7-dev libedit-dev libncurses5-dev

可选安装:(假定需要ARM交叉平台上使用,暂未安装)

      • sudo apt-get install g++-4.9g++-4.9 g++-4.9
      • sudo apt-get install g++-4.9-arm-linux-gnueabig++-4.9-arm-linux-gnueabi
      • sudo apt-get install g++-4.9-arm-linux-gnueabihf g++-4.9-arm-linux-gnueabihf

如果需要检查内存泄露,建议安装valgrind(建议安装)

sudo apt-get install valgrind

说明:

      • 为了看ast-view生成的树,graphviz和xdot需要安装
      • LLVM 3.8起推荐使用cmake,因此,cmake需要安装

2          代码下载与安装:

2.1         建立LLVM目录

    • 建立llvm源码目录,假定:llvm_source
    • 建立llvm工作目录(build目录),假定:llvm_project
    • 建立llvm安装目录,假定:llvm_install
从C++到LLVM IR:一份能跑通的生成演示与避坑指南 LLVM IR 是编译器前端与后端之间的中间表示,掌握其生成方式对代码生成、静态分析和 JIT 实验至关重要。通过 C++ 调用 LLVM 库,利用 IRBuilder 构建模块、函数与指令,可将源码逻辑转化为可验证的 IR 文本。这一过程不仅帮助理解编译器内部机制,还能为优化 Pass 提供可操作的输入。在代码生成、程序分析和即时编译等场景中,直接生成 IR 是核心能力。本文以一份可运行的演示资源为例,展示从环境搭建到 IR 输出、校验与优化的完整闭环,并总结常见链接与类型错误,帮助开发者快速上手 LLV 阅读详情

相关推荐

工业级C-MinusF教学编译器:LLVM IR生成与循环优化实战

编译器优化是程序性能提升的核心环节,其基础在于对控制流、数据流及中间表示(IR)的深入理解。循环不变式外提(LICM)和常量传播作为经典优化技术,依赖活跃变量分析、支配关系识别与标准循环结构构建等原理,具备明确的数据流方程求解逻辑与工程落地约束。在教学实践中,将理论映射到真实LLVM IR生成链路,可显著强化对优化时机、副作用判定与内存语义的认知。本实现基于C-MinusF语言,完整覆盖词法语法分析、AST构建、符号表管理、LLVM模块生成及LICM/常量传播等关键环节,特别适配《编译原理》课程第九章优化内

weixin_29722783的博客 231

SymEngine符号计算加速:C++内核、Lambdify与混合工作流

在 Python 科学计算栈中,符号计算与计算机代数系统常用于公式推导、求导和表达式求值,但表达式构建、展开、代换在循环与参数扫描中容易成为性能瓶颈。SymEngine 以 C++ 内核承担符号运算,Python 绑定保持轻量,并通过 Lambdify 借助 LLVM 将表达式编译为机器码,降低逐点求值开销。其技术价值在于高频符号操作快一到两个数量级,适合批量数值扫描、服务端计算和 C++ 侧求值等场景。围绕安装路径、表达式构造、精度控制及 SymPy 混合工作流展开工程实践,可帮助定位共享库链接、浮点污染

weixin_34221654的博客 256

llvm-sys.rs:Rust绑定到LLVM。 (https的镜像

Rust绑定到LLVM的C API。 用法 [ dependencies ] llvm-sys = " 110 " 必须有可用的LLVM兼容版本。 默认情况下, llvm-sys将在PATH上查找llvm-config ,以查找LLVM的系统范围的副本,如果它是兼容版本,则使用该副本。 可以通过环境变量指定在系统上查找LLVM的自定义选项。 有关更多信息,请参见。 文献资料 请参阅此存储库中的examples目录以获取API示例。 也存在一些其他使用这些绑定的项目,这些项目可能是有益的或有用的: 使用LLVM的安全,“稳定” API: Jay Phelps撰写了有关 这些绑定中没有记录大多数接口。 有关更多信息,请参阅,尤其是。 如果您有使用这些绑定的自己的项目,而您认为在这里值得一提,那么请务必告知我。 LLVM兼容性 由于LLVM C 相对较弱,因此该板条箱强制要求所使用的LLV

ArcGIS Pro 3.0 水文分析实战:用DEM数据模拟城市内涝,手把手教你生成淹没范围图

本文详细介绍了如何使用ArcGIS Pro 3.0进行水文分析,通过DEM数据模拟城市内涝并生成淹没范围图。从数据准备、核心分析流程优化到成果可视化,手把手教你掌握关键技巧,如动态流量阈值设定和淹没区三维模拟,帮助城市规划与应急管理部门精准预测积水范围。

weixin_42531925的博客 233

powerdesigner导出sql将name放到comment注释上

【代码】powerdesigner导出sql将name放到comment注释上。

weixin_45947759的博客 1355

3dsMax高效导入OSGB倾斜模型的3个关键步骤与插件应用

本文详细解析了在3dsMax中高效导入OSGB倾斜模型的三个核心步骤:建立索引、处理贴图路径以及选择合适的插件。针对导入过程中常见的模型崩溃、贴图丢失和操作卡顿问题,提供了从数据结构理解到插件选型的实战解决方案,帮助用户实现大规模实景模型在3dsMax中的流畅导入与编辑。

weixin_29238147的博客 473

保姆级教程:用AI辅助反编译Python3.9+的EXE文件(兼容新版pycdc工具)

本文详细介绍了如何利用AI技术辅助反编译Python 3.9+的EXE文件,解决传统工具如uncompyle6无法处理新版字节码的问题。通过pycdc工具和AI大模型的结合,开发者可以高效还原代码逻辑,并提供了从EXE解包到字节码解析的完整流程,适用于逆向工程和代码分析场景。

hill8的博客 1236

不会ps,你也可以成为ps高手,最强傻瓜式人像一键磨皮美白瘦脸美妆PS插件

比如:美肤是用来去斑点的,如果效果不太理想,就加大百分比,反之就减小。瘦脸如果脸胖的就打开,正常的就关闭。所谓的一键调节,要不只能调节一种效果,要不就是个预设,然后让你自己再调。同时,该软件还加入了贴心的批量处理功能,能同时处理上千张照片,让您喝着茶也能将工作做完。、自动检测照片中的人脸,包括鼻子,嘴巴,耳朵,眼睛和眉毛。、依托强大的脸部识别功能,可以高效的对人物全身皮肤进行智能识别,处理,使肤质平滑、过渡均匀。,这是网上下载的模糊照片,经过简单处理,你可以发现,眼睛变的更亮,皮肤更白,眼袋消失。

心语家园 - www.xinyucn.cc 2908

BurpSuite+安卓模拟器双保险:避开真机抓包限制的完整配置指南

本文详细介绍了如何通过BurpSuite与安卓模拟器(如雷电、夜神)协同工作,绕过真机抓包限制的完整配置指南。从环境准备、网络拓扑配置到证书部署和流量分析,提供了一套高效的解决方案,帮助安全测试人员稳定捕获手机数据包,提升测试效率。

Apple的专栏 442

【Docker】完美解决拉取镜像超时报错:ERROR: Get https://registry-1.docker.io/v2/

因为我们下载的镜像是外网的镜像资源,所以下载的速度会非常的慢,甚至大概率下载时会报错,所以需要我们配置一个国内的服务器镜像地址,国内服务器镜像地址有很多,这里咱们就说一下阿里镜像加速器的配置方法。

liu_chen_yang的博客 12万+

2xmax96717+max96724+agx orin驱动代码

说明:这里主要解决max96717的设备地址和sensor地址映射,vc0->vc1多颗max96717+max96724使用配置思路如下: 1、改变max96717的pipez stream id,然后max96724的pipe绑定使用相应的stream id 2、max96717默认是vc0,把vc0改写成vc1\vc2\vc3,然后max96724再重新映射vc输出

mantouyouyou的博客 120

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

上一篇: 简要评说Adobe的FlashPlayer的渲染算法--续1
下一篇: LLVM代码研读(2) --- LLVM前端: Clang剖析
「已注销」
「已注销」 领域专家: 学术研究与理论基础技术领域 领域专家: 学术研究与理论基础技术领域
博客等级 码龄19年 388粉丝 17原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值