在我的llvm IR代码中,我有以下一行:
%tmp = call i32 @decf1(void (i8*)* bitcast (void (%a_type*)* @decf2 to void (i8*)*), i8 %x3, i8* @external_type)
我正在尝试以编程方式提取a_type
和decf2
,但我似乎无法访问它们。
bool runOnFunction(Function &F) override {
errs() << "Initializing Test pass\n";
for (BasicBlock &BB : F) {
for (Instruction &I : BB) {
// New Instruction
errs() << "\n\n"
<< "=====================\n"
<< "- - - - - - - - - - -\n"
<< "NewInstruction:\n";
I.dump();
errs() << "\n";
// New Operands
errs() << "- - - - - - - - - - -\n"
<< "Operands:\n";
for (Use &U : I.operands()) {
errs() << "Type: ";
U->getType()->print(errs());
errs() << "\n";
errs() << "Name: " << U->getName() << "\n";
}
errs() << "\n";
}
这个过程为我提供了包含演员的指令的以下ouptut。
=====================
- - - - - - - - - - -
NewInstruction:
%tmp = call i32 @decf1(void (i8*)* bitcast (void (%a_type*)* @decf2 to void (i8*)*), i8 %x3, i8* @external_type)
- - - - - - - - - - -
Operands:
Type: void (i8*)*
Name:
Is Instruction: No
Is Function: No
Type: i8
Name: x3
Is Instruction: Yes
%x3 = mul i8 %x2, %x2
Is Function: No
Type: i8*
Name: external_type
Is Instruction: No
Is Function: No
Type: i32 (void (i8*)*, i8, i8*)*
Name: decf1
Is Instruction: No
Is Function: Yes
Is Declaration: Yes
似乎第一个打印的操作数与bitcast有关。 如何获取bitcast以及它正在投射的操作数/类型/功能?
答案 0 :(得分:1)
似乎Value::stripPointerCasts()
是将decf2
函数转换为Function *
的方法。
还需要详细说明如何从那里获取a_type
。