0
我想要得到嵌套結構/數組數據類型的確切字節表示。例如,以下C結構:嵌套結構/數組的LLVM對齊
typedef struct zTy {
int x;
char c[2];
struct { char d; } v;
} z;
它被轉換爲以下LLVM IR:
%struct.zTy = type { i32, [2 x i8], %struct.anon }
%struct.anon = type { i8 }
%a = alloca %struct.zTy, align 4
從ALLOCA指令有可能看到的對準(4字節)。但是我不知道這個對齊方式是在哪裏插入的,或者是如何計算嵌套結構的對齊方式。 我得到的結構的總大小爲我的目標三重使用getTypeAllocSize():
AllocaInst* AI;
Module &M;
Type* T = AI->getAllocatedType();
int size = M.getDataLayout()->getTypeAllocSize(T) // 8 Byte
有沒有辦法來確定從LLVM任意嵌套的數據類型爲我的目標架構的準確佈局傳遞?
你知道我怎麼能在我的通行證裏面得到這些信息嗎? – user2600312
用LLVM API更新了答案。 – Joky