From f021fab2afdc3d9534dbddcccecf892986b9654b Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Thu, 13 Apr 2017 23:12:13 +0000 Subject: [IR] Make getParamAttributes take argument numbers, not ArgNo+1 Add hasParamAttribute() and use it instead of hasAttribute(ArgNo+1, Kind) everywhere. The fact that the AttributeList index for an argument is ArgNo+1 should be a hidden implementation detail. NFC llvm-svn: 300272 --- .../lib/Target/WebAssembly/WebAssemblyFastISel.cpp | 24 +++++++++++----------- .../WebAssemblyLowerEmscriptenEHSjLj.cpp | 3 +-- 2 files changed, 13 insertions(+), 14 deletions(-) (limited to 'llvm/lib/Target/WebAssembly') diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp index e7fd4ef33e1..53698ff09b1 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp @@ -597,11 +597,11 @@ bool WebAssemblyFastISel::fastLowerArguments() { unsigned i = 0; for (auto const &Arg : F->args()) { const AttributeList &Attrs = F->getAttributes(); - if (Attrs.hasAttribute(i+1, Attribute::ByVal) || - Attrs.hasAttribute(i+1, Attribute::SwiftSelf) || - Attrs.hasAttribute(i+1, Attribute::SwiftError) || - Attrs.hasAttribute(i+1, Attribute::InAlloca) || - Attrs.hasAttribute(i+1, Attribute::Nest)) + if (Attrs.hasParamAttribute(i, Attribute::ByVal) || + Attrs.hasParamAttribute(i, Attribute::SwiftSelf) || + Attrs.hasParamAttribute(i, Attribute::SwiftError) || + Attrs.hasParamAttribute(i, Attribute::InAlloca) || + Attrs.hasParamAttribute(i, Attribute::Nest)) return false; Type *ArgTy = Arg.getType(); @@ -747,18 +747,18 @@ bool WebAssemblyFastISel::selectCall(const Instruction *I) { return false; const AttributeList &Attrs = Call->getAttributes(); - if (Attrs.hasAttribute(i+1, Attribute::ByVal) || - Attrs.hasAttribute(i+1, Attribute::SwiftSelf) || - Attrs.hasAttribute(i+1, Attribute::SwiftError) || - Attrs.hasAttribute(i+1, Attribute::InAlloca) || - Attrs.hasAttribute(i+1, Attribute::Nest)) + if (Attrs.hasParamAttribute(i, Attribute::ByVal) || + Attrs.hasParamAttribute(i, Attribute::SwiftSelf) || + Attrs.hasParamAttribute(i, Attribute::SwiftError) || + Attrs.hasParamAttribute(i, Attribute::InAlloca) || + Attrs.hasParamAttribute(i, Attribute::Nest)) return false; unsigned Reg; - if (Attrs.hasAttribute(i+1, Attribute::SExt)) + if (Attrs.hasParamAttribute(i, Attribute::SExt)) Reg = getRegForSignedValue(V); - else if (Attrs.hasAttribute(i+1, Attribute::ZExt)) + else if (Attrs.hasParamAttribute(i, Attribute::ZExt)) Reg = getRegForUnsignedValue(V); else Reg = getRegForValue(V); diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp index 6af7d107934..947c0329bb6 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp @@ -441,9 +441,8 @@ Value *WebAssemblyLowerEmscriptenEHSjLj::wrapInvoke(CallOrInvoke *CI) { // No attributes for the callee pointer. ArgAttributes.push_back(AttributeSet()); // Copy the argument attributes from the original - for (unsigned i = 1, e = CI->getNumArgOperands(); i <= e; ++i) { + for (unsigned i = 0, e = CI->getNumArgOperands(); i < e; ++i) ArgAttributes.push_back(InvokeAL.getParamAttributes(i)); - } // Reconstruct the AttributesList based on the vector we constructed. AttributeList NewCallAL = -- cgit v1.2.3