-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Arm64: Use op2 type for LOCKADD #14547
Conversation
|
@sdmaclea - I'm not certain this is the right fix, but I added an assert that the type of op2 matches the type of the |
src/jit/codegenarm64.cpp
Outdated
| // TODO-ARM64-CQ Evaluate whether this is necessary | ||
| // https://github.com/dotnet/coreclr/issues/14346 | ||
| getEmitter()->emitIns_R_R(INS_ldaxr, emitTypeSize(treeNode), loadReg, addrReg); | ||
| getEmitter()->emitIns_R_R(INS_ldaxr, emitActualTypeSize(data), loadReg, addrReg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally use emitTypeSize for loads. Since it does not force the size to a general purpose register size.
Here it doesn't effect functionality, but I would prefer to change it to be consistent.
| expr->SetOperRaw(GT_LOCKADD); | ||
| #ifndef _TARGET_ARM64_ | ||
| assert(genActualType(expr->gtType) == genActualType(expr->gtOp.gtOp2->gtType)); | ||
| expr->gtType = TYP_VOID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the importer should be changed to set the type to VOID on import of GT_LOCKADD too. I think this must be missing unless emitTypeSize for TYP_VOID doesn't assert or return 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that, theoretically, it is defined to return the data type. It's in Compiler::gtExtractSideEffList that it changes it to TYP_VOID when its result isn't used. However, I don't know if it ever actually returns a result.
|
Something between gentree and codegen is changing the type of the addend On my tip w/o your original change, I added three asserts, that the addend matched the atomic node type.
This test is hitting the codegen assert on my tip. |
|
gdb from failing test case So the addend is from a indirect TYP_SHORT address. During lowering, there must have been a cast dropped. Since on ARM64 the type of op2 would normally be evaluated with emitActualTypeSize by consumers. I think GTF_NOVALUE, might be a better way to signal this behavior. If we want to continue setting GT_LOCKADD->gtType to TYP_VOID, then using |
I would like to avoid the use of
I think that's the right approach. |
Fix #14539
|
@sdmaclea - Do you agree that this is an appropriate and correct fix? |
|
@dotnet/jit-contrib - I meant to ping on this, not on the bug. |
briansull
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks Good
|
@CarolEidt Thanks, I had to go offline last night due to a household appliance failure |
|
@CarolEidt BTW, there may still be an issue for 64 bit atomics if the addend is an indirect small type, when there should be a carry into the high 32 bits. I would guess the problem exist on all platforms now, but I am not sure. There is certainly no coverage for this case. |
Agreed. I opened #14557 because I think the implementation of the interlocked operations would be cleaner and less error-prone if they took an indirection as their op1. That indirection would hold the correct type. I'll add a note there that we should add better test coverage. |
Fix #14539