mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 11:02:59 +02:00
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
This commit is contained in:
parent
5366cb42f6
commit
215de3da2d
@ -1567,6 +1567,20 @@ static bool isTypeCongruent(Type *L, Type *R) {
|
|||||||
return PL->getAddressSpace() == PR->getAddressSpace();
|
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) {
|
void Verifier::verifyMustTailCall(CallInst &CI) {
|
||||||
Assert1(!CI.isInlineAsm(), "cannot use musttail call with inline asm", &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,
|
// - All ABI-impacting function attributes, such as sret, byval, inreg,
|
||||||
// returned, and inalloca, must match.
|
// 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 CallerAttrs = F->getAttributes();
|
||||||
AttributeSet CalleeAttrs = CI.getAttributes();
|
AttributeSet CalleeAttrs = CI.getAttributes();
|
||||||
for (int I = 0, E = CallerTy->getNumParams(); I != E; ++I) {
|
for (int I = 0, E = CallerTy->getNumParams(); I != E; ++I) {
|
||||||
AttrBuilder CallerABIAttrs;
|
AttrBuilder CallerABIAttrs = getParameterABIAttributes(I, CallerAttrs);
|
||||||
AttrBuilder CalleeABIAttrs;
|
AttrBuilder CalleeABIAttrs = getParameterABIAttributes(I, CalleeAttrs);
|
||||||
for (auto AK : ABIAttrs) {
|
|
||||||
if (CallerAttrs.hasAttribute(I + 1, AK))
|
|
||||||
CallerABIAttrs.addAttribute(AK);
|
|
||||||
if (CalleeAttrs.hasAttribute(I + 1, AK))
|
|
||||||
CalleeABIAttrs.addAttribute(AK);
|
|
||||||
}
|
|
||||||
Assert2(CallerABIAttrs == CalleeABIAttrs,
|
Assert2(CallerABIAttrs == CalleeABIAttrs,
|
||||||
"cannot guarantee tail call due to mismatched ABI impacting "
|
"cannot guarantee tail call due to mismatched ABI impacting "
|
||||||
"function attributes", &CI, CI.getOperand(I));
|
"function attributes", &CI, CI.getOperand(I));
|
||||||
|
@ -60,6 +60,13 @@ define void @mismatched_sret(i32* %a) {
|
|||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare void @mismatched_alignment_callee(i32* byval align 8)
|
||||||
|
define void @mismatched_alignment(i32* byval align 4 %a) {
|
||||||
|
; CHECK: mismatched ABI impacting function attributes
|
||||||
|
musttail call void @mismatched_alignment_callee(i32* byval align 8 %a)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
declare i32 @not_tail_pos_callee()
|
declare i32 @not_tail_pos_callee()
|
||||||
define i32 @not_tail_pos() {
|
define i32 @not_tail_pos() {
|
||||||
; CHECK: musttail call must be precede a ret with an optional bitcast
|
; CHECK: musttail call must be precede a ret with an optional bitcast
|
||||||
|
Loading…
Reference in New Issue
Block a user