Skip to content

Commit ef903fd

Browse files
Always set addlDelta to zero on x86 (#79467)
* Always set "addlDelta" to zero on x86 The value is used to compensate for the additional instruction bytes, which should only be relevant for RIP-relative addressing, while x86 uses absolute addressing. * Re-enable the test
1 parent 582e522 commit ef903fd

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

src/coreclr/jit/emitxarch.cpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11691,8 +11691,6 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc)
1169111691
{
1169211692
if (id->idIsDspReloc())
1169311693
{
11694-
INT32 addlDelta = 0;
11695-
1169611694
// The address is of the form "[disp]"
1169711695
// On x86 - disp is relative to zero
1169811696
// On Amd64 - disp is relative to RIP
@@ -11705,20 +11703,17 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc)
1170511703
dst += emitOutputWord(dst, code | 0x0500);
1170611704
}
1170711705

11706+
INT32 addlDelta = 0;
11707+
#ifdef TARGET_AMD64
1170811708
if (addc)
1170911709
{
11710-
// It is of the form "ins [disp], imm" or "ins reg, [disp], imm"
11711-
// For emitting relocation, we also need to take into account of the
11712-
// additional bytes of code emitted for immed val.
11713-
11710+
// It is of the form "ins [disp], imm" or "ins reg, [disp], imm". Emitting relocation for a
11711+
// RIP-relative address means we also need to take into account the additional bytes of code
11712+
// generated for the immediate value, since RIP will point at the next instruction.
1171411713
ssize_t cval = addc->cnsVal;
1171511714

11716-
#ifdef TARGET_AMD64
1171711715
// all these opcodes only take a sign-extended 4-byte immediate
1171811716
noway_assert(opsz < 8 || ((int)cval == cval && !addc->cnsReloc));
11719-
#else // TARGET_X86
11720-
noway_assert(opsz <= 4);
11721-
#endif // TARGET_X86
1172211717

1172311718
switch (opsz)
1172411719
{
@@ -11739,6 +11734,7 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc)
1173911734
unreached();
1174011735
}
1174111736
}
11737+
#endif // TARGET_AMD64
1174211738

1174311739
#ifdef TARGET_AMD64
1174411740
// We emit zero on Amd64, to avoid the assert in emitOutputLong()
@@ -12990,20 +12986,16 @@ BYTE* emitter::emitOutputCV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc)
1299012986
{
1299112987
INT32 addlDelta = 0;
1299212988

12989+
#ifdef TARGET_AMD64
1299312990
if (addc)
1299412991
{
12995-
// It is of the form "ins [disp], imm" or "ins reg, [disp], imm"
12996-
// For emitting relocation, we also need to take into account of the
12997-
// additional bytes of code emitted for immed val.
12998-
12992+
// It is of the form "ins [disp], imm" or "ins reg, [disp], imm". Emitting relocation for a
12993+
// RIP-relative address means we also need to take into account the additional bytes of code
12994+
// generated for the immediate value, since RIP will point at the next instruction.
1299912995
ssize_t cval = addc->cnsVal;
1300012996

13001-
#ifdef TARGET_AMD64
1300212997
// all these opcodes only take a sign-extended 4-byte immediate
1300312998
noway_assert(opsz < 8 || ((int)cval == cval && !addc->cnsReloc));
13004-
#else // TARGET_X86
13005-
noway_assert(opsz <= 4);
13006-
#endif // TARGET_X86
1300712999

1300813000
switch (opsz)
1300913001
{
@@ -13024,6 +13016,7 @@ BYTE* emitter::emitOutputCV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc)
1302413016
unreached();
1302513017
}
1302613018
}
13019+
#endif // TARGET_AMD64
1302713020

1302813021
#ifdef TARGET_AMD64
1302913022
// All static field and data section constant accesses should be marked as relocatable

src/tests/issues.targets

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,6 @@
277277
<ExcludeList Include="$(XunitTestBinBase)/Regressions/coreclr/GitHub_34094/Test34094/*">
278278
<Issue>https://github.com/dotnet/runtime/issues/57458</Issue>
279279
</ExcludeList>
280-
<ExcludeList Include="$(XunitTestBinBase)/JIT/Regression/JitBlue/Runtime_31615/Runtime_31615/*">
281-
<Issue>https://github.com/dotnet/runtime/issues/79170</Issue>
282-
</ExcludeList>
283280
</ItemGroup>
284281

285282
<!-- Windows arm32 specific excludes -->

0 commit comments

Comments
 (0)