pub fn inline(val: ValueRef, inline: InlineAttr) {
use self::InlineAttr::*;
match inline {
- Hint => llvm::SetFunctionAttribute(val, llvm::InlineHintAttribute),
- Always => llvm::SetFunctionAttribute(val, llvm::AlwaysInlineAttribute),
- Never => llvm::SetFunctionAttribute(val, llvm::NoInlineAttribute),
+ Hint => llvm::SetFunctionAttribute(val, llvm::Attribute::InlineHint),
+ Always => llvm::SetFunctionAttribute(val, llvm::Attribute::AlwaysInline),
+ Never => llvm::SetFunctionAttribute(val, llvm::Attribute::NoInline),
None => {
- let attr = llvm::InlineHintAttribute |
- llvm::AlwaysInlineAttribute |
- llvm::NoInlineAttribute;
+ let attr = llvm::Attribute::InlineHint |
+ llvm::Attribute::AlwaysInline |
+ llvm::Attribute::NoInline;
unsafe {
llvm::LLVMRemoveFunctionAttr(val, attr.bits() as c_ulonglong)
}
#[inline]
pub fn emit_uwtable(val: ValueRef, emit: bool) {
if emit {
- llvm::SetFunctionAttribute(val, llvm::UWTableAttribute);
+ llvm::SetFunctionAttribute(val, llvm::Attribute::UWTable);
} else {
unsafe {
- llvm::LLVMRemoveFunctionAttr(val, llvm::UWTableAttribute.bits() as c_ulonglong);
+ llvm::LLVMRemoveFunctionAttr(
+ val,
+ llvm::Attribute::UWTable.bits() as c_ulonglong,
+ );
}
}
}
pub fn unwind(val: ValueRef, can_unwind: bool) {
if can_unwind {
unsafe {
- llvm::LLVMRemoveFunctionAttr(val, llvm::NoUnwindAttribute.bits() as c_ulonglong);
+ llvm::LLVMRemoveFunctionAttr(
+ val,
+ llvm::Attribute::NoUnwind.bits() as c_ulonglong,
+ );
}
} else {
- llvm::SetFunctionAttribute(val, llvm::NoUnwindAttribute);
+ llvm::SetFunctionAttribute(val, llvm::Attribute::NoUnwind);
}
}
#[allow(dead_code)] // possibly useful function
pub fn set_optimize_for_size(val: ValueRef, optimize: bool) {
if optimize {
- llvm::SetFunctionAttribute(val, llvm::OptimizeForSizeAttribute);
+ llvm::SetFunctionAttribute(val, llvm::Attribute::OptimizeForSize);
} else {
unsafe {
- llvm::LLVMRemoveFunctionAttr(val, llvm::OptimizeForSizeAttribute.bits() as c_ulonglong);
+ llvm::LLVMRemoveFunctionAttr(
+ val,
+ llvm::Attribute::OptimizeForSize.bits() as c_ulonglong,
+ );
}
}
}
llvm::ColdAttribute as u64)
}
} else if attr.check_name("allocator") {
- llvm::NoAliasAttribute.apply_llfn(llvm::ReturnIndex as c_uint, llfn);
+ llvm::Attribute::NoAlias.apply_llfn(llvm::ReturnIndex as c_uint, llfn);
}
}
}
// The outptr can be noalias and nocapture because it's entirely
// invisible to the program. We also know it's nonnull as well
// as how many bytes we can dereference
- attrs.arg(1, llvm::StructRetAttribute)
- .arg(1, llvm::NoAliasAttribute)
- .arg(1, llvm::NoCaptureAttribute)
+ attrs.arg(1, llvm::Attribute::StructRet)
+ .arg(1, llvm::Attribute::NoAlias)
+ .arg(1, llvm::Attribute::NoCapture)
.arg(1, llvm::DereferenceableAttribute(llret_sz));
// Add one more since there's an outptr
// The `noalias` attribute on the return value is useful to a
// function ptr caller.
match ret_ty.sty {
- // `~` pointer return values never alias because ownership
+ // `Box` pointer return values never alias because ownership
// is transferred
ty::ty_uniq(it) if common::type_is_sized(ccx.tcx(), it) => {
- attrs.ret(llvm::NoAliasAttribute);
+ attrs.ret(llvm::Attribute::NoAlias);
}
_ => {}
}
}
if let ty::ty_bool = ret_ty.sty {
- attrs.ret(llvm::ZExtAttribute);
+ attrs.ret(llvm::Attribute::ZExt);
}
}
}
// For non-immediate arguments the callee gets its own copy of
// the value on the stack, so there are no aliases. It's also
// program-invisible so can't possibly capture
- attrs.arg(idx, llvm::NoAliasAttribute)
- .arg(idx, llvm::NoCaptureAttribute)
+ attrs.arg(idx, llvm::Attribute::NoAlias)
+ .arg(idx, llvm::Attribute::NoCapture)
.arg(idx, llvm::DereferenceableAttribute(llarg_sz));
}
ty::ty_bool => {
- attrs.arg(idx, llvm::ZExtAttribute);
+ attrs.arg(idx, llvm::Attribute::ZExt);
}
- // `~` pointer parameters never alias because ownership is transferred
+ // `Box` pointer parameters never alias because ownership is transferred
ty::ty_uniq(inner) => {
let llsz = machine::llsize_of_real(ccx, type_of::type_of(ccx, inner));
- attrs.arg(idx, llvm::NoAliasAttribute)
+ attrs.arg(idx, llvm::Attribute::NoAlias)
.arg(idx, llvm::DereferenceableAttribute(llsz));
}
!ty::type_contents(ccx.tcx(), mt.ty).interior_unsafe() => {
let llsz = machine::llsize_of_real(ccx, type_of::type_of(ccx, mt.ty));
- attrs.arg(idx, llvm::NoAliasAttribute)
+ attrs.arg(idx, llvm::Attribute::NoAlias)
.arg(idx, llvm::DereferenceableAttribute(llsz));
if mt.mutbl == ast::MutImmutable {
- attrs.arg(idx, llvm::ReadOnlyAttribute);
+ attrs.arg(idx, llvm::Attribute::ReadOnly);
}
if let ReLateBound(_, BrAnon(_)) = *b {
- attrs.arg(idx, llvm::NoCaptureAttribute);
+ attrs.arg(idx, llvm::Attribute::NoCapture);
}
}
// reference to escape this function (returned or stored beyond the call by a closure).
ty::ty_rptr(&ReLateBound(_, BrAnon(_)), mt) => {
let llsz = machine::llsize_of_real(ccx, type_of::type_of(ccx, mt.ty));
- attrs.arg(idx, llvm::NoCaptureAttribute)
+ attrs.arg(idx, llvm::Attribute::NoCapture)
.arg(idx, llvm::DereferenceableAttribute(llsz));
}