mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 16:41:06 +03:00
Fixed LLVM function attribute handling.
Previously, set_param_attrs would overwrite any pre-existing attributes, which is problematic, as per-function attributes are also stored in a slot in that attribute list. This for example lead to "noinline" being dropped for functions with inline asm.
This commit is contained in:
parent
f95371aeb5
commit
08a8f5df9b
1 changed files with 24 additions and 7 deletions
|
@ -426,7 +426,6 @@ void DtoResolveFunction(FuncDeclaration* fdecl)
|
||||||
static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclaration* fdecl)
|
static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclaration* fdecl)
|
||||||
{
|
{
|
||||||
LLSmallVector<llvm::AttributeWithIndex, 9> attrs;
|
LLSmallVector<llvm::AttributeWithIndex, 9> attrs;
|
||||||
llvm::AttributeWithIndex PAWI;
|
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
|
||||||
|
@ -434,9 +433,7 @@ static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclarati
|
||||||
#define ADD_PA(X) \
|
#define ADD_PA(X) \
|
||||||
if (f->fty.X) { \
|
if (f->fty.X) { \
|
||||||
if (HAS_ATTRIBUTES(f->fty.X->attrs)) { \
|
if (HAS_ATTRIBUTES(f->fty.X->attrs)) { \
|
||||||
PAWI.Index = idx; \
|
attrs.push_back(llvm::AttributeWithIndex::get(idx, f->fty.X->attrs)); \
|
||||||
PAWI.Attrs = f->fty.X->attrs; \
|
|
||||||
attrs.push_back(PAWI); \
|
|
||||||
} \
|
} \
|
||||||
idx++; \
|
idx++; \
|
||||||
}
|
}
|
||||||
|
@ -477,9 +474,29 @@ static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclarati
|
||||||
{
|
{
|
||||||
if (HAS_ATTRIBUTES(attrptr[i]))
|
if (HAS_ATTRIBUTES(attrptr[i]))
|
||||||
{
|
{
|
||||||
PAWI.Index = idx+i;
|
attrs.push_back(llvm::AttributeWithIndex::get(idx + i, attrptr[i]));
|
||||||
PAWI.Attrs = attrptr[i];
|
}
|
||||||
attrs.push_back(PAWI);
|
}
|
||||||
|
|
||||||
|
// Merge in any old attributes (attributes for the function itself are
|
||||||
|
// also stored in a list slot).
|
||||||
|
const size_t newSize = attrs.size();
|
||||||
|
llvm::AttrListPtr oldAttrs = func->getAttributes();
|
||||||
|
for (size_t i = 0; i < oldAttrs.getNumSlots(); ++i) {
|
||||||
|
llvm::AttributeWithIndex curr = oldAttrs.getSlot(i);
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
for (size_t j = 0; j < newSize; ++j) {
|
||||||
|
if (attrs[j].Index == curr.Index) {
|
||||||
|
// TODO: LLVM 3.2.
|
||||||
|
attrs[j].Attrs |= curr.Attrs;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
attrs.push_back(curr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue