Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix bugs so that at least Windows Arm64 works
  • Loading branch information
davidwrighton committed Aug 18, 2022
commit 183a36e5d3fc725e01415ae073d09ffd9c7d0f37
2 changes: 1 addition & 1 deletion src/coreclr/jit/lclvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6337,7 +6337,7 @@ int Compiler::lvaAssignVirtualFrameOffsetToArg(unsigned lclNum,
unsigned argAlignment = eeGetArgSizeAlignment(varDsc->lvType, isFloatHfa);

#if TARGET_ARM64
if (!info.compIsVarArgs && varDsc->lvSize() == 16 && varDsc->lvType == TYP_STRUCT && !isFloatHfa && info.compCompHnd->getClassAlignmentRequirement(varDsc->GetStructHnd()) == 16)
if (!info.compIsVarArgs && varDsc->lvType == TYP_STRUCT && varDsc->lvSize() == 16 && !isFloatHfa && info.compCompHnd->getClassAlignmentRequirement(varDsc->GetStructHnd()) == 16)
{
// TODO-Cleanup: use "eeGetArgSizeAlignment" here. See also: https://github.com/dotnet/runtime/issues/46026.
argAlignment = 16;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp

ComputedInstanceFieldLayout layoutFromMetadata = _fallbackAlgorithm.ComputeInstanceLayout(defType, layoutKind);

if (defType.Context.Target.IsWindows || (defType.Context.Target.PointerSize == 4))
if (defType.Context.Target.Architecture != TargetArchitecture.ARM64 && defType.Context.Target.IsWindows || (defType.Context.Target.PointerSize == 4))
{
return layoutFromMetadata;
}
Expand Down Expand Up @@ -72,7 +72,7 @@ public override ValueTypeShapeCharacteristics ComputeValueTypeShapeCharacteristi
public static bool IsIntegerType(DefType type)
{
return type.IsIntrinsic
&& type.Namespace == "System."
&& type.Namespace == "System"
&& ((type.Name == "Int128") || (type.Name == "UInt128"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TestTypeSystemContext : MetadataTypeSystemContext
public CanonicalizationMode CanonMode { get; set; } = CanonicalizationMode.RuntimeDetermined;

public TestTypeSystemContext(TargetArchitecture arch, TargetOS targetOS = TargetOS.Unknown)
: base(new TargetDetails(arch, TargetOS.Unknown, TargetAbi.Unknown))
: base(new TargetDetails(arch, targetOS, TargetAbi.Unknown))
{
_vectorFieldLayoutAlgorithm = new VectorFieldLayoutAlgorithm(_metadataFieldLayout, true);
_int128FieldLayoutAlgorithm = new Int128FieldLayoutAlgorithm(_metadataFieldLayout);
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/vm/callingconvention.h
Original file line number Diff line number Diff line change
Expand Up @@ -1575,10 +1575,9 @@ int ArgIteratorTemplate<ARGITERATOR_BASE>::GetNextOffset()
// If the argument has an alignment of 16 then the NGRN is rounded up to the next even number.
//
// This rule is not used for Apple platforms. See https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms
if (!this->IsVarArg() && ((_arm64IdxGenReg & 1) == 1) && regSlots == 2 && thValueType.GetMethodTable()->GetFieldAlignmentRequirement() == 16)
if (!this->IsVarArg() && ((m_idxGenReg & 1) == 1) && regSlots == 2 && thValueType.GetMethodTable()->GetFieldAlignmentRequirement() == 16)
{
m_idxGenReg++;
numRegistersUsed++;
}
#endif

Expand Down
8 changes: 6 additions & 2 deletions src/tests/Interop/PInvoke/Int128/Int128Native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
#elif defined(__SIZEOF_INT128__)
typedef __int128 Int128;
#else
typedef struct {
struct
#ifdef _M_ARM64
alignas(16)
#endif
Int128 {
uint64_t lower;
uint64_t upper;
} Int128;
};
#endif

static Int128 Int128Value = { };
Expand Down