LLVM: lib/Transforms/Utils/FunctionComparator.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
43#include
44#include
45#include
46#include
47
48using namespace llvm;
49
50#define DEBUG_TYPE "functioncomparator"
51
53 if (L < R)
54 return -1;
55 if (L > R)
56 return 1;
57 return 0;
58}
59
61 if (L.value() < R.value())
62 return -1;
63 if (L.value() > R.value())
64 return 1;
65 return 0;
66}
67
69 if ((int)L < (int)R)
70 return -1;
71 if ((int)L > (int)R)
72 return 1;
73 return 0;
74}
75
77 if (int Res = cmpNumbers(L.getBitWidth(), R.getBitWidth()))
78 return Res;
79 if (L.ugt(R))
80 return 1;
81 if (R.ugt(L))
82 return -1;
83 return 0;
84}
85
88 if (int Res = cmpAPInts(L.getLower(), R.getLower()))
89 return Res;
90 return cmpAPInts(L.getUpper(), R.getUpper());
91}
92
94
95
96 const fltSemantics &SL = L.getSemantics(), &SR = R.getSemantics();
99 return Res;
102 return Res;
105 return Res;
108 return Res;
109 return cmpAPInts(L.bitcastToAPInt(), R.bitcastToAPInt());
110}
111
113
114 if (int Res = cmpNumbers(L.size(), R.size()))
115 return Res;
116
117
118
119 return std::clamp(L.compare(R), -1, 1);
120}
121
122int FunctionComparator::cmpAttrs(const AttributeList L,
124 if (int Res = cmpNumbers(L.getNumAttrSets(), R.getNumAttrSets()))
125 return Res;
126
127 for (unsigned i : L.indexes()) {
132 for (; LI != LE && RI != RE; ++LI, ++RI) {
138
140 Type *TyR = RA.getValueAsType();
141 if (TyL && TyR) {
142 if (int Res = cmpTypes(TyL, TyR))
143 return Res;
144 continue;
145 }
146
147
148
150 return Res;
151 continue;
153 RA.isConstantRangeAttribute()) {
156
158 return Res;
159 continue;
161 RA.isConstantRangeListAttribute()) {
164
168 return Res;
169
170 for (const auto &[L, R] : zip(CRL, CRR))
172 return Res;
173 continue;
174 }
175 if (LA < RA)
176 return -1;
177 if (RA < LA)
178 return 1;
179 }
180 if (LI != LE)
181 return 1;
182 if (RI != RE)
183 return -1;
184 }
185 return 0;
186}
187
188int FunctionComparator::cmpMetadata(const Metadata *L,
190
191
192
193
194
195
196 auto *MDStringL = dyn_cast(L);
197 auto *MDStringR = dyn_cast(R);
198 if (MDStringL && MDStringR) {
199 if (MDStringL == MDStringR)
200 return 0;
201 return MDStringL->getString().compare(MDStringR->getString());
202 }
203 if (MDStringR)
204 return -1;
205 if (MDStringL)
206 return 1;
207
208 auto *CL = dyn_cast(L);
209 auto *CR = dyn_cast(R);
210 if (CL == CR)
211 return 0;
212 if (!CL)
213 return -1;
214 if (!CR)
215 return 1;
216 return cmpConstants(CL->getValue(), CR->getValue());
217}
218
219int FunctionComparator::cmpMDNode(const MDNode *L, const MDNode *R) const {
220 if (L == R)
221 return 0;
222 if (!L)
223 return -1;
224 if (!R)
225 return 1;
226
227
228
229
230
231
232 if (int Res = cmpNumbers(L->getNumOperands(), R->getNumOperands()))
233 return Res;
234 for (size_t I = 0; I < L->getNumOperands(); ++I)
235 if (int Res = cmpMetadata(L->getOperand(I), R->getOperand(I)))
236 return Res;
237 return 0;
238}
239
240int FunctionComparator::cmpInstMetadata(Instruction const *L,
242
243
244
246 L->getAllMetadataOtherThanDebugLoc(MDL);
247 R->getAllMetadataOtherThanDebugLoc(MDR);
249 return 1;
250 else if (MDL.size() < MDR.size())
251 return -1;
252 for (size_t I = 0, N = MDL.size(); I < N; ++I) {
253 auto const [KeyL, ML] = MDL[I];
254 auto const [KeyR, MR] = MDR[I];
255 if (int Res = cmpNumbers(KeyL, KeyR))
256 return Res;
257 if (int Res = cmpMDNode(ML, MR))
258 return Res;
259 }
260 return 0;
261}
262
263int FunctionComparator::cmpOperandBundlesSchema(const CallBase &LCS,
266
267 if (int Res =
269 return Res;
270
274
275 if (int Res = OBL.getTagName().compare(OBR.getTagName()))
276 return Res;
277
278 if (int Res = cmpNumbers(OBL.Inputs.size(), OBR.Inputs.size()))
279 return Res;
280 }
281
282 return 0;
283}
284
285
286
287
288
289
292 Type *TyL = L->getType();
293 Type *TyR = R->getType();
294
295
296
297
298 int TypesRes = cmpTypes(TyL, TyR);
299 if (TypesRes != 0) {
300
303 return -1;
304
305
306 return TypesRes;
307 }
310 return 1;
311 return TypesRes;
312 }
313
314
315
316 unsigned TyLWidth = 0;
317 unsigned TyRWidth = 0;
318
319 if (auto *VecTyL = dyn_cast(TyL))
320 TyLWidth = VecTyL->getPrimitiveSizeInBits().getFixedValue();
321 if (auto *VecTyR = dyn_cast(TyR))
322 TyRWidth = VecTyR->getPrimitiveSizeInBits().getFixedValue();
323
324 if (TyLWidth != TyRWidth)
325 return cmpNumbers(TyLWidth, TyRWidth);
326
327
328 if (!TyLWidth) {
329 PointerType *PTyL = dyn_cast(TyL);
330 PointerType *PTyR = dyn_cast(TyR);
331 if (PTyL && PTyR) {
334 if (int Res = cmpNumbers(AddrSpaceL, AddrSpaceR))
335 return Res;
336 }
337 if (PTyL)
338 return 1;
339 if (PTyR)
340 return -1;
341
342
343
344 return TypesRes;
345 }
346 }
347
348
349
350 if (L->isNullValue() && R->isNullValue())
351 return TypesRes;
352 if (L->isNullValue() && !R->isNullValue())
353 return 1;
354 if (!L->isNullValue() && R->isNullValue())
355 return -1;
356
357 auto GlobalValueL = const_cast<GlobalValue *>(dyn_cast(L));
358 auto GlobalValueR = const_cast<GlobalValue *>(dyn_cast(R));
359 if (GlobalValueL && GlobalValueR) {
361 }
362
363 if (int Res = cmpNumbers(L->getValueID(), R->getValueID()))
364 return Res;
365
366 if (const auto *SeqL = dyn_cast(L)) {
367 const auto *SeqR = cast(R);
368
369
370
371
372
373 return cmpMem(SeqL->getRawDataValues(), SeqR->getRawDataValues());
374 }
375
376 switch (L->getValueID()) {
377 case Value::UndefValueVal:
378 case Value::PoisonValueVal:
379 case Value::ConstantTokenNoneVal:
380 return TypesRes;
381 case Value::ConstantIntVal: {
382 const APInt &LInt = cast(L)->getValue();
383 const APInt &RInt = cast(R)->getValue();
385 }
386 case Value::ConstantFPVal: {
387 const APFloat &LAPF = cast(L)->getValueAPF();
388 const APFloat &RAPF = cast(R)->getValueAPF();
390 }
391 case Value::ConstantArrayVal: {
392 const ConstantArray *LA = cast(L);
394 uint64_t NumElementsL = cast(TyL)->getNumElements();
395 uint64_t NumElementsR = cast(TyR)->getNumElements();
396 if (int Res = cmpNumbers(NumElementsL, NumElementsR))
397 return Res;
398 for (uint64_t i = 0; i < NumElementsL; ++i) {
400 cast(RA->getOperand(i))))
401 return Res;
402 }
403 return 0;
404 }
405 case Value::ConstantStructVal: {
408 unsigned NumElementsL = cast(TyL)->getNumElements();
409 unsigned NumElementsR = cast(TyR)->getNumElements();
410 if (int Res = cmpNumbers(NumElementsL, NumElementsR))
411 return Res;
412 for (unsigned i = 0; i != NumElementsL; ++i) {
413 if (int Res = cmpConstants(cast(LS->getOperand(i)),
415 return Res;
416 }
417 return 0;
418 }
419 case Value::ConstantVectorVal: {
422 unsigned NumElementsL = cast(TyL)->getNumElements();
423 unsigned NumElementsR = cast(TyR)->getNumElements();
424 if (int Res = cmpNumbers(NumElementsL, NumElementsR))
425 return Res;
426 for (uint64_t i = 0; i < NumElementsL; ++i) {
429 return Res;
430 }
431 return 0;
432 }
433 case Value::ConstantExprVal: {
434 const ConstantExpr *LE = cast(L);
435 const ConstantExpr *RE = cast(R);
437 return Res;
438 unsigned NumOperandsL = LE->getNumOperands();
440 if (int Res = cmpNumbers(NumOperandsL, NumOperandsR))
441 return Res;
442 for (unsigned i = 0; i < NumOperandsL; ++i) {
443 if (int Res = cmpConstants(cast(LE->getOperand(i)),
445 return Res;
446 }
447 if (auto *GEPL = dyn_cast(LE)) {
448 auto *GEPR = cast(RE);
449 if (int Res = cmpTypes(GEPL->getSourceElementType(),
450 GEPR->getSourceElementType()))
451 return Res;
452 if (int Res = cmpNumbers(GEPL->getNoWrapFlags().getRaw(),
453 GEPR->getNoWrapFlags().getRaw()))
454 return Res;
455
456 std::optional InRangeL = GEPL->getInRange();
457 std::optional InRangeR = GEPR->getInRange();
458 if (InRangeL) {
459 if (!InRangeR)
460 return 1;
462 return Res;
463 } else if (InRangeR) {
464 return -1;
465 }
466 }
467 if (auto *OBOL = dyn_cast(LE)) {
468 auto *OBOR = cast(RE);
469 if (int Res =
470 cmpNumbers(OBOL->hasNoUnsignedWrap(), OBOR->hasNoUnsignedWrap()))
471 return Res;
472 if (int Res =
473 cmpNumbers(OBOL->hasNoSignedWrap(), OBOR->hasNoSignedWrap()))
474 return Res;
475 }
476 return 0;
477 }
478 case Value::BlockAddressVal: {
479 const BlockAddress *LBA = cast(L);
480 const BlockAddress *RBA = cast(R);
482 return Res;
484
485
489 if (LBB == RBB)
490 return 0;
492 if (&BB == LBB) {
494 return -1;
495 }
496 if (&BB == RBB)
497 return 1;
498 }
499 llvm_unreachable("Basic Block Address does not point to a basic block in "
500 "its function.");
501 return -1;
502 } else {
503
504
505
507
508
510 }
511 }
512 case Value::DSOLocalEquivalentVal: {
513
514
515
516
517 const auto *LEquiv = cast(L);
518 const auto *REquiv = cast(R);
519 return cmpGlobalValues(LEquiv->getGlobalValue(), REquiv->getGlobalValue());
520 }
521 default:
522 LLVM_DEBUG(dbgs() << "Looking at valueID " << L->getValueID() << "\n");
524 return -1;
525 }
526}
527
532}
533
534
535
536
538 PointerType *PTyL = dyn_cast(TyL);
539 PointerType *PTyR = dyn_cast(TyR);
540
543 TyL = DL.getIntPtrType(TyL);
545 TyR = DL.getIntPtrType(TyR);
546
547 if (TyL == TyR)
548 return 0;
549
551 return Res;
552
554 default:
559
569 return 0;
570
572 assert(PTyL && PTyR && "Both types must be pointers here.");
574
576 StructType *STyL = cast(TyL);
577 StructType *STyR = cast(TyR);
580
583
584 for (unsigned i = 0, e = STyL->getNumElements(); i != e; ++i) {
586 return Res;
587 }
588 return 0;
589 }
590
592 FunctionType *FTyL = cast(TyL);
593 FunctionType *FTyR = cast(TyR);
596
599
601 return Res;
602
603 for (unsigned i = 0, e = FTyL->getNumParams(); i != e; ++i) {
605 return Res;
606 }
607 return 0;
608 }
609
611 auto *STyL = cast(TyL);
612 auto *STyR = cast(TyR);
613 if (STyL->getNumElements() != STyR->getNumElements())
614 return cmpNumbers(STyL->getNumElements(), STyR->getNumElements());
615 return cmpTypes(STyL->getElementType(), STyR->getElementType());
616 }
619 auto *STyL = cast(TyL);
620 auto *STyR = cast(TyR);
621 if (STyL->getElementCount().isScalable() !=
622 STyR->getElementCount().isScalable())
623 return cmpNumbers(STyL->getElementCount().isScalable(),
624 STyR->getElementCount().isScalable());
625 if (STyL->getElementCount() != STyR->getElementCount())
626 return cmpNumbers(STyL->getElementCount().getKnownMinValue(),
627 STyR->getElementCount().getKnownMinValue());
628 return cmpTypes(STyL->getElementType(), STyR->getElementType());
629 }
630 }
631}
632
633
634
635
636
639 bool &needToCmpOperands) const {
640 needToCmpOperands = true;
642 return Res;
643
644
645
646
647
648 if (int Res = cmpNumbers(L->getOpcode(), R->getOpcode()))
649 return Res;
650
651 if (const GetElementPtrInst *GEPL = dyn_cast(L)) {
652 needToCmpOperands = false;
654 if (int Res =
656 return Res;
657 return cmpGEPs(GEPL, GEPR);
658 }
659
660 if (int Res = cmpNumbers(L->getNumOperands(), R->getNumOperands()))
661 return Res;
662
663 if (int Res = cmpTypes(L->getType(), R->getType()))
664 return Res;
665
666 if (int Res = cmpNumbers(L->getRawSubclassOptionalData(),
667 R->getRawSubclassOptionalData()))
668 return Res;
669
670
671
672 for (unsigned i = 0, e = L->getNumOperands(); i != e; ++i) {
673 if (int Res =
674 cmpTypes(L->getOperand(i)->getType(), R->getOperand(i)->getType()))
675 return Res;
676 }
677
678
679 if (const AllocaInst *AI = dyn_cast(L)) {
680 if (int Res = cmpTypes(AI->getAllocatedType(),
681 cast(R)->getAllocatedType()))
682 return Res;
683 return cmpAligns(AI->getAlign(), cast(R)->getAlign());
684 }
685 if (const LoadInst *LI = dyn_cast(L)) {
686 if (int Res = cmpNumbers(LI->isVolatile(), cast(R)->isVolatile()))
687 return Res;
688 if (int Res = cmpAligns(LI->getAlign(), cast(R)->getAlign()))
689 return Res;
690 if (int Res =
691 cmpOrderings(LI->getOrdering(), cast(R)->getOrdering()))
692 return Res;
693 if (int Res = cmpNumbers(LI->getSyncScopeID(),
694 cast(R)->getSyncScopeID()))
695 return Res;
696 return cmpInstMetadata(L, R);
697 }
698 if (const StoreInst *SI = dyn_cast(L)) {
699 if (int Res =
700 cmpNumbers(SI->isVolatile(), cast(R)->isVolatile()))
701 return Res;
702 if (int Res = cmpAligns(SI->getAlign(), cast(R)->getAlign()))
703 return Res;
704 if (int Res =
705 cmpOrderings(SI->getOrdering(), cast(R)->getOrdering()))
706 return Res;
707 return cmpNumbers(SI->getSyncScopeID(),
708 cast(R)->getSyncScopeID());
709 }
710 if (const CmpInst *CI = dyn_cast(L))
711 return cmpNumbers(CI->getPredicate(), cast(R)->getPredicate());
712 if (auto *CBL = dyn_cast(L)) {
713 auto *CBR = cast(R);
714 if (int Res = cmpNumbers(CBL->getCallingConv(), CBR->getCallingConv()))
715 return Res;
716 if (int Res = cmpAttrs(CBL->getAttributes(), CBR->getAttributes()))
717 return Res;
718 if (int Res = cmpOperandBundlesSchema(*CBL, *CBR))
719 return Res;
720 if (const CallInst *CI = dyn_cast(L))
721 if (int Res = cmpNumbers(CI->getTailCallKind(),
722 cast(R)->getTailCallKind()))
723 return Res;
724 return cmpMDNode(L->getMetadata(LLVMContext::MD_range),
725 R->getMetadata(LLVMContext::MD_range));
726 }
727 if (const InsertValueInst *IVI = dyn_cast(L)) {
729 ArrayRef RIndices = cast(R)->getIndices();
731 return Res;
732 for (size_t i = 0, e = LIndices.size(); i != e; ++i) {
733 if (int Res = cmpNumbers(LIndices[i], RIndices[i]))
734 return Res;
735 }
736 return 0;
737 }
738 if (const ExtractValueInst *EVI = dyn_cast(L)) {
740 ArrayRef RIndices = cast(R)->getIndices();
742 return Res;
743 for (size_t i = 0, e = LIndices.size(); i != e; ++i) {
744 if (int Res = cmpNumbers(LIndices[i], RIndices[i]))
745 return Res;
746 }
747 }
748 if (const FenceInst *FI = dyn_cast(L)) {
749 if (int Res =
750 cmpOrderings(FI->getOrdering(), cast(R)->getOrdering()))
751 return Res;
752 return cmpNumbers(FI->getSyncScopeID(),
753 cast(R)->getSyncScopeID());
754 }
755 if (const AtomicCmpXchgInst *CXI = dyn_cast(L)) {
756 if (int Res = cmpNumbers(CXI->isVolatile(),
757 cast(R)->isVolatile()))
758 return Res;
759 if (int Res =
760 cmpNumbers(CXI->isWeak(), cast(R)->isWeak()))
761 return Res;
762 if (int Res =
763 cmpOrderings(CXI->getSuccessOrdering(),
764 cast(R)->getSuccessOrdering()))
765 return Res;
766 if (int Res =
767 cmpOrderings(CXI->getFailureOrdering(),
768 cast(R)->getFailureOrdering()))
769 return Res;
770 return cmpNumbers(CXI->getSyncScopeID(),
771 cast(R)->getSyncScopeID());
772 }
773 if (const AtomicRMWInst *RMWI = dyn_cast(L)) {
774 if (int Res = cmpNumbers(RMWI->getOperation(),
775 cast(R)->getOperation()))
776 return Res;
777 if (int Res = cmpNumbers(RMWI->isVolatile(),
778 cast(R)->isVolatile()))
779 return Res;
780 if (int Res = cmpOrderings(RMWI->getOrdering(),
781 cast(R)->getOrdering()))
782 return Res;
783 return cmpNumbers(RMWI->getSyncScopeID(),
784 cast(R)->getSyncScopeID());
785 }
786 if (const ShuffleVectorInst *SVI = dyn_cast(L)) {
788 ArrayRef RMask = cast(R)->getShuffleMask();
790 return Res;
791 for (size_t i = 0, e = LMask.size(); i != e; ++i) {
792 if (int Res = cmpNumbers(LMask[i], RMask[i]))
793 return Res;
794 }
795 }
796 if (const PHINode *PNL = dyn_cast(L)) {
797 const PHINode *PNR = cast(R);
798
799
800
801 for (unsigned i = 0, e = PNL->getNumIncomingValues(); i != e; ++i) {
802 if (int Res =
804 return Res;
805 }
806 }
807 return 0;
808}
809
810
811
812int FunctionComparator::cmpGEPs(const GEPOperator *GEPL,
816
818 return Res;
819
820
821
823 unsigned OffsetBitWidth = DL.getIndexSizeInBits(ASL);
824 APInt OffsetL(OffsetBitWidth, 0), OffsetR(OffsetBitWidth, 0);
827 return cmpAPInts(OffsetL, OffsetR);
828 if (int Res =
830 return Res;
831
833 return Res;
834
835 for (unsigned i = 0, e = GEPL->getNumOperands(); i != e; ++i) {
837 return Res;
838 }
839
840 return 0;
841}
842
843int FunctionComparator::cmpInlineAsm(const InlineAsm *L,
845
846
847 if (L == R)
848 return 0;
849 if (int Res = cmpTypes(L->getFunctionType(), R->getFunctionType()))
850 return Res;
851 if (int Res = cmpMem(L->getAsmString(), R->getAsmString()))
852 return Res;
853 if (int Res = cmpMem(L->getConstraintString(), R->getConstraintString()))
854 return Res;
855 if (int Res = cmpNumbers(L->hasSideEffects(), R->hasSideEffects()))
856 return Res;
857 if (int Res = cmpNumbers(L->isAlignStack(), R->isAlignStack()))
858 return Res;
859 if (int Res = cmpNumbers(L->getDialect(), R->getDialect()))
860 return Res;
861 assert(L->getFunctionType() != R->getFunctionType());
862 return 0;
863}
864
865
866
867
868
870
871 if (L == FnL) {
872 if (R == FnR)
873 return 0;
874 return -1;
875 }
876 if (R == FnR) {
877 if (L == FnL)
878 return 0;
879 return 1;
880 }
881
882 const Constant *ConstL = dyn_cast(L);
883 const Constant *ConstR = dyn_cast(R);
884 if (ConstL && ConstR) {
885 if (L == R)
886 return 0;
888 }
889
890 if (ConstL)
891 return 1;
892 if (ConstR)
893 return -1;
894
895 const MetadataAsValue *MetadataValueL = dyn_cast(L);
896 const MetadataAsValue *MetadataValueR = dyn_cast(R);
897 if (MetadataValueL && MetadataValueR) {
898 if (MetadataValueL == MetadataValueR)
899 return 0;
900
901 return cmpMetadata(MetadataValueL->getMetadata(),
903 }
904
905 if (MetadataValueL)
906 return 1;
907 if (MetadataValueR)
908 return -1;
909
910 const InlineAsm *InlineAsmL = dyn_cast(L);
911 const InlineAsm *InlineAsmR = dyn_cast(R);
912
913 if (InlineAsmL && InlineAsmR)
914 return cmpInlineAsm(InlineAsmL, InlineAsmR);
915 if (InlineAsmL)
916 return 1;
917 if (InlineAsmR)
918 return -1;
919
920 auto LeftSN = sn_mapL.insert(std::make_pair(L, sn_mapL.size())),
921 RightSN = sn_mapR.insert(std::make_pair(R, sn_mapR.size()));
922
923 return cmpNumbers(LeftSN.first->second, RightSN.first->second);
924}
925
926
931
932 do {
933 bool needToCmpOperands = true;
934 if (int Res = cmpOperations(&*InstL, &*InstR, needToCmpOperands))
935 return Res;
936 if (needToCmpOperands) {
937 assert(InstL->getNumOperands() == InstR->getNumOperands());
938
939 for (unsigned i = 0, e = InstL->getNumOperands(); i != e; ++i) {
940 Value *OpL = InstL->getOperand(i);
941 Value *OpR = InstR->getOperand(i);
942 if (int Res = cmpValues(OpL, OpR))
943 return Res;
944
946 }
947 }
948
949 ++InstL;
950 ++InstR;
951 } while (InstL != InstLE && InstR != InstRE);
952
953 if (InstL != InstLE && InstR == InstRE)
954 return 1;
955 if (InstL == InstLE && InstR != InstRE)
956 return -1;
957 return 0;
958}
959
962 return Res;
963
965 return Res;
966
969 return Res;
970 }
971
973 return Res;
974
977 return Res;
978 }
979
981 return Res;
982
983
984
986 return Res;
987
989 return Res;
990
992 "Identically typed functions have different numbers of args!");
993
994
995
999 ArgLI != ArgLE; ++ArgLI, ++ArgRI) {
1000 if (cmpValues(&*ArgLI, &*ArgRI) != 0)
1002 }
1003 return 0;
1004}
1005
1006
1009
1011 return Res;
1012
1013
1014
1015
1016
1019
1022
1023 VisitedBBs.insert(FnLBBs[0]);
1024 while (!FnLBBs.empty()) {
1027
1028 if (int Res = cmpValues(BBL, BBR))
1029 return Res;
1030
1032 return Res;
1033
1036
1038 for (unsigned i = 0, e = TermL->getNumSuccessors(); i != e; ++i) {
1040 continue;
1041
1044 }
1045 }
1046 return 0;
1047}
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the simple types necessary to represent the attributes associated with functions a...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Module.h This file contains the declarations for the Module class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SI optimize exec mask operations pre RA
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
Class for arbitrary precision integers.
an instruction to allocate memory on the stack
This class represents an incoming formal argument to a Function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
An instruction that atomically checks whether a specified value is in a memory location,...
an instruction that atomically reads a memory location, combines it with another value,...
const ConstantRange & getRange() const
Returns the value of the range attribute.
bool isConstantRangeAttribute() const
Return true if the attribute is a ConstantRange attribute.
Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
ArrayRef< ConstantRange > getValueAsConstantRangeList() const
Return the attribute's value as a ConstantRange array.
bool isTypeAttribute() const
Return true if the attribute is a type attribute.
bool isConstantRangeListAttribute() const
Return true if the attribute is a ConstantRangeList attribute.
Type * getValueAsType() const
Return the attribute's value as a Type.
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
InstListType::const_iterator const_iterator
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
The address of a basic block.
Function * getFunction() const
BasicBlock * getBasicBlock() const
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
OperandBundleUse getOperandBundleAt(unsigned Index) const
Return the operand bundle at a specific index.
unsigned getNumOperandBundles() const
Return the number of operand bundles associated with this User.
This class represents a function call, abstracting a target machine's calling convention.
This class is the base class for the comparison instructions.
ConstantArray - Constant Array Declarations.
A constant value that is initialized with an expression using other constant values.
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
This class represents a range of values.
Constant Vector Declarations.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
An instruction for ordering other memory operations.
int cmpBasicBlocks(const BasicBlock *BBL, const BasicBlock *BBR) const
Test whether two basic blocks have equivalent behaviour.
int cmpConstantRanges(const ConstantRange &L, const ConstantRange &R) const
int compareSignature() const
Compares the signature and other general attributes of the two functions.
int cmpMem(StringRef L, StringRef R) const
int compare()
Test whether the two functions have equivalent behaviour.
int cmpAPFloats(const APFloat &L, const APFloat &R) const
int cmpTypes(Type *TyL, Type *TyR) const
cmpType - compares two types, defines total ordering among the types set.
int cmpOperations(const Instruction *L, const Instruction *R, bool &needToCmpOperands) const
Compare two Instructions for equivalence, similar to Instruction::isSameOperationAs.
int cmpNumbers(uint64_t L, uint64_t R) const
int cmpAligns(Align L, Align R) const
void beginCompare()
Start the comparison.
int cmpValues(const Value *L, const Value *R) const
Assign or look up previously assigned numbers for the two values, and return whether the numbers are ...
int cmpGlobalValues(GlobalValue *L, GlobalValue *R) const
Compares two global values by number.
int cmpConstants(const Constant *L, const Constant *R) const
Constants comparison.
int cmpAPInts(const APInt &L, const APInt &R) const
Class to represent function types.
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
Type * getParamType(unsigned i) const
Parameter type accessors.
Type * getReturnType() const
const BasicBlock & getEntryBlock() const
FunctionType * getFunctionType() const
Returns the FunctionType for me.
const DataLayout & getDataLayout() const
Get the data layout of the module this function belongs to.
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
AttributeList getAttributes() const
Return the attribute list for this Function.
const std::string & getGC() const
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
Type * getSourceElementType() const
bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset, function_ref< bool(Value &, APInt &)> ExternalAnalysis=nullptr) const
Accumulate the constant address offset of this GEP if possible.
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
Value * getPointerOperand()
uint64_t getNumber(GlobalValue *Global)
StringRef getSection() const
Get the custom section of this global if it has one.
bool hasSection() const
Check if this global has a custom object file section.
This instruction inserts a struct field of array element value into an aggregate value.
unsigned getNumSuccessors() const LLVM_READONLY
Return the number of successors that this instruction has.
BasicBlock * getSuccessor(unsigned Idx) const LLVM_READONLY
Return the specified successor. This instruction must be a terminator.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
An instruction for reading from memory.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Class to represent pointers.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
This instruction constructs a fixed permutation of two input vectors.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
StringRef - Represent a constant reference to a string, i.e.
Class to represent struct types.
unsigned getNumElements() const
Random access to the elements.
Type * getElementType(unsigned N) const
The instances of the Type class are immutable: once they are created, they are never changed.
@ VoidTyID
type with no size
@ ScalableVectorTyID
Scalable SIMD vector type.
@ FloatTyID
32-bit floating point type
@ IntegerTyID
Arbitrary bit width integers.
@ FixedVectorTyID
Fixed width SIMD vector type.
@ DoubleTyID
64-bit floating point type
@ X86_FP80TyID
80-bit floating point type (X87)
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
@ FP128TyID
128-bit floating point type (112-bit significand)
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value.
TypeID getTypeID() const
Return the type id for the type.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
detail::zippy< detail::zip_shortest, T, U, Args... > zip(T &&t, U &&u, Args &&...args)
zip iterator for two or more iteratable types.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
AtomicOrdering
Atomic ordering for LLVM's memory model.
static ExponentType semanticsMinExponent(const fltSemantics &)
static unsigned int semanticsSizeInBits(const fltSemantics &)
static ExponentType semanticsMaxExponent(const fltSemantics &)
static unsigned int semanticsPrecision(const fltSemantics &)
This struct is a compact representation of a valid (non-zero power of two) alignment.