llvm

聊聊风口上的 eBPF

岁酱吖の 提交于 2021-01-06 11:01:42
eBPF 是一个用于访问 Linux 内核服务和硬件的新技术,由于其灵活性和高性能等特点,被迅速用于网络、出错、跟踪以及防火墙等多场景。目前国内已有少数企业开始尝试将 eBPF 引入生产实践,又拍云也是其中一个。专为技术开发者提供知识分享的 Open Talk 公开课邀请了又拍云开发工程师周晨约直播分享 eBPF 的学习经验与开发心得,并对其分享内容进行整理,下拉至文末点击阅读原文可回看原视频。 大家好,今天分享的主题是《eBPF 探索之旅》,围绕三部分展开: eBPF 是什么 eBPF 能做什么 如何编写 eBPF 程序 认识 eBPF eBPF 是什么,从字面上来看是扩展伯克利包处理器,那伯克利包处理器是什么呢? 在此之前先来了解一个性能优秀的常用抓包工具:tcpdump tcpdump 图中展示了两个常用指令 指令一:指定 IP 和端口,可以抓到 IP 为 220.173.103.227,端口为 80 的包 指令二:加上 grep,可以过滤出带有 route 字段的数据 那么 tcpdump 又是如何做到通过用户提供的规则处理网络上收到的包,再 copy 给用户的呢?如果放在用户层,就需要在系统里所有 socket 读写的时候做一层处理,把规则放上去,这样做难度太大。而 tcpdump 是基于 libpcap 库实现的,libpcap 能做到在驱动将包交给内核网络时

how to convert LLVM clang++ command line to cmake config?

99封情书 提交于 2021-01-01 07:06:27
问题 I'm building a LLVM language with some tutorials. In a situation, there are command with: clang++ -g main.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core orcjit native` -O3 -o toy here a command llvm-config --cxxflags --ldflags --system-libs --libs core orcjit native which can expand to: -I/usr/local/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing

Building LLVM using Visual Studio

≯℡__Kan透↙ 提交于 2021-01-01 06:45:26
问题 I'm trying to build LLVM using visual studio 2012 (version 10.0). I have CMake installed and have run the following commands: svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm cd llvm\tools svn co http://llvm.org/svn/llvm-project/cfe/trunk clang cd .... mkdir build cd build cmake -G "Visual Studio 10" ..\llvm Running these commands works fine, until the last step. I receive a large number of warnings(?) which are as follows: -- Looking for dirent.h -- Looking for dirent.h - not found --

Is the transformation of fetch_add(0, memory_order_relaxed/release) to mfence + mov legal?

老子叫甜甜 提交于 2020-12-30 06:32:27
问题 The paper N4455 No Sane Compiler Would Optimize Atomics talks about various optimizations compilers can apply to atomics. Under the section Optimization Around Atomics, for the seqlock example, it mentions a transformation implemented in LLVM, where a fetch_add(0, std::memory_order_release) is turned into a mfence followed by a plain load, rather than the usual lock add or xadd . The idea is that this avoids taking exclusive access of the cacheline, and is relatively cheaper. The mfence is

Is the transformation of fetch_add(0, memory_order_relaxed/release) to mfence + mov legal?

笑着哭i 提交于 2020-12-30 06:31:41
问题 The paper N4455 No Sane Compiler Would Optimize Atomics talks about various optimizations compilers can apply to atomics. Under the section Optimization Around Atomics, for the seqlock example, it mentions a transformation implemented in LLVM, where a fetch_add(0, std::memory_order_release) is turned into a mfence followed by a plain load, rather than the usual lock add or xadd . The idea is that this avoids taking exclusive access of the cacheline, and is relatively cheaper. The mfence is

How to redirect llvm::outs() to file?

╄→尐↘猪︶ㄣ 提交于 2020-12-30 05:58:25
问题 I'm using some LLVM tools (like llvm-nm ) as static libraries. I.e. i copied source llvm-nm.cpp, renamed main(..) to llvm_nm(..) and compiled it as static library. I'd like to forward standard output to my file. I've tried to use the next approach: int out_fd, err_fd; fpos_t out_pos, err_pos; // redirect out fflush(stdout); fgetpos(stdout, &out_pos); out_fd = dup(fileno(stdout)); freopen(outFilename, "w", stdout); // execute int ret = llvm_nm(argc_, argv_); // restore output fflush(stdout);

What is a clobber?

坚强是说给别人听的谎言 提交于 2020-12-29 09:55:56
问题 Clang TargetInfo has a method called getClobbers : Returns a string of target-specific clobbers, in LLVM format. So, what is a clobber? 回答1: A clobbered register is a register which is trashed i.e. modified in unpredictable way by inline assembler. This usually happens when you need a temp. register or use particular instruction which happens to modify some register as a by-product. Usually programmer explicitly declares registers which are clobbered by his inline asm code but some may be

What is a clobber?

给你一囗甜甜゛ 提交于 2020-12-29 09:52:04
问题 Clang TargetInfo has a method called getClobbers : Returns a string of target-specific clobbers, in LLVM format. So, what is a clobber? 回答1: A clobbered register is a register which is trashed i.e. modified in unpredictable way by inline assembler. This usually happens when you need a temp. register or use particular instruction which happens to modify some register as a by-product. Usually programmer explicitly declares registers which are clobbered by his inline asm code but some may be

What is a clobber?

不羁岁月 提交于 2020-12-29 09:51:14
问题 Clang TargetInfo has a method called getClobbers : Returns a string of target-specific clobbers, in LLVM format. So, what is a clobber? 回答1: A clobbered register is a register which is trashed i.e. modified in unpredictable way by inline assembler. This usually happens when you need a temp. register or use particular instruction which happens to modify some register as a by-product. Usually programmer explicitly declares registers which are clobbered by his inline asm code but some may be

How can I find the size of a type?

和自甴很熟 提交于 2020-12-27 08:38:19
问题 I'm holding a Type* in my hand. How do I find out its size (the size objects of this type will occupy in memory) in bits / bytes? I see all kinds of methods allowing me to get "primitive" or "scalar" size, but that won't help me with aggregate types... 回答1: If you only need the size because you are inserting it into the IR (e.g., so you can send it to a call to malloc() ), you can use the getelementptr instruction to do the dirty work (with a little casting), as described here (with updating