Add TBAA labels to initialization (default and copy) of locals.

This commit is contained in:
Nick Lewycky
2019-12-20 17:02:36 -08:00
parent fa29a1b9f2
commit cca73c0a6f

View File

@ -927,7 +927,14 @@ impl<'ctx> FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator<'ct
for local_idx in 0..count { for local_idx in 0..count {
let alloca = let alloca =
alloca_builder.build_alloca(ty, &format!("local{}", param_len + local_idx)); alloca_builder.build_alloca(ty, &format!("local{}", param_len + local_idx));
builder.build_store(alloca, default_value); let store = builder.build_store(alloca, default_value);
tbaa_label(
&self.module,
&intrinsics,
"local",
store,
Some((param_len + local_idx) as u32),
);
if local_idx == 0 { if local_idx == 0 {
alloca_builder.position_before( alloca_builder.position_before(
&alloca &alloca
@ -8579,10 +8586,17 @@ impl<'ctx> ModuleCodeGenerator<LLVMFunctionCodeGenerator<'ctx>, LLVMBackend, Cod
let real_ty_llvm = type_to_llvm(&intrinsics, real_ty); let real_ty_llvm = type_to_llvm(&intrinsics, real_ty);
let alloca = let alloca =
alloca_builder.build_alloca(real_ty_llvm, &format!("local{}", index)); alloca_builder.build_alloca(real_ty_llvm, &format!("local{}", index));
builder.build_store( let store = builder.build_store(
alloca, alloca,
builder.build_bitcast(param, real_ty_llvm, &state.var_name()), builder.build_bitcast(param, real_ty_llvm, &state.var_name()),
); );
tbaa_label(
&self.module,
&intrinsics,
"local",
store,
Some(index as u32),
);
if index == 0 { if index == 0 {
alloca_builder.position_before( alloca_builder.position_before(
&alloca &alloca