Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 3fc65f3

Browse files
BruceForstalljkotas
authored andcommitted
Work around a Visual C++ silent bad code generation bug (#7890)
Fixes #7837 The full description of the problem is in that issue.
1 parent d64c7d6 commit 3fc65f3

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/vm/dllimportcallback.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,9 @@ MethodDesc* UMThunkMarshInfo::GetILStubMethodDesc(MethodDesc* pInvokeMD, PInvoke
13201320
dwStubFlags |= NDIRECTSTUB_FL_REVERSE_INTEROP; // could be either delegate interop or not--that info is passed in from the caller
13211321

13221322
#if defined(DEBUGGING_SUPPORTED)
1323-
if (GetDebuggerCompileFlags(pSigInfo->GetModule(), CORJIT_FLAGS()).IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE))
1323+
// Combining the next two lines, and eliminating jitDebuggerFlags, leads to bad codegen in x86 Release builds using Visual C++ 19.00.24215.1.
1324+
CORJIT_FLAGS jitDebuggerFlags = GetDebuggerCompileFlags(pSigInfo->GetModule(), CORJIT_FLAGS());
1325+
if (jitDebuggerFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE))
13241326
{
13251327
dwStubFlags |= NDIRECTSTUB_FL_GENERATEDEBUGGABLEIL;
13261328
}
@@ -1394,7 +1396,9 @@ VOID UMThunkMarshInfo::RunTimeInit()
13941396
DWORD dwStubFlags = NDIRECTSTUB_FL_NGENEDSTUB | NDIRECTSTUB_FL_REVERSE_INTEROP | NDIRECTSTUB_FL_DELEGATE;
13951397

13961398
#if defined(DEBUGGING_SUPPORTED)
1397-
if (GetDebuggerCompileFlags(GetModule(), CORJIT_FLAGS()).IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE))
1399+
// Combining the next two lines, and eliminating jitDebuggerFlags, leads to bad codegen in x86 Release builds using Visual C++ 19.00.24215.1.
1400+
CORJIT_FLAGS jitDebuggerFlags = GetDebuggerCompileFlags(GetModule(), CORJIT_FLAGS());
1401+
if (jitDebuggerFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE))
13981402
{
13991403
dwStubFlags |= NDIRECTSTUB_FL_GENERATEDEBUGGABLEIL;
14001404
}

src/vm/jitinterface.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7394,11 +7394,15 @@ CorInfoInline CEEInfo::canInline (CORINFO_METHOD_HANDLE hCaller,
73947394

73957395
// If the callee wants debuggable code, don't allow it to be inlined
73967396

7397-
if (GetDebuggerCompileFlags(pCallee->GetModule(), CORJIT_FLAGS()).IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE))
73987397
{
7399-
result = INLINE_NEVER;
7400-
szFailReason = "Inlinee is debuggable";
7401-
goto exit;
7398+
// Combining the next two lines, and eliminating jitDebuggerFlags, leads to bad codegen in x86 Release builds using Visual C++ 19.00.24215.1.
7399+
CORJIT_FLAGS jitDebuggerFlags = GetDebuggerCompileFlags(pCallee->GetModule(), CORJIT_FLAGS());
7400+
if (jitDebuggerFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE))
7401+
{
7402+
result = INLINE_NEVER;
7403+
szFailReason = "Inlinee is debuggable";
7404+
goto exit;
7405+
}
74027406
}
74037407
#endif
74047408

0 commit comments

Comments
 (0)