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

Commit 84e39c3

Browse files
committed
[Arm64] Revise GTF_IND_VOLATILE per comments
1 parent 5d16da3 commit 84e39c3

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

src/jit/codegenarm64.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,6 +2522,12 @@ void CodeGen::genCodeForInitBlkUnroll(GenTreeBlk* initBlkNode)
25222522

25232523
genConsumeOperands(initBlkNode);
25242524

2525+
if (initBlkNode->gtFlags & GTF_BLK_VOLATILE)
2526+
{
2527+
// issue a full memory barrier before volatile an initBlockUnroll operation
2528+
instGen_MemoryBarrier();
2529+
}
2530+
25252531
regNumber valReg = initVal->IsIntegralConst(0) ? REG_ZR : initVal->gtRegNum;
25262532

25272533
assert(!initVal->IsIntegralConst(0) || (valReg == REG_ZR));
@@ -2664,8 +2670,9 @@ void CodeGen::genCodeForCpBlkUnroll(GenTreeBlk* cpBlkNode)
26642670

26652671
emitter* emit = getEmitter();
26662672

2667-
if (cpBlkNode->gtFlags & GTF_IND_VOLATILE)
2673+
if (cpBlkNode->gtFlags & GTF_BLK_VOLATILE)
26682674
{
2675+
// issue a full memory barrier before & after a volatile CpBlkUnroll operation
26692676
instGen_MemoryBarrier();
26702677
}
26712678

@@ -2748,8 +2755,9 @@ void CodeGen::genCodeForCpBlkUnroll(GenTreeBlk* cpBlkNode)
27482755
}
27492756
}
27502757

2751-
if (cpBlkNode->gtFlags & GTF_IND_VOLATILE)
2758+
if (cpBlkNode->gtFlags & GTF_BLK_VOLATILE)
27522759
{
2760+
// issue a full memory barrier before & after a volatile CpBlkUnroll operation
27532761
instGen_MemoryBarrier();
27542762
}
27552763
}
@@ -2830,8 +2838,9 @@ void CodeGen::genCodeForCpObj(GenTreeObj* cpObjNode)
28302838
assert(tmpReg2 != REG_WRITE_BARRIER_SRC_BYREF);
28312839
}
28322840

2833-
if (cpObjNode->gtFlags & GTF_IND_VOLATILE)
2841+
if (cpObjNode->gtFlags & GTF_BLK_VOLATILE)
28342842
{
2843+
// issue a full memory barrier before & after a volatile CpObj operation
28352844
instGen_MemoryBarrier();
28362845
}
28372846

@@ -2907,15 +2916,16 @@ void CodeGen::genCodeForCpObj(GenTreeObj* cpObjNode)
29072916
assert(gcPtrCount == 0);
29082917
}
29092918

2919+
if (cpObjNode->gtFlags & GTF_BLK_VOLATILE)
2920+
{
2921+
// issue a full memory barrier before & after a volatile CpObj operation
2922+
instGen_MemoryBarrier();
2923+
}
2924+
29102925
// Clear the gcInfo for REG_WRITE_BARRIER_SRC_BYREF and REG_WRITE_BARRIER_DST_BYREF.
29112926
// While we normally update GC info prior to the last instruction that uses them,
29122927
// these actually live into the helper call.
29132928
gcInfo.gcMarkRegSetNpt(RBM_WRITE_BARRIER_SRC_BYREF | RBM_WRITE_BARRIER_DST_BYREF);
2914-
2915-
if (cpObjNode->gtFlags & GTF_IND_VOLATILE)
2916-
{
2917-
instGen_MemoryBarrier();
2918-
}
29192929
}
29202930

29212931
// generate code do a switch statement based on a table of ip-relative offsets
@@ -3586,6 +3596,7 @@ void CodeGen::genCodeForStoreInd(GenTreeStoreInd* tree)
35863596

35873597
if (tree->gtFlags & GTF_IND_VOLATILE)
35883598
{
3599+
// issue a full memory barrier a before volatile StInd
35893600
instGen_MemoryBarrier();
35903601
}
35913602

src/jit/codegenarmarch.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,7 @@ void CodeGen::genCodeForIndir(GenTreeIndir* tree)
13621362

13631363
if (tree->gtFlags & GTF_IND_VOLATILE)
13641364
{
1365+
// issue a full memory barrier after a volatile LdInd operation
13651366
instGen_MemoryBarrier();
13661367
}
13671368
}
@@ -1386,15 +1387,17 @@ void CodeGen::genCodeForCpBlk(GenTreeBlk* cpBlkNode)
13861387
}
13871388
#endif // _TARGET_ARM64_
13881389

1389-
if (cpBlkNode->gtFlags & GTF_IND_VOLATILE)
1390+
if (cpBlkNode->gtFlags & GTF_BLK_VOLATILE)
13901391
{
1392+
// issue a full memory barrier before & after a volatile CpBlkUnroll operation
13911393
instGen_MemoryBarrier();
13921394
}
13931395

13941396
genEmitHelperCall(CORINFO_HELP_MEMCPY, 0, EA_UNKNOWN);
13951397

1396-
if (cpBlkNode->gtFlags & GTF_IND_VOLATILE)
1398+
if (cpBlkNode->gtFlags & GTF_BLK_VOLATILE)
13971399
{
1400+
// issue a full memory barrier before & after a volatile CpBlkUnroll operation
13981401
instGen_MemoryBarrier();
13991402
}
14001403
}
@@ -1434,8 +1437,9 @@ void CodeGen::genCodeForInitBlk(GenTreeBlk* initBlkNode)
14341437

14351438
genConsumeBlockOp(initBlkNode, REG_ARG_0, REG_ARG_1, REG_ARG_2);
14361439

1437-
if (initBlkNode->gtFlags & GTF_IND_VOLATILE)
1440+
if (initBlkNode->gtFlags & GTF_BLK_VOLATILE)
14381441
{
1442+
// issue a full memory barrier before a volatile initBlock Operation
14391443
instGen_MemoryBarrier();
14401444
}
14411445

0 commit comments

Comments
 (0)