mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 00:55:49 +03:00
Fix function attribute handling on LLVM 3.3+.
The issue was that when merging in the old attributes, attrs wasn't assigned to, thus silently dropping all of them (leading e.g. to noinline being omitted on functions containing inline asm). The new code hopefully also makes the intent clearer.
This commit is contained in:
parent
10f5d74737
commit
a792ecbaf2
1 changed files with 7 additions and 12 deletions
|
@ -552,7 +552,10 @@ void DtoResolveFunction(FuncDeclaration* fdecl)
|
|||
#if LDC_LLVM_VER >= 303
|
||||
static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclaration* fdecl)
|
||||
{
|
||||
llvm::AttributeSet attrs;
|
||||
llvm::AttributeSet old = func->getAttributes();
|
||||
llvm::AttributeSet existingAttrs[] = { old.getFnAttributes(), old.getRetAttributes() };
|
||||
llvm::AttributeSet newAttrs = llvm::AttributeSet::get(gIR->context(), existingAttrs);
|
||||
|
||||
int idx = 0;
|
||||
|
||||
// handle implicit args
|
||||
|
@ -560,7 +563,7 @@ static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclarati
|
|||
if (f->fty.X) { \
|
||||
if (f->fty.X->attrs.hasAttributes()) { \
|
||||
llvm::AttributeSet a = llvm::AttributeSet::get(gIR->context(), idx, f->fty.X->attrs); \
|
||||
attrs = attrs.addAttributes(gIR->context(), idx, a); \
|
||||
newAttrs = newAttrs.addAttributes(gIR->context(), idx, a); \
|
||||
} \
|
||||
idx++; \
|
||||
}
|
||||
|
@ -586,20 +589,12 @@ static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclarati
|
|||
{
|
||||
unsigned i = idx + (f->fty.reverseParams ? n-k-1 : k);
|
||||
llvm::AttributeSet as = llvm::AttributeSet::get(gIR->context(), i, a);
|
||||
attrs = attrs.addAttributes(gIR->context(), i, as);
|
||||
newAttrs = newAttrs.addAttributes(gIR->context(), i, as);
|
||||
}
|
||||
}
|
||||
|
||||
// Merge in any old attributes (attributes for the function itself are
|
||||
// also stored in a list slot).
|
||||
llvm::AttributeSet oldAttrs = func->getAttributes();
|
||||
for (size_t i = 0; i < oldAttrs.getNumSlots(); ++i) {
|
||||
attrs.addAttributes(gIR->context(), oldAttrs.getSlotIndex(i),
|
||||
oldAttrs.getSlotAttributes(i));
|
||||
}
|
||||
|
||||
// Store the final attribute set
|
||||
func->setAttributes(attrs);
|
||||
func->setAttributes(newAttrs);
|
||||
}
|
||||
#else
|
||||
static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclaration* fdecl)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue