bool Flattening::flatten(Function *f) { vector<BasicBlock *> origBB; // 存储原始基本块 BasicBlock *loopEntry; // 进入循环的基本块 BasicBlock *loopEnd; // 退出循环的基本块 LoadInst *load; // switch 变量的加载指令 SwitchInst *swi
遍历内部的blocks,如果是through block则记录下来 上图将相关的through block也同样记录下来,记录为推荐spill模式,并将节点放入TodoList和ActiveNodes 最终通过iterate函数将之前得到的Todolist函数进行更新,确定每个节点是用寄存器分配还是spill分配,还是不管,如果更洗完还有寄存器分配的情况,则重新进行while循环 上图中的Rec...
void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) { SelectAllBasicBlocks中一开始会对函数参数进行Lower,因为参数对于各个Basic Block是公有的。 LowerArguments(Fn); 然后按照Reverse Post-Order调用SelectBasicBlock来对每个Basic Block进行指令选择。 ReversePostOrderTraversal<const Function*> RPOT(&...
F);// 调用addBogusFlow进行虚假控制流混淆}// remove the block from the listbasicBlocks.pop_front();if(firstTime){// first time we iterate on this function
if(firstTime){ // first time we iterate on this function ++InitNumBasicBlocks; ++FinalNumBasicBlocks; } } // end of while(!basicBlocks.empty()) firstTime = false; }while(--NumObfTimes > 0); }外面一层while循环是循环虚假控制流混淆次数,对于每次混淆,先将函数的所有基本块加入到basicBlocks...
It roughly corresponds to the LLVM code input to the instruction selector, but there can be a one-to-many mapping (i.e. one LLVM basic block can map to multiple machine basic blocks). The MachineBasicBlock class has a “getBasicBlock” method, which returns the LLVM basic block that ...
importsysfromllvmcpyimportLLVMCPyllvm=LLVMCPy()buffer=llvm.create_memory_buffer_with_contents_of_file(sys.argv[1])context=llvm.get_global_context()module=context.parse_ir(buffer)forfunctioninmodule.iter_functions():forbbinfunction.iter_basic_blocks():forinstructioninbb.iter_instructions():instruction...
- VPBlockUtils::insertBlockAfter(VPExitBlock, MiddleVPBB); - VPBlockUtils::connectBlocks(MiddleVPBB, ScalarPH); + if (IRExitBlock) { + auto *VPExitBlock = VPIRBasicBlock::fromBasicBlock(IRExitBlock); + // The connection order corresponds to the operands of the conditional + // branch...
Every source file should have a header on it that describes the basic purpose of the file. The standard header looks like this: A few things to note about this particular format: The “-- C++ --” string on the first line is there to tell Emacs that the source file is a C++ file,...
A LLVM function consists of a sequence ofbasic blockscontaining a sequence of instructions and assignment to local values. During compilation basic blocks will roughly correspond to labels in the native assembly output. define double@main(double%x) { ...