about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorBjörn Steinbrink <bsteinbr@gmail.com>2016-03-26 12:27:33 +0100
committerBjörn Steinbrink <bsteinbr@gmail.com>2016-03-26 13:02:54 +0100
commit95697a83955c03d42eaaac6ecedcae04bd6986c9 (patch)
treebf75c17b3c8323e9e9c927a79c7463d4486f2246 /src/rustllvm/RustWrapper.cpp
parentd322f990b04e3b598afd6a47c09a0277f73031aa (diff)
downloadrust-95697a83955c03d42eaaac6ecedcae04bd6986c9.tar.gz
rust-95697a83955c03d42eaaac6ecedcae04bd6986c9.zip
Fix removal of function attributes on ARM
We use a 64bit integer to pass the set of attributes that is to be
removed, but the called C function expects a 32bit integer. On most
platforms this doesn't cause any problems other than being unable to
unset some attributes, but on  ARM even the lower 32bit aren't handled
correctly because the 64bit value is passed in different registers, so
the C function actually sees random garbage.

So we need to fix the relevant functions to use 32bit integers instead.
Additionally we need an implementation that actually accepts 64bit
integers because some attributes can only be unset that way.

Fixes #32360
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
-rw-r--r--src/rustllvm/RustWrapper.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp
index 33174c1e9df..6ff90a8f53a 100644
--- a/src/rustllvm/RustWrapper.cpp
+++ b/src/rustllvm/RustWrapper.cpp
@@ -151,6 +151,16 @@ extern "C" void LLVMAddFunctionAttrStringValue(LLVMValueRef Fn, unsigned index,
   F->addAttributes(index, AttributeSet::get(F->getContext(), index, B));
 }
 
+extern "C" void LLVMRemoveFunctionAttributes(LLVMValueRef Fn, unsigned index, uint64_t Val) {
+  Function *A = unwrap<Function>(Fn);
+  const AttributeSet PAL = A->getAttributes();
+  AttrBuilder B(Val);
+  const AttributeSet PALnew =
+    PAL.removeAttributes(A->getContext(), index,
+                         AttributeSet::get(A->getContext(), index, B));
+  A->setAttributes(PALnew);
+}
+
 extern "C" void LLVMRemoveFunctionAttrString(LLVMValueRef fn, unsigned index, const char *Name) {
   Function *f = unwrap<Function>(fn);
   LLVMContext &C = f->getContext();