From 3fc65f37cd4bf5989647f6e1a48da6821ea5adbd Mon Sep 17 00:00:00 2001 From: Bruce Forstall Date: Sun, 30 Oct 2016 02:34:49 -0700 Subject: Work around a Visual C++ silent bad code generation bug (#7890) Fixes #7837 The full description of the problem is in that issue. --- src/vm/dllimportcallback.cpp | 8 ++++++-- src/vm/jitinterface.cpp | 12 ++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/vm/dllimportcallback.cpp b/src/vm/dllimportcallback.cpp index 8db5a4fd48..cfac3cdb47 100644 --- a/src/vm/dllimportcallback.cpp +++ b/src/vm/dllimportcallback.cpp @@ -1320,7 +1320,9 @@ MethodDesc* UMThunkMarshInfo::GetILStubMethodDesc(MethodDesc* pInvokeMD, PInvoke dwStubFlags |= NDIRECTSTUB_FL_REVERSE_INTEROP; // could be either delegate interop or not--that info is passed in from the caller #if defined(DEBUGGING_SUPPORTED) - if (GetDebuggerCompileFlags(pSigInfo->GetModule(), CORJIT_FLAGS()).IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE)) + // Combining the next two lines, and eliminating jitDebuggerFlags, leads to bad codegen in x86 Release builds using Visual C++ 19.00.24215.1. + CORJIT_FLAGS jitDebuggerFlags = GetDebuggerCompileFlags(pSigInfo->GetModule(), CORJIT_FLAGS()); + if (jitDebuggerFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE)) { dwStubFlags |= NDIRECTSTUB_FL_GENERATEDEBUGGABLEIL; } @@ -1394,7 +1396,9 @@ VOID UMThunkMarshInfo::RunTimeInit() DWORD dwStubFlags = NDIRECTSTUB_FL_NGENEDSTUB | NDIRECTSTUB_FL_REVERSE_INTEROP | NDIRECTSTUB_FL_DELEGATE; #if defined(DEBUGGING_SUPPORTED) - if (GetDebuggerCompileFlags(GetModule(), CORJIT_FLAGS()).IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE)) + // Combining the next two lines, and eliminating jitDebuggerFlags, leads to bad codegen in x86 Release builds using Visual C++ 19.00.24215.1. + CORJIT_FLAGS jitDebuggerFlags = GetDebuggerCompileFlags(GetModule(), CORJIT_FLAGS()); + if (jitDebuggerFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE)) { dwStubFlags |= NDIRECTSTUB_FL_GENERATEDEBUGGABLEIL; } diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp index 0ac9bd9373..8171eb6cc2 100644 --- a/src/vm/jitinterface.cpp +++ b/src/vm/jitinterface.cpp @@ -7394,11 +7394,15 @@ CorInfoInline CEEInfo::canInline (CORINFO_METHOD_HANDLE hCaller, // If the callee wants debuggable code, don't allow it to be inlined - if (GetDebuggerCompileFlags(pCallee->GetModule(), CORJIT_FLAGS()).IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE)) { - result = INLINE_NEVER; - szFailReason = "Inlinee is debuggable"; - goto exit; + // Combining the next two lines, and eliminating jitDebuggerFlags, leads to bad codegen in x86 Release builds using Visual C++ 19.00.24215.1. + CORJIT_FLAGS jitDebuggerFlags = GetDebuggerCompileFlags(pCallee->GetModule(), CORJIT_FLAGS()); + if (jitDebuggerFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE)) + { + result = INLINE_NEVER; + szFailReason = "Inlinee is debuggable"; + goto exit; + } } #endif -- cgit v1.2.3