随笔分类 -  LLVM程序分析日记

摘要:Introduction LLVM MemorySSA使我们能够便捷地推断各种内存操作之间的交互。它旨在替代 MemoryDependenceAnalysis大多数(即使不是全部)用例。在较高的层次上,MemorySSA是提供一种基于SSA的内存表单,并带有def-use和use-def链,这使用户 阅读全文
posted @ 2021-02-21 22:25 bjchan9an 阅读(1348) 评论(0) 推荐(0)
摘要:LLVM IR中惯用的IntegerType主要是: Int8Ty Int16Ty Int32Ty Int64Ty 但是,今天注意到了一个有意思的API: static IntegerType * getIntNTy (LLVMContext &C, unsigned N) 从而,我们可以定义任意长 阅读全文
posted @ 2021-02-03 22:23 bjchan9an 阅读(392) 评论(0) 推荐(0)
摘要:前言 消除对LLVM GEP指令的恐惧!它其实也很简单。 挖坑TODO References [1] https://www.llvm.org/docs/GetElementPtr.html [2] https://stackoverflow.com/questions/53960500/llvm- 阅读全文
posted @ 2021-02-03 11:30 bjchan9an 阅读(309) 评论(0) 推荐(0)
摘要:查看LLVM BasicBlock类的文档时,发现了一些有意思的成员函数 BasicBlock *getSingleSuccessor () const Return the successor of this block if it has a single successor. More... 阅读全文
posted @ 2021-01-30 11:22 bjchan9an 阅读(385) 评论(0) 推荐(0)
摘要:1. def-use chain 以及 use-def chain See https://llvm.org/docs/ProgrammersManual.html#iterating-over-def-use-use-def-chains 其中,前者可以很方便得获取函数得所有caller inst 阅读全文
posted @ 2021-01-07 20:47 bjchan9an 阅读(1528) 评论(0) 推荐(0)
摘要:在对现有工具二次开发时,我们常常插入assert()检查来确保程序行为符合预期。但需要注意的是,一些项目的编译选项会使assert()无效。目前我们的解决方案是,宏定义一个自己的assert检查: #define MyAssert(x) do { \ if (!(x)) {printf("MyAss 阅读全文
posted @ 2020-12-22 23:28 bjchan9an 阅读(205) 评论(0) 推荐(0)
摘要:1. splitblockandinsertifthenelse() 一个代码例子:StackOverflow 2. SplitBlockAndInsertIfThen() 或者仅仅想插桩if then的逻辑,就可以用SplitBlockAndInsertIfThen(),其使用相对简单些,一个例子 阅读全文
posted @ 2020-12-16 08:52 bjchan9an 阅读(1112) 评论(6) 推荐(0)
摘要:我们编写LLVM Pass或者将LLVM嵌入自己的项目时,需要用到CMake来组织自己的项目目录。 Documents http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project http://llvm.org/docs/CMake. 阅读全文
posted @ 2020-12-12 20:14 bjchan9an 阅读(320) 评论(0) 推荐(0)
摘要:We used the predecessors() to get the predecessors of a basic block based on LLVM's IR. The code is like: for (llvm::BasicBlock* pred_bb : predecessor 阅读全文
posted @ 2020-12-06 10:22 bjchan9an 阅读(183) 评论(1) 推荐(0)