Given the following code:
struct Point<'a> {
x: i32,
caption: &'a str,
y: i32,
}
static mut global_var: Point = Point {
x: 123,
y: 344,
caption: "123",
};
The generated LLVM IR code contains empty arrays, which are believed to be alignment paddings, according to discussions on Reddit: https://www.reddit.com/r/rust/comments/et2i62/why_the_global_variables_in_llvm_ir_is_generated/
%Point = type
{
[0 x i64],
{ [0 x i8]*, i64 },
[0 x i32],
i32,
[0 x i32],
i32,
[0 x i32]
}
Can I avoid those paddings to make some analyses on LLVM IR easier? To my understand, if an LLVM pass can do this job, it should be able to first identify those paddings, and then correctly rewrite the GEP instructions in the LLVM code.