|
15 | 15 | use std::c_str::ToCStr;
|
16 | 16 | use std::cell::RefCell;
|
17 | 17 | use collections::HashMap;
|
18 |
| -use libc::{c_uint, c_ushort, c_void, free}; |
| 18 | +use libc::{c_uint, c_ushort, c_void, free, uint64_t}; |
19 | 19 | use std::str::raw::from_c_str;
|
20 | 20 |
|
21 | 21 | use middle::trans::type_::Type;
|
@@ -92,6 +92,33 @@ pub enum Attribute {
|
92 | 92 | NonLazyBindAttribute = 1 << 31,
|
93 | 93 | }
|
94 | 94 |
|
| 95 | +#[repr(u64)] |
| 96 | +pub enum OtherAttribute { |
| 97 | + // The following are not really exposed in |
| 98 | + // the LLVM c api so instead to add these |
| 99 | + // we call a wrapper function in RustWrapper |
| 100 | + // that uses the C++ api. |
| 101 | + SanitizeAddressAttribute = 1 << 32, |
| 102 | + MinSizeAttribute = 1 << 33, |
| 103 | + NoDuplicateAttribute = 1 << 34, |
| 104 | + StackProtectStrongAttribute = 1 << 35, |
| 105 | + SanitizeThreadAttribute = 1 << 36, |
| 106 | + SanitizeMemoryAttribute = 1 << 37, |
| 107 | + NoBuiltinAttribute = 1 << 38, |
| 108 | + ReturnedAttribute = 1 << 39, |
| 109 | + ColdAttribute = 1 << 40, |
| 110 | + BuiltinAttribute = 1 << 41, |
| 111 | + OptimizeNoneAttribute = 1 << 42, |
| 112 | + InAllocaAttribute = 1 << 43, |
| 113 | + NonNullAttribute = 1 << 44, |
| 114 | +} |
| 115 | + |
| 116 | +#[repr(C)] |
| 117 | +pub enum AttributeSet { |
| 118 | + ReturnIndex = 0, |
| 119 | + FunctionIndex = !0 |
| 120 | +} |
| 121 | + |
95 | 122 | // enum for the LLVM IntPredicate type
|
96 | 123 | pub enum IntPredicate {
|
97 | 124 | IntEQ = 32,
|
@@ -308,7 +335,7 @@ pub mod llvm {
|
308 | 335 | use super::{CodeGenModel, RelocMode, CodeGenOptLevel};
|
309 | 336 | use super::debuginfo::*;
|
310 | 337 | use libc::{c_char, c_int, c_longlong, c_ushort, c_uint, c_ulonglong,
|
311 |
| - size_t}; |
| 338 | + size_t, uint64_t}; |
312 | 339 |
|
313 | 340 | // Link to our native llvm bindings (things that we need to use the C++ api
|
314 | 341 | // for) and because llvm is written in C++ we need to link against libstdc++
|
@@ -706,20 +733,11 @@ pub mod llvm {
|
706 | 733 | pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
|
707 | 734 | pub fn LLVMGetGC(Fn: ValueRef) -> *c_char;
|
708 | 735 | pub fn LLVMSetGC(Fn: ValueRef, Name: *c_char);
|
709 |
| - pub fn LLVMAddFunctionAttr(Fn: ValueRef, PA: c_uint); |
710 |
| - pub fn LLVMAddFunctionAttrString(Fn: ValueRef, Name: *c_char); |
711 |
| - pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, Name: *c_char); |
| 736 | + pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t); |
| 737 | + pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *c_char); |
| 738 | + pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *c_char); |
712 | 739 | pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
|
713 | 740 |
|
714 |
| - pub fn LLVMAddReturnAttribute(Fn: ValueRef, PA: c_uint); |
715 |
| - pub fn LLVMRemoveReturnAttribute(Fn: ValueRef, PA: c_uint); |
716 |
| - |
717 |
| - pub fn LLVMAddColdAttribute(Fn: ValueRef); |
718 |
| - |
719 |
| - pub fn LLVMRemoveFunctionAttr(Fn: ValueRef, |
720 |
| - PA: c_ulonglong, |
721 |
| - HighPA: c_ulonglong); |
722 |
| - |
723 | 741 | /* Operations on parameters */
|
724 | 742 | pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
|
725 | 743 | pub fn LLVMGetParams(Fn: ValueRef, Params: *ValueRef);
|
@@ -783,6 +801,9 @@ pub mod llvm {
|
783 | 801 | pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
|
784 | 802 | index: c_uint,
|
785 | 803 | align: c_uint);
|
| 804 | + pub fn LLVMAddCallSiteAttribute(Instr: ValueRef, |
| 805 | + index: c_uint, |
| 806 | + Val: uint64_t); |
786 | 807 |
|
787 | 808 | /* Operations on call instructions (only) */
|
788 | 809 | pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
|
@@ -1835,7 +1856,7 @@ pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
|
1835 | 1856 |
|
1836 | 1857 | pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
|
1837 | 1858 | unsafe {
|
1838 |
| - llvm::LLVMAddFunctionAttr(fn_, attr as c_uint) |
| 1859 | + llvm::LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr as uint64_t) |
1839 | 1860 | }
|
1840 | 1861 | }
|
1841 | 1862 | /* Memory-managed object interface to type handles. */
|
|
0 commit comments