-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
I hit some GCC build failure in JIT code in my PR here, and I don't think it has to do with my changes.
The official build log simply repeated these few failures many times:
In file included from /__w/1/s/src/coreclr/jit/compiler.h:30,
from /__w/1/s/src/coreclr/jit/jit.h:758,
from /__w/1/s/src/coreclr/jit/jitpch.h:18,
from /__w/1/s/src/coreclr/jit/alloc.cpp:4:
/__w/1/s/src/coreclr/jit/lir.h:301:30: warning: extra qualification 'LIR::' on member 'AsRange' [-fpermissive]
301 | static const LIR::Range& LIR::AsRange(const BasicBlock* block);
| ^~~
In file included from /__w/1/s/src/coreclr/jit/codegeninterface.h:26,
from /__w/1/s/src/coreclr/jit/compiler.h:51,
from /__w/1/s/src/coreclr/jit/jit.h:758,
from /__w/1/s/src/coreclr/jit/jitpch.h:18,
from /__w/1/s/src/coreclr/jit/alloc.cpp:4:
/__w/1/s/src/coreclr/jit/emit.h:536:25: warning: 'emitter::emitAddrMode::amScale' is too small to hold all values of 'enum emitter::opSize'
536 | emitter::opSize amScale : 2;
| ^~~~~~~
/__w/1/s/src/coreclr/jit/emit.h:855:27: warning: 'emitter::instrDesc::idAddrUnion::<unnamed struct>::_idReg3' is too small to hold all values of 'regNumber' {aka 'enum _regNumber_enum'}
855 | regNumber _idReg3 : REGNUM_BITS;
| ^~~~~~~
/__w/1/s/src/coreclr/jit/emit.h:856:27: warning: 'emitter::instrDesc::idAddrUnion::<unnamed struct>::_idReg4' is too small to hold all values of 'regNumber' {aka 'enum _regNumber_enum'}
856 | regNumber _idReg4 : REGNUM_BITS;
| ^~~~~~~
/__w/1/s/src/coreclr/jit/emit.h:669:19: warning: 'emitter::instrDesc::_idReg1' is too small to hold all values of 'regNumber' {aka 'enum _regNumber_enum'}
669 | regNumber _idReg1 : REGNUM_BITS; // register num
| ^~~~~~~
/__w/1/s/src/coreclr/jit/emit.h:671:19: warning: 'emitter::instrDesc::_idReg2' is too small to hold all values of 'regNumber' {aka 'enum _regNumber_enum'}
671 | regNumber _idReg2 : REGNUM_BITS;
The warning on line 301 is obvious. All we needed to do is to get rid of the extra qualification.
The warning on line 536 is valid, there are 7 distinct values for opSize, but we are allocating only 2 bits for amScale.
runtime/src/coreclr/jit/emit.h
Lines 457 to 471 in c5f5b99
| enum opSize : unsigned | |
| { | |
| OPSZ1 = 0, | |
| OPSZ2 = 1, | |
| OPSZ4 = 2, | |
| OPSZ8 = 3, | |
| OPSZ16 = 4, | |
| OPSZ32 = 5, | |
| OPSZ_COUNT = 6, | |
| #ifdef TARGET_AMD64 | |
| OPSZP = OPSZ8, | |
| #else | |
| OPSZP = OPSZ4, | |
| #endif | |
| }; |
It is unclear what's wrong with the REGNUM_BITS. This is a failure on x64, and on x64 we should have 36 distinct enum values, and we gave 6 bits, that should be enough, but somehow GCC complains.
0:000> dt clrjit!emitter::instrDesc
+0x000 _idIns : Pos 0, 10 Bits
+0x000 _idInsFmt : Pos 10, 7 Bits
+0x000 _idCodeSize : Pos 17, 4 Bits
+0x000 _idOpSize : Pos 21, 3 Bits
+0x000 _idGCref : Pos 24, 2 Bits
+0x000 _idReg1 : Pos 26, 6 Bits
+0x004 _idReg2 : Pos 0, 6 Bits
+0x004 _idSmallDsc : Pos 6, 1 Bit
+0x004 _idLargeCns : Pos 7, 1 Bit
+0x004 _idLargeDsp : Pos 8, 1 Bit
+0x004 _idLargeCall : Pos 9, 1 Bit
+0x004 _idBound : Pos 10, 1 Bit
+0x004 _idCallRegPtr : Pos 11, 1 Bit
+0x004 _idCallAddr : Pos 12, 1 Bit
+0x004 _idNoGC : Pos 13, 1 Bit
+0x004 _idCnsReloc : Pos 14, 1 Bit
+0x004 _idDspReloc : Pos 15, 1 Bit
+0x004 _idSmallCns : Pos 16, 16 Bits
+0x008 _idDebugOnlyInfo : Ptr64 emitter::instrDescDebugInfo
+0x010 _idAddrUnion : emitter::instrDesc::idAddrUnion
0:000> dt clrjit!_regNumber_enum
REG_RAX = 0n0
REG_RCX = 0n1
REG_RDX = 0n2
REG_RBX = 0n3
REG_RSP = 0n4
REG_RBP = 0n5
REG_RSI = 0n6
REG_RDI = 0n7
REG_R8 = 0n8
REG_R9 = 0n9
REG_R10 = 0n10
REG_R11 = 0n11
REG_R12 = 0n12
REG_R13 = 0n13
REG_R14 = 0n14
REG_R15 = 0n15
REG_EAX = 0n0
REG_ECX = 0n1
REG_EDX = 0n2
REG_EBX = 0n3
REG_ESP = 0n4
REG_EBP = 0n5
REG_ESI = 0n6
REG_EDI = 0n7
REG_XMM0 = 0n16
REG_XMM1 = 0n17
REG_XMM2 = 0n18
REG_XMM3 = 0n19
REG_XMM4 = 0n20
REG_XMM5 = 0n21
REG_XMM6 = 0n22
REG_XMM7 = 0n23
REG_XMM8 = 0n24
REG_XMM9 = 0n25
REG_XMM10 = 0n26
REG_XMM11 = 0n27
REG_XMM12 = 0n28
REG_XMM13 = 0n29
REG_XMM14 = 0n30
REG_XMM15 = 0n31
REG_STK = 0n32
REG_COUNT = 0n33
REG_NA = 0n33
ACTUAL_REG_COUNT = 0n32
This post on StackOverflow seems to imply that the warning is independent on the enum values. If that's the case then it at least makes sense, but I wonder what should we do about that, we can't just leave the warning there.