diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-05-15 23:58:57 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-05-15 23:58:57 +0000 |
commit | d20c970aaca0d60d9a20c86c9a8c8adc4c13a584 (patch) | |
tree | 79a775b8c0cd2b4e63c43331a91769d134b64879 /llvm/lib/IR/Verifier.cpp | |
parent | 932e1c392426b692d72c71a849ca94a0a20f9cb7 (diff) | |
download | bcm5719-llvm-d20c970aaca0d60d9a20c86c9a8c8adc4c13a584.tar.gz bcm5719-llvm-d20c970aaca0d60d9a20c86c9a8c8adc4c13a584.zip |
musttail: Fix the verification of alignment attributes
Previously this would fail with an assertion failure when trying to add
an alignment attribute without a value.
llvm-svn: 208935
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index ec287f58fa3..ff9ca44f870 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -1567,6 +1567,20 @@ static bool isTypeCongruent(Type *L, Type *R) { return PL->getAddressSpace() == PR->getAddressSpace(); } +static AttrBuilder getParameterABIAttributes(int I, AttributeSet Attrs) { + static const Attribute::AttrKind ABIAttrs[] = { + Attribute::StructRet, Attribute::ByVal, Attribute::InAlloca, + Attribute::InReg, Attribute::Returned}; + AttrBuilder Copy; + for (auto AK : ABIAttrs) { + if (Attrs.hasAttribute(I + 1, AK)) + Copy.addAttribute(AK); + } + if (Attrs.hasAttribute(I + 1, Attribute::Alignment)) + Copy.addAlignmentAttr(Attrs.getParamAlignment(I + 1)); + return Copy; +} + void Verifier::verifyMustTailCall(CallInst &CI) { Assert1(!CI.isInlineAsm(), "cannot use musttail call with inline asm", &CI); @@ -1598,20 +1612,11 @@ void Verifier::verifyMustTailCall(CallInst &CI) { // - All ABI-impacting function attributes, such as sret, byval, inreg, // returned, and inalloca, must match. - static const Attribute::AttrKind ABIAttrs[] = { - Attribute::Alignment, Attribute::StructRet, Attribute::ByVal, - Attribute::InAlloca, Attribute::InReg, Attribute::Returned}; AttributeSet CallerAttrs = F->getAttributes(); AttributeSet CalleeAttrs = CI.getAttributes(); for (int I = 0, E = CallerTy->getNumParams(); I != E; ++I) { - AttrBuilder CallerABIAttrs; - AttrBuilder CalleeABIAttrs; - for (auto AK : ABIAttrs) { - if (CallerAttrs.hasAttribute(I + 1, AK)) - CallerABIAttrs.addAttribute(AK); - if (CalleeAttrs.hasAttribute(I + 1, AK)) - CalleeABIAttrs.addAttribute(AK); - } + AttrBuilder CallerABIAttrs = getParameterABIAttributes(I, CallerAttrs); + AttrBuilder CalleeABIAttrs = getParameterABIAttributes(I, CalleeAttrs); Assert2(CallerABIAttrs == CalleeABIAttrs, "cannot guarantee tail call due to mismatched ABI impacting " "function attributes", &CI, CI.getOperand(I)); |