如何在从 CPP class 编译的 LLVM IR 中打印结构类型的详细类型?

How to print the detailed type of a struct type in LLVM IR which is compiled from a CPP class?

在将 C++ 中的 class 编译为 LLVM 位码后,我使用 llvm-disopt -S 来显示文本 IR,但是 class 的打印类型是总是喜欢:%class.A = type { i32 (...)** }

有谁知道如何打印...当前隐藏的详细类型?

这是我使用的 C++ 代码:

#include <stdio.h>
#include <stdlib.h>

class A {
  public:
    virtual int foo(int i) {
      return i + 2;
    }
};

int main() {
  A *a = new A;
  int x = a->foo(1);
  return 0;
}

这里是输出 LLVM IR 的一部分:

; ModuleID = 'logs/abstract.bc'
source_filename = "abstract.cpp"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

%class.A = type { i32 (...)** }              // How to make ... become more detailed?

$_ZN1AC2Ev = comdat any
$_ZN1A3fooEi = comdat any
$_ZN1A3barEi = comdat any
$_ZTV1A = comdat any
$_ZTS1A = comdat any
$_ZTI1A = comdat any
....

这里没有什么隐藏的。

您的 class 包含一个虚函数。所以,相应的结构体应该有一个地方来存放函数指针。