Fix void function calls not discarding name
This commit is contained in:
parent
b82cbcb45c
commit
3d5ddc60dc
@ -205,14 +205,12 @@ impl FunctionHolder {
|
|||||||
let own_function = *module.functions.get(&self.value).unwrap();
|
let own_function = *module.functions.get(&self.value).unwrap();
|
||||||
|
|
||||||
if self.data.flags.is_extern {
|
if self.data.flags.is_extern {
|
||||||
LLVMSetLinkage(
|
LLVMSetLinkage(own_function.value_ref, LLVMLinkage::LLVMExternalLinkage);
|
||||||
own_function.value_ref,
|
|
||||||
LLVMLinkage::LLVMAvailableExternallyLinkage,
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if self.data.flags.is_pub {
|
|
||||||
LLVMSetLinkage(own_function.value_ref, LLVMLinkage::LLVMCommonLinkage);
|
if self.data.flags.is_pub || self.data.name == "main" {
|
||||||
|
LLVMSetLinkage(own_function.value_ref, LLVMLinkage::LLVMExternalLinkage);
|
||||||
} else {
|
} else {
|
||||||
LLVMSetLinkage(own_function.value_ref, LLVMLinkage::LLVMPrivateLinkage);
|
LLVMSetLinkage(own_function.value_ref, LLVMLinkage::LLVMPrivateLinkage);
|
||||||
}
|
}
|
||||||
@ -317,14 +315,22 @@ impl InstructionHolder {
|
|||||||
.map(|i| module.values.get(i).unwrap().value_ref)
|
.map(|i| module.values.get(i).unwrap().value_ref)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
LLVMBuildCall2(
|
let is_void = module.builder.function_data(&*function_value).ret == Type::Void;
|
||||||
|
if is_void {
|
||||||
|
LLVMContextSetDiscardValueNames(module.context_ref, 1);
|
||||||
|
}
|
||||||
|
let value = LLVMBuildCall2(
|
||||||
module.builder_ref,
|
module.builder_ref,
|
||||||
fun.type_ref,
|
fun.type_ref,
|
||||||
fun.value_ref,
|
fun.value_ref,
|
||||||
param_list.as_mut_ptr(),
|
param_list.as_mut_ptr(),
|
||||||
param_list.len() as u32,
|
param_list.len() as u32,
|
||||||
c"call".as_ptr(),
|
c"call".as_ptr(),
|
||||||
)
|
);
|
||||||
|
if is_void {
|
||||||
|
LLVMContextSetDiscardValueNames(module.context_ref, 0);
|
||||||
|
}
|
||||||
|
value
|
||||||
}
|
}
|
||||||
Phi(values) => {
|
Phi(values) => {
|
||||||
let mut inc_values = Vec::new();
|
let mut inc_values = Vec::new();
|
||||||
@ -491,7 +497,7 @@ impl Type {
|
|||||||
I64 | U64 => LLVMInt64TypeInContext(context),
|
I64 | U64 => LLVMInt64TypeInContext(context),
|
||||||
I128 | U128 => LLVMInt128TypeInContext(context),
|
I128 | U128 => LLVMInt128TypeInContext(context),
|
||||||
Bool => LLVMInt1TypeInContext(context),
|
Bool => LLVMInt1TypeInContext(context),
|
||||||
Void => LLVMVoidType(),
|
Void => LLVMVoidTypeInContext(context),
|
||||||
Ptr(ty) => LLVMPointerType(ty.as_llvm(context), 0),
|
Ptr(ty) => LLVMPointerType(ty.as_llvm(context), 0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user