Skip to content

Commit 8d24ba3

Browse files
Fix JIT/SPMI CodeQL issues (#107056)
1 parent 7ff684a commit 8d24ba3

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

src/coreclr/jit/emit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8361,7 +8361,7 @@ void emitter::emitDispDataSec(dataSecDsc* section, BYTE* dst)
83618361
bool isRelative = (data->dsType == dataSection::blockRelative32);
83628362
size_t blockCount = data->dsSize / (isRelative ? 4 : TARGET_POINTER_SIZE);
83638363

8364-
for (unsigned i = 0; i < blockCount; i++)
8364+
for (size_t i = 0; i < blockCount; i++)
83658365
{
83668366
if (i > 0)
83678367
{

src/coreclr/jit/lowerxarch.cpp

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4845,8 +4845,6 @@ GenTree* Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node)
48454845
case TYP_INT:
48464846
case TYP_UINT:
48474847
{
4848-
unsigned N = 0;
4849-
GenTree* opN = nullptr;
48504848
NamedIntrinsic insIntrinsic = NI_Illegal;
48514849

48524850
if ((simdBaseType == TYP_SHORT) || (simdBaseType == TYP_USHORT))
@@ -4861,7 +4859,7 @@ GenTree* Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node)
48614859

48624860
if (insIntrinsic != NI_Illegal)
48634861
{
4864-
for (N = 1; N < argCnt - 1; N++)
4862+
for (size_t N = 1; N < argCnt - 1; N++)
48654863
{
48664864
// We will be constructing the following parts:
48674865
// ...
@@ -4877,7 +4875,7 @@ GenTree* Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node)
48774875
// tmp1 = Sse?.Insert(tmp1, opN, N);
48784876
// ...
48794877

4880-
opN = node->Op(N + 1);
4878+
GenTree* opN = node->Op(N + 1);
48814879

48824880
idx = comp->gtNewIconNode(N, TYP_INT);
48834881
// Place the insert as early as possible to avoid creating a lot of long lifetimes.
@@ -4889,26 +4887,24 @@ GenTree* Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node)
48894887
LowerNode(tmp1);
48904888
}
48914889

4892-
assert(N == (argCnt - 1));
4893-
48944890
// We will be constructing the following parts:
4895-
// idx = CNS_INT int N
4896-
// /--* tmp1 simd16
4897-
// +--* opN T
4898-
// +--* idx int
4891+
// idx = CNS_INT int (argCnt - 1)
4892+
// /--* tmp1 simd16
4893+
// +--* lastOp T
4894+
// +--* idx int
48994895
// node = * HWINTRINSIC simd16 T Insert
49004896

49014897
// This is roughly the following managed code:
49024898
// ...
4903-
// tmp1 = Sse?.Insert(tmp1, opN, N);
4899+
// tmp1 = Sse?.Insert(tmp1, lastOp, (argCnt - 1));
49044900
// ...
49054901

4906-
opN = node->Op(argCnt);
4902+
GenTree* lastOp = node->Op(argCnt);
49074903

4908-
idx = comp->gtNewIconNode(N, TYP_INT);
4909-
BlockRange().InsertAfter(opN, idx);
4904+
idx = comp->gtNewIconNode((argCnt - 1), TYP_INT);
4905+
BlockRange().InsertAfter(lastOp, idx);
49104906

4911-
node->ResetHWIntrinsicId(insIntrinsic, comp, tmp1, opN, idx);
4907+
node->ResetHWIntrinsicId(insIntrinsic, comp, tmp1, lastOp, idx);
49124908
break;
49134909
}
49144910

@@ -4918,17 +4914,17 @@ GenTree* Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node)
49184914
GenTree* op[16];
49194915
op[0] = tmp1;
49204916

4921-
for (N = 1; N < argCnt; N++)
4917+
for (size_t N = 1; N < argCnt; N++)
49224918
{
4923-
opN = node->Op(N + 1);
4919+
GenTree* opN = node->Op(N + 1);
49244920

49254921
op[N] = InsertNewSimdCreateScalarUnsafeNode(TYP_SIMD16, opN, simdBaseJitType, 16);
49264922
LowerNode(op[N]);
49274923
}
49284924

49294925
if ((simdBaseType == TYP_BYTE) || (simdBaseType == TYP_UBYTE))
49304926
{
4931-
for (N = 0; N < argCnt; N += 4)
4927+
for (size_t N = 0; N < argCnt; N += 4)
49324928
{
49334929
// We will be constructing the following parts:
49344930
// ...
@@ -4958,9 +4954,9 @@ GenTree* Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node)
49584954
// tmp3 = Sse2.UnpackLow(tmp1, tmp2);
49594955
// ...
49604956

4961-
unsigned O = N + 1;
4962-
unsigned P = N + 2;
4963-
unsigned Q = N + 3;
4957+
size_t O = N + 1;
4958+
size_t P = N + 2;
4959+
size_t Q = N + 3;
49644960

49654961
tmp1 = comp->gtNewSimdHWIntrinsicNode(simdType, op[N], op[O], NI_SSE2_UnpackLow, CORINFO_TYPE_UBYTE,
49664962
simdSize);

src/coreclr/tools/superpmi/superpmi-shared/mclist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ bool MCList::processArgAsMCL(char* input, int* count, int** list)
1616

1717
size_t len = strlen(input);
1818

19-
for (unsigned int i = 0; (i < len) && isRangeList; i++)
19+
for (size_t i = 0; (i < len) && isRangeList; i++)
2020
{
2121
if ((input[i] != '-') && (input[i] != ',') && (!isdigit((unsigned char)input[i])))
2222
isRangeList = false;

src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,7 @@ int MyICJI::doAssert(const char* szFile, int iLine, const char* szExpr)
17751775
sprintf_s(buff, sizeof(buff), "%s (%d) - %s", szFile, iLine, szExpr);
17761776

17771777
LogIssue(ISSUE_ASSERT, "#%d %s", jitInstance->mc->index, buff);
1778-
jitInstance->mc->cr->recMessageLog(buff);
1778+
jitInstance->mc->cr->recMessageLog("%s", buff);
17791779

17801780
// Under "/boa", ask the user if they want to attach a debugger. If they do, the debugger will be attached,
17811781
// then we'll call DebugBreakorAV(), which will issue a __debugbreak() and actually cause

0 commit comments

Comments
 (0)