authorgravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2021-02-05 00:25:01+07:00
committergravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2021-02-05 00:25:01+07:00
logd23dfdeab9358f0f026990e4d0f1da0ddaa6b177
tree16ca6c1d0f60e43fb2948fc96310b1f6723d358b
parente3e4af727103d90cb191f130159928d237263e1f

Add comment explaining the alignment setting


1 files changed, 6 insertions(+), 0 deletions(-)

src/stage1/codegen.cpp+6
...@@ -4161,6 +4161,12 @@ static LLVMValueRef gen_frame_size(CodeGen *g, LLVMValueRef fn_val) {...@@ -4161,6 +4161,12 @@ static LLVMValueRef gen_frame_size(CodeGen *g, LLVMValueRef fn_val) {
4161 LLVMValueRef negative_one = LLVMConstInt(LLVMInt32Type(), -1, true);4161 LLVMValueRef negative_one = LLVMConstInt(LLVMInt32Type(), -1, true);
4162 LLVMValueRef prefix_ptr = LLVMBuildInBoundsGEP(g->builder, casted_fn_val, &negative_one, 1, "");4162 LLVMValueRef prefix_ptr = LLVMBuildInBoundsGEP(g->builder, casted_fn_val, &negative_one, 1, "");
4163 LLVMValueRef load_inst = LLVMBuildLoad(g->builder, prefix_ptr, "");4163 LLVMValueRef load_inst = LLVMBuildLoad(g->builder, prefix_ptr, "");
4164
4165 // Some architectures (e.g SPARCv9) has different alignment requirements between a
4166 // function/usize pointer and also require all loads to be aligned.
4167 // On those architectures, not explicitly setting the alignment will lead into @frameSize
4168 // generating usize-aligned load instruction that could crash if the function pointer
4169 // happens to be not usize-aligned.
4164 LLVMSetAlignment(load_inst, 1);4170 LLVMSetAlignment(load_inst, 1);
4165 return load_inst;4171 return load_inst;
4166}4172}