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

Commit 5d16da3

Browse files
committed
[Arm64] Support GTF_IND_VOLATILE
Addresses #9711 for arm64
1 parent ce327d5 commit 5d16da3

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/jit/codegenarm64.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,6 +2664,11 @@ void CodeGen::genCodeForCpBlkUnroll(GenTreeBlk* cpBlkNode)
26642664

26652665
emitter* emit = getEmitter();
26662666

2667+
if (cpBlkNode->gtFlags & GTF_IND_VOLATILE)
2668+
{
2669+
instGen_MemoryBarrier();
2670+
}
2671+
26672672
if (source->gtOper == GT_IND)
26682673
{
26692674
srcAddr = source->gtGetOp1();
@@ -2742,6 +2747,11 @@ void CodeGen::genCodeForCpBlkUnroll(GenTreeBlk* cpBlkNode)
27422747
genCodeForStoreOffset(INS_strb, EA_1BYTE, tmpReg, dstAddr, offset);
27432748
}
27442749
}
2750+
2751+
if (cpBlkNode->gtFlags & GTF_IND_VOLATILE)
2752+
{
2753+
instGen_MemoryBarrier();
2754+
}
27452755
}
27462756

27472757
// Generate code for CpObj nodes wich copy structs that have interleaved
@@ -2820,6 +2830,11 @@ void CodeGen::genCodeForCpObj(GenTreeObj* cpObjNode)
28202830
assert(tmpReg2 != REG_WRITE_BARRIER_SRC_BYREF);
28212831
}
28222832

2833+
if (cpObjNode->gtFlags & GTF_IND_VOLATILE)
2834+
{
2835+
instGen_MemoryBarrier();
2836+
}
2837+
28232838
emitter* emit = getEmitter();
28242839

28252840
BYTE* gcPtrs = cpObjNode->gtGcPtrs;
@@ -2896,6 +2911,11 @@ void CodeGen::genCodeForCpObj(GenTreeObj* cpObjNode)
28962911
// While we normally update GC info prior to the last instruction that uses them,
28972912
// these actually live into the helper call.
28982913
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+
}
28992919
}
29002920

29012921
// generate code do a switch statement based on a table of ip-relative offsets
@@ -3564,6 +3584,11 @@ void CodeGen::genCodeForStoreInd(GenTreeStoreInd* tree)
35643584
dataReg = data->gtRegNum;
35653585
}
35663586

3587+
if (tree->gtFlags & GTF_IND_VOLATILE)
3588+
{
3589+
instGen_MemoryBarrier();
3590+
}
3591+
35673592
emit->emitInsLoadStoreOp(ins_Store(targetType), emitTypeSize(tree), dataReg, tree);
35683593
}
35693594
}

src/jit/codegenarmarch.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,11 @@ void CodeGen::genCodeForIndir(GenTreeIndir* tree)
13591359
genConsumeAddress(tree->Addr());
13601360
emit->emitInsLoadStoreOp(ins_Load(targetType), emitTypeSize(tree), targetReg, tree);
13611361
genProduceReg(tree);
1362+
1363+
if (tree->gtFlags & GTF_IND_VOLATILE)
1364+
{
1365+
instGen_MemoryBarrier();
1366+
}
13621367
}
13631368

13641369
// Generate code for a CpBlk node by the means of the VM memcpy helper call
@@ -1381,7 +1386,17 @@ void CodeGen::genCodeForCpBlk(GenTreeBlk* cpBlkNode)
13811386
}
13821387
#endif // _TARGET_ARM64_
13831388

1389+
if (cpBlkNode->gtFlags & GTF_IND_VOLATILE)
1390+
{
1391+
instGen_MemoryBarrier();
1392+
}
1393+
13841394
genEmitHelperCall(CORINFO_HELP_MEMCPY, 0, EA_UNKNOWN);
1395+
1396+
if (cpBlkNode->gtFlags & GTF_IND_VOLATILE)
1397+
{
1398+
instGen_MemoryBarrier();
1399+
}
13851400
}
13861401

13871402
// Generates code for InitBlk by calling the VM memset helper function.
@@ -1418,6 +1433,12 @@ void CodeGen::genCodeForInitBlk(GenTreeBlk* initBlkNode)
14181433
#endif // _TARGET_ARM64_
14191434

14201435
genConsumeBlockOp(initBlkNode, REG_ARG_0, REG_ARG_1, REG_ARG_2);
1436+
1437+
if (initBlkNode->gtFlags & GTF_IND_VOLATILE)
1438+
{
1439+
instGen_MemoryBarrier();
1440+
}
1441+
14211442
genEmitHelperCall(CORINFO_HELP_MEMSET, 0, EA_UNKNOWN);
14221443
}
14231444

0 commit comments

Comments
 (0)