@@ -564,6 +564,24 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
564
564
BasicBlock::iterator FromBeginIt,
565
565
BasicBlock::iterator FromEndIt);
566
566
567
+ enum {
568
+ HasAddressTaken = 1 << 0 ,
569
+ InstrOrderValid = 1 << 1 ,
570
+ };
571
+
572
+ void setHasAddressTaken (bool B) {
573
+ if (B)
574
+ SubclassOptionalData |= HasAddressTaken;
575
+ else
576
+ SubclassOptionalData &= ~HasAddressTaken;
577
+ }
578
+
579
+ // / Shadow Value::setValueSubclassData with a private forwarding method so
580
+ // / that any future subclasses cannot accidentally use it.
581
+ void setValueSubclassData (unsigned short D) {
582
+ Value::setValueSubclassData (D);
583
+ }
584
+
567
585
public:
568
586
// / Returns a pointer to the symbol table if one exists.
569
587
ValueSymbolTable *getValueSymbolTable ();
@@ -669,7 +687,7 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
669
687
// / Returns true if there are any uses of this basic block other than
670
688
// / direct branches, switches, etc. to it.
671
689
bool hasAddressTaken () const {
672
- return getBasicBlockBits (). BlockAddressRefCount != 0 ;
690
+ return SubclassOptionalData & HasAddressTaken ;
673
691
}
674
692
675
693
// / Update all phi nodes in this basic block to refer to basic block \p New
@@ -711,15 +729,13 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
711
729
712
730
// / Returns true if the Order field of child Instructions is valid.
713
731
bool isInstrOrderValid () const {
714
- return getBasicBlockBits (). InstrOrderValid ;
732
+ return SubclassOptionalData & InstrOrderValid;
715
733
}
716
734
717
735
// / Mark instruction ordering invalid. Done on every instruction insert.
718
736
void invalidateOrders () {
719
737
validateInstrOrdering ();
720
- BasicBlockBits Bits = getBasicBlockBits ();
721
- Bits.InstrOrderValid = false ;
722
- setBasicBlockBits (Bits);
738
+ SubclassOptionalData &= ~InstrOrderValid;
723
739
}
724
740
725
741
// / Renumber instructions and mark the ordering as valid.
@@ -734,63 +750,6 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
734
750
// / each ordering to ensure that transforms have the same algorithmic
735
751
// / complexity when asserts are enabled as when they are disabled.
736
752
void validateInstrOrdering () const ;
737
-
738
- private:
739
- #if defined(_AIX) && (!defined(__GNUC__) || defined(__clang__))
740
- // Except for GCC; by default, AIX compilers store bit-fields in 4-byte words
741
- // and give the `pack` pragma push semantics.
742
- #define BEGIN_TWO_BYTE_PACK () _Pragma (" pack(2)" )
743
- #define END_TWO_BYTE_PACK () _Pragma (" pack(pop)" )
744
- #else
745
- #define BEGIN_TWO_BYTE_PACK ()
746
- #define END_TWO_BYTE_PACK ()
747
- #endif
748
-
749
- BEGIN_TWO_BYTE_PACK ()
750
- // / Bitfield to help interpret the bits in Value::SubclassData.
751
- struct BasicBlockBits {
752
- unsigned short BlockAddressRefCount : 15 ;
753
- unsigned short InstrOrderValid : 1 ;
754
- };
755
- END_TWO_BYTE_PACK ()
756
-
757
- #undef BEGIN_TWO_BYTE_PACK
758
- #undef END_TWO_BYTE_PACK
759
-
760
- // / Safely reinterpret the subclass data bits to a more useful form.
761
- BasicBlockBits getBasicBlockBits () const {
762
- static_assert (sizeof (BasicBlockBits) == sizeof (unsigned short ),
763
- " too many bits for Value::SubclassData" );
764
- unsigned short ValueData = getSubclassDataFromValue ();
765
- BasicBlockBits AsBits;
766
- memcpy (&AsBits, &ValueData, sizeof (AsBits));
767
- return AsBits;
768
- }
769
-
770
- // / Reinterpret our subclass bits and store them back into Value.
771
- void setBasicBlockBits (BasicBlockBits AsBits) {
772
- unsigned short D;
773
- memcpy (&D, &AsBits, sizeof (D));
774
- Value::setValueSubclassData (D);
775
- }
776
-
777
- // / Increment the internal refcount of the number of BlockAddresses
778
- // / referencing this BasicBlock by \p Amt.
779
- // /
780
- // / This is almost always 0, sometimes one possibly, but almost never 2, and
781
- // / inconceivably 3 or more.
782
- void AdjustBlockAddressRefCount (int Amt) {
783
- BasicBlockBits Bits = getBasicBlockBits ();
784
- Bits.BlockAddressRefCount += Amt;
785
- setBasicBlockBits (Bits);
786
- assert (Bits.BlockAddressRefCount < 255 && " Refcount wrap-around" );
787
- }
788
-
789
- // / Shadow Value::setValueSubclassData with a private forwarding method so
790
- // / that any future subclasses cannot accidentally use it.
791
- void setValueSubclassData (unsigned short D) {
792
- Value::setValueSubclassData (D);
793
- }
794
753
};
795
754
796
755
// Create wrappers for C Binding types (see CBindingWrapping.h).
0 commit comments