summaryrefslogtreecommitdiff
path: root/src/jit
diff options
context:
space:
mode:
authorBruce Forstall <Bruce_Forstall@msn.com>2018-10-29 14:49:26 -0700
committerBruce Forstall <Bruce_Forstall@msn.com>2018-10-29 18:47:33 -0700
commite36b7a089efd1b36d7e77cccacaca7b15b0c1f15 (patch)
tree101509cdaa24f29d11a3c1e87fe44f085d52bf91 /src/jit
parentccc18a6352c7a6232606131424c0377ea3529991 (diff)
downloadcoreclr-e36b7a089efd1b36d7e77cccacaca7b15b0c1f15.tar.gz
coreclr-e36b7a089efd1b36d7e77cccacaca7b15b0c1f15.tar.bz2
coreclr-e36b7a089efd1b36d7e77cccacaca7b15b0c1f15.zip
Dump the "reason" for a compiler temp
Compiler temps are created with a "reason" that is dumped in JitDump. Save the reason and display it in the local variable table dump. This is useful when trying to find a particular temp and see what code has been generated using it.
Diffstat (limited to 'src/jit')
-rw-r--r--src/jit/compiler.h2
-rw-r--r--src/jit/compiler.hpp2
-rw-r--r--src/jit/lclvars.cpp29
3 files changed, 25 insertions, 8 deletions
diff --git a/src/jit/compiler.h b/src/jit/compiler.h
index 16e7ebd503..f68642671b 100644
--- a/src/jit/compiler.h
+++ b/src/jit/compiler.h
@@ -850,6 +850,8 @@ public:
#ifdef DEBUG
public:
+ const char* lvReason;
+
void PrintVarReg() const
{
printf("%s", getRegName(lvRegNum));
diff --git a/src/jit/compiler.hpp b/src/jit/compiler.hpp
index 823cc99038..b4de24ae38 100644
--- a/src/jit/compiler.hpp
+++ b/src/jit/compiler.hpp
@@ -1701,6 +1701,8 @@ inline unsigned Compiler::lvaGrabTemp(bool shortLifetime DEBUGARG(const char* re
}
#ifdef DEBUG
+ lvaTable[tempNum].lvReason = reason;
+
if (verbose)
{
printf("\nlvaGrabTemp returning %d (", tempNum);
diff --git a/src/jit/lclvars.cpp b/src/jit/lclvars.cpp
index 645f3fe280..0f68c365e2 100644
--- a/src/jit/lclvars.cpp
+++ b/src/jit/lclvars.cpp
@@ -2116,17 +2116,21 @@ void Compiler::StructPromotionHelper::PromoteStructVar(unsigned lclNum)
// Now grab the temp for the field local.
#ifdef DEBUG
- char buf[200];
- char* bufp = &buf[0];
-
- sprintf_s(bufp, sizeof(buf), "%s V%02u.%s (fldOffset=0x%x)", "field", lclNum,
+ char buf[200];
+ sprintf_s(buf, sizeof(buf), "%s V%02u.%s (fldOffset=0x%x)", "field", lclNum,
compiler->eeGetFieldName(pFieldInfo->fldHnd), pFieldInfo->fldOffset);
+ // We need to copy 'buf' as lvaGrabTemp() below caches a copy to its argument.
+ size_t len = strlen(buf) + 1;
+ char* bufp = compiler->getAllocator(CMK_DebugOnly).allocate<char>(len);
+ strcpy_s(bufp, len, buf);
+
if (index > 0)
{
noway_assert(pFieldInfo->fldOffset > (pFieldInfo - 1)->fldOffset);
}
#endif
+
// Lifetime of field locals might span multiple BBs, so they must be long lifetime temps.
unsigned varNum = compiler->lvaGrabTemp(false DEBUGARG(bufp));
@@ -2227,12 +2231,16 @@ void Compiler::lvaPromoteLongVars()
CLANG_FORMAT_COMMENT_ANCHOR;
#ifdef DEBUG
- char buf[200];
- char* bufp = &buf[0];
-
- sprintf_s(bufp, sizeof(buf), "%s V%02u.%s (fldOffset=0x%x)", "field", lclNum, index == 0 ? "lo" : "hi",
+ char buf[200];
+ sprintf_s(buf, sizeof(buf), "%s V%02u.%s (fldOffset=0x%x)", "field", lclNum, index == 0 ? "lo" : "hi",
index * 4);
+
+ // We need to copy 'buf' as lvaGrabTemp() below caches a copy to its argument.
+ size_t len = strlen(buf) + 1;
+ char* bufp = getAllocator(CMK_DebugOnly).allocate<char>(len);
+ strcpy_s(bufp, len, buf);
#endif
+
unsigned varNum = lvaGrabTemp(false DEBUGARG(bufp)); // Lifetime of field locals might span multiple BBs, so
// they are long lifetime temps.
@@ -6964,6 +6972,11 @@ void Compiler::lvaDumpEntry(unsigned lclNum, FrameLayoutState curState, size_t r
}
}
+ if (varDsc->lvReason != nullptr)
+ {
+ printf(" \"%s\"", varDsc->lvReason);
+ }
+
printf("\n");
}