c++ - 在 LLVM 中,什么 "type"是调用中函数的位转换?如何访问此功能?

标签 c++ compiler-construction llvm llvm-ir

在我的 llvm IR 代码中,我有以下行:

%tmp = call i32 @decf1(void (i8*)* bitcast (void (%a_type*)* @decf2 to void (i8*)*), i8 %x3, i8* @external_type)

我正在尝试以编程方式提取 a_typedecf2,但我似乎无法访问它们。

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/

相关文章:

c++ - 使用宏创建自定义 block 类型

build-process - 如何注册一个新的 LLVM 后端?

ubuntu - 在 Ubuntu 中构建 llvm 源代码的 fatal error

c++ - 使用dumpbin查看C++库信息时,UNDEF和notype()是什么意思?

c++ - 是否可以使函数对常量参数或变量参数表现不同?

c++ - Float、Double、Char、C++ 错误。怎么了?

c++ - 如何在 Qt Creator 中使用英特尔 C++ 编译器

c - Flex 和 Bison 代码 - 总是有语法错误

c++ - 使用 Clang 和 LLVM

C++ htonll 和返回