0

My Problem

I would like to get Rust TypeAlias identifiers such as MyU64 in the following code from LLVM IR code compiled with rustc. Is this possible?

type MyU64 = u64;

fn main() {
    let my_u64: MyU64 = 987;
    println!("{}", my_u64);
}

I know that the clang -g -S -emit-llvm command can be used to get the C type definition identifier as LLVM IR Metadata.

typedef unsigned long int MyU64;
int main() {
    MyU64 a = 987;
}
define dso_local i32 @main() #0 !dbg !7 {
  %1 = alloca i64, align 8
  call void @llvm.dbg.declare(metadata i64* %1, metadata !12, metadata !DIExpression()), !dbg !15
  store i64 987, i64* %1, align 8, !dbg !15
  ret i32 0, !dbg !16
}

...

!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "MyU64", file: !8, line: 1, baseType: !14)
!14 = !DIBasicType(name: "long unsigned int", size: 64, encoding: DW_ATE_unsigned)

Can something similar be done with rustc?

I tried to do that with rustc -C debuginfo=2 --emit=llvm-ir, but I couldn't.

woxjro
  • 1
  • 1

0 Answers0