Procházet zdrojové kódy

Remove DXIL Dia's assert which makes assumptions about dwarf bit pieces. (#2094)

In the general case, bit_pieces might be only for part of a register or register range. For example a half in a VGPR or a SGPRx4 for which we only have debug info for the first register.
Tristan Labelle před 6 roky
rodič
revize
41ef8bd2c8
1 změnil soubory, kde provedl 15 přidání a 14 odebrání
  1. 15 14
      lib/DxilDia/DxilDiaSymbolManager.cpp

+ 15 - 14
lib/DxilDia/DxilDiaSymbolManager.cpp

@@ -1682,29 +1682,30 @@ HRESULT dxil_dia::hlsl_symbols::SymbolManagerInit::IsDbgDeclareCall(llvm::Module
       return E_FAIL;
     }
 
+    static constexpr uint64_t kNumBytesPerDword = 4;
     if (Fields->isBitPiece()) {
-      const uint64_t Offset = Fields->getBitPieceOffset();
-      const uint64_t Size = Fields->getBitPieceSize();
+      const uint64_t BitPieceOffset = Fields->getBitPieceOffset();
+      const uint64_t BitPieceSize = Fields->getBitPieceSize();
 
       // dxcompiler had a bug (fixed in
       // 4870297404a37269e24ddce7db3bd94a8110fff8) where the BitPieceSize
       // was defined in bytes, not bits. We use the register size in bits to
       // verify if Size is bits or bytes.
-      static constexpr uint64_t kNumBytesPerDword = 4;
-      if (*pRegSize * kNumBytesPerDword == Size) {
-          // Size is bytes.
-          *pStartOffset = Offset;
-          *pEndOffset = *pStartOffset + Size;
+      if (*pRegSize * kNumBytesPerDword == BitPieceSize) {
+        // Size is bytes.
+        *pStartOffset = BitPieceOffset;
+        *pEndOffset = *pStartOffset + BitPieceSize;
       } else {
-          // Size is (should be) bits; pStartOffset/pEndOffset should be bytes.
-          static constexpr uint64_t kNumBitsPerByte = 8;
-          (void)kNumBitsPerByte;
-          assert(*pRegSize * kNumBytesPerDword * kNumBitsPerByte == Size);
-          *pStartOffset = Offset / kNumBitsPerByte;
-          *pEndOffset = *pStartOffset + (Size / kNumBitsPerByte);
+        // Size is (should be) bits; pStartOffset/pEndOffset should be bytes.
+        // We don't expect to encounter bit pieces more granular than bytes.
+        static constexpr uint64_t kNumBitsPerByte = 8;
+        (void)kNumBitsPerByte;
+        assert(BitPieceOffset % kNumBitsPerByte == 0);
+        assert(BitPieceSize % kNumBitsPerByte == 0);
+        *pStartOffset = BitPieceOffset / kNumBitsPerByte;
+        *pEndOffset = *pStartOffset + (BitPieceSize / kNumBitsPerByte);
       }
     } else {
-      static constexpr uint64_t kNumBytesPerDword = 4;
       *pStartOffset = 0;
       *pEndOffset = *pRegSize * kNumBytesPerDword;
     }