在我的 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";
}
此过程为包含强制转换的指令生成了以下输出。
=====================
- - - - - - - - - - -
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
似乎第一个打印的操作数与位广播有关。 如何获取位转换及其正在转换的操作数/类型/函数?
最佳答案
似乎Value::stripPointerCasts()
是获得 Actor 阵容的一种方式decf2
用作 Function *
.
还需要详细说明如何得到a_type
从那里开始。
关于c++ - 在 LLVM 中,什么 "type"是调用中函数的位转换?如何访问此功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47333508/