Skip to content

Commit 0db0ca3

Browse files
committedApr 12, 2017
[WebAssembly] Update use of Attributes after r299875
This fixes the failing WebAssemblyLowerEmscriptenEHSjLj tests llvm-svn: 300072
1 parent 58e0806 commit 0db0ca3

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed
 

‎llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp

+14-17
Original file line numberDiff line numberDiff line change
@@ -435,26 +435,23 @@ Value *WebAssemblyLowerEmscriptenEHSjLj::wrapInvoke(CallOrInvoke *CI) {
435435

436436
// Because we added the pointer to the callee as first argument, all
437437
// 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+
448441
// 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+
452450
// 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());
455452
// 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);
458455

459456
CI->replaceAllUsesWith(NewCall);
460457

0 commit comments

Comments
 (0)
Please sign in to comment.