From 95697a83955c03d42eaaac6ecedcae04bd6986c9 Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Sat, 26 Mar 2016 12:27:33 +0100 Subject: 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 --- src/rustllvm/RustWrapper.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/rustllvm') 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(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(fn); LLVMContext &C = f->getContext(); -- cgit 1.4.1-3-g733a5