@@ -435,26 +435,23 @@ Value *WebAssemblyLowerEmscriptenEHSjLj::wrapInvoke(CallOrInvoke *CI) {
435
435
436
436
// Because we added the pointer to the callee as first argument, all
437
437
// argument attribute indices have to be incremented by one.
438
- SmallVector<AttributeList, 8 > AttributesVec;
439
- const AttributeList &InvokePAL = CI->getAttributes ();
440
- CallSite::arg_iterator AI = CI->arg_begin ();
441
- unsigned i = 1 ; // Argument attribute index starts from 1
442
- for (unsigned e = CI->getNumArgOperands (); i <= e; ++AI, ++i) {
443
- if (InvokePAL.hasAttributes (i)) {
444
- AttrBuilder B (InvokePAL, i);
445
- AttributesVec.push_back (AttributeList::get (C, i + 1 , B));
446
- }
447
- }
438
+ SmallVector<AttributeSet, 8 > AttributesVec;
439
+ const AttributeList &InvokeAL = CI->getAttributes ();
440
+
448
441
// Add any return attributes.
449
- if (InvokePAL.hasAttributes (AttributeList::ReturnIndex))
450
- AttributesVec.push_back (
451
- AttributeList::get (C, InvokePAL.getRetAttributes ()));
442
+ AttributesVec.push_back (InvokeAL.getRetAttributes ());
443
+ // No attributes for the callee pointer.
444
+ AttributesVec.push_back (AttributeSet ());
445
+ // Copy the argument attributes from the original
446
+ for (unsigned i = 1 , e = CI->getNumArgOperands (); i <= e; ++i) {
447
+ AttributesVec.push_back (InvokeAL.getParamAttributes (i));
448
+ }
449
+
452
450
// Add any function attributes.
453
- if (InvokePAL.hasAttributes (AttributeList::FunctionIndex))
454
- AttributesVec.push_back (AttributeList::get (C, InvokePAL.getFnAttributes ()));
451
+ AttributesVec.push_back (InvokeAL.getFnAttributes ());
455
452
// Reconstruct the AttributesList based on the vector we constructed.
456
- AttributeList NewCallPAL = AttributeList::get (C, AttributesVec);
457
- NewCall->setAttributes (NewCallPAL );
453
+ AttributeList NewCallAL = AttributeList::get (C, AttributesVec);
454
+ NewCall->setAttributes (NewCallAL );
458
455
459
456
CI->replaceAllUsesWith (NewCall);
460
457
0 commit comments