我试图插入内部cos()函数调用LLVM传递.我在FunctionPass中的代码:
std::vector<Type *> arg_type;
arg_type.push_back(Type::getFloatTy(getGlobalContext()));
Function *fun = Intrinsic::getDeclaration(F.getParent(), Intrinsic::cos, arg_type);
CallInst* callInst = CallInst::Create(fun, args, Twine("cos"), (Instruction *)&I);
Run Code Online (Sandbox Code Playgroud)
当我遗漏最后一行时产生的IR是:
define i32 @main() nounwind uwtable {
entry:
...
}
declare float @llvm.cos.f32(float) nounwind readonly
Run Code Online (Sandbox Code Playgroud)
,但包含CallInst所有我得到的是:
0 opt 0x000000000094f4bf
1 opt 0x000000000094f9c9
2 libpthread.so.0 0x00007fb92b652cb0
3 opt 0x00000000008be244 llvm::Instruction::Instruction(llvm::Type*, unsigned int, llvm::Use*, unsigned int, llvm::Instruction*) + 148
4 LLVMObfuscation.so 0x00007fb92a66c52f
5 LLVMObfuscation.so 0x00007fb92a66c9a5
6 LLVMObfuscation.so 0x00007fb92a66df21
7 opt 0x00000000008e921f llvm::FPPassManager::runOnFunction(llvm::Function&) + 591
8 opt 0x00000000008e9293 llvm::FPPassManager::runOnModule(llvm::Module&) + 51
9 opt 0x00000000008e8f34 …Run Code Online (Sandbox Code Playgroud)