Fix #7100
authorBruce Forstall <brucefo@microsoft.com>
Thu, 8 Sep 2016 23:42:22 +0000 (16:42 -0700)
committerBruce Forstall <brucefo@microsoft.com>
Thu, 8 Sep 2016 23:42:22 +0000 (16:42 -0700)
This issue is the following assert:
```
Assert failure '!emitComp->opts.compReloc || memBase->IsIconHandle()'
```
while ngen'ing mscorlib on desktop.

We're trying to generate
```
cmp ebx, dword ptr [0000H]
```
(due to inlining). But, emitInsBinary() doesn't expect a zero address that
is not a relocatable handle.

Simply change the assert to allow this. The code then generates the correct
zero base address.

src/jit/emitxarch.cpp

index d43f766..6b7777a 100644 (file)
@@ -2499,8 +2499,9 @@ void emitter::emitHandleMemOp(GenTreeIndir* indir, instrDesc* id, insFormat fmt,
         // Absolute addresses marked as contained should fit within the base of addr mode.
         assert(memBase->AsIntConCommon()->FitsInAddrBase(emitComp));
 
-        // Either not generating relocatable code or addr must be an icon handle
-        assert(!emitComp->opts.compReloc || memBase->IsIconHandle());
+        // Either not generating relocatable code, or addr must be an icon handle, or the
+        // constant is zero (which we won't generate a relocation for).
+        assert(!emitComp->opts.compReloc || memBase->IsIconHandle() || memBase->IsIntegralConst(0));
 
         if (memBase->AsIntConCommon()->AddrNeedsReloc(emitComp))
         {