llvm.org GIT mirror llvm / b57b170
Fix target specific intrinsic handling to adjust intrinsic number before doing attribute table lookup. Also fix attribute table lookup to handle 'invalid' intrinsic correctly. Fixes PR12542 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154658 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 8 years ago
1 changed file(s) with 18 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
536536 // at least one entry, for the function itself (index ~1), which is
537537 // usually nounwind.
538538 OS << " static const uint8_t IntrinsicsToAttributesMap[] = {\n";
539 OS << " 255, // Invalid intrinsic\n";
540539
541540 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
542541 const CodeGenIntrinsic &intrinsic = Ints[i];
548547
549548 OS << " AttributeWithIndex AWI[" << maxArgAttrs+1 << "];\n";
550549 OS << " unsigned NumAttrs = 0;\n";
551 OS << " switch(IntrinsicsToAttributesMap[id]) {\n";
552 OS << " default: llvm_unreachable(\"Invalid attribute number\");\n";
550 OS << " if (id != 0) {\n";
551 OS << " switch(IntrinsicsToAttributesMap[id - ";
552 if (TargetOnly)
553 OS << "Intrinsic::num_intrinsics";
554 else
555 OS << "1";
556 OS << "]) {\n";
557 OS << " default: llvm_unreachable(\"Invalid attribute number\");\n";
553558 for (UniqAttrMapTy::const_iterator I = UniqAttributes.begin(),
554559 E = UniqAttributes.end(); I != E; ++I) {
555 OS << " case " << I->second << ":\n";
560 OS << " case " << I->second << ":\n";
556561
557562 const CodeGenIntrinsic &intrinsic = *(I->first);
558563
563568 for (unsigned ai = 0, ae = intrinsic.ArgumentAttributes.size(); ai != ae;) {
564569 unsigned argNo = intrinsic.ArgumentAttributes[ai].first;
565570
566 OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get("
571 OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get("
567572 << argNo+1 << ", ";
568573
569574 bool moreThanOne = false;
587592 ModRefKind modRef = getModRefKind(intrinsic);
588593
589594 if (!intrinsic.canThrow || modRef) {
590 OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(~0, ";
595 OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(~0, ";
591596 if (!intrinsic.canThrow) {
592597 OS << "Attribute::NoUnwind";
593598 if (modRef) OS << '|';
601606 }
602607
603608 if (numAttrs) {
604 OS << " NumAttrs = " << numAttrs << ";\n";
605 OS << " break;\n";
609 OS << " NumAttrs = " << numAttrs << ";\n";
610 OS << " break;\n";
606611 } else {
607 OS << " return AttrListPtr();\n";
608 }
609 }
610
612 OS << " return AttrListPtr();\n";
613 }
614 }
615
616 OS << " }\n";
611617 OS << " }\n";
612618 OS << " return AttrListPtr::get(AWI, NumAttrs);\n";
613619 OS << "}\n";