-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NativeAOT-LLVM] Merge may24 #2591
Changes from 5 commits
08e0f89
38f5daf
f3014db
a530a1c
91b32f6
5bc4a58
1eb888b
fbb67a6
1e9c6a8
dc42750
0d818ba
8608181
a601bca
4e626e2
7dc3669
e1c6717
3c00af9
a9f43da
256f320
9181d5f
40e664e
4e64b39
de44b65
0e5de42
102dcd1
0fb0188
188b3c4
a0eb5f2
562457f
56e67a7
35ad5e1
3fce4e7
5f02413
bca9f0f
fdac34d
b42426c
a7702f4
7ce2e6d
16bd99d
cdef0dd
214ea9c
c5301c4
d01ebfe
76567bf
209ce2e
de4fa45
9926d60
9be6287
ce2364c
279dbe1
02e348b
5263848
b4449fa
38467bb
5fdb133
7037516
315c4c4
6cc6c66
acd3175
aa4b0ab
6b03ebd
00a8973
0235164
c93ee68
de12ee9
eab967b
5376eca
56d7e5d
2ecc177
4c67cdf
95a0265
776ff7e
279f29e
9eac175
dc98263
31527d1
34e65b9
fdc9c9d
b997776
bdfbed6
7ce5d0f
07f7626
3ffa05f
3de068c
073e35e
4b87c13
42c2362
2cf4431
1d62262
0e46919
7536484
1be664e
741af4a
78c8cb9
bed87f8
a2d23a9
a591a77
fdacc57
5a141fc
622130e
5686f6a
cbac9f2
6c3245e
786b288
0129837
3bd4171
29cb8a6
2385d08
4b8fcd5
a37af85
0432b30
b88972a
778cc84
8c1e166
bad00cf
a71a85a
10cba5b
039d2ec
abc23ef
8966434
b48a639
3a72ea6
ed339b3
714a442
0d478a0
c12c3b7
09dd34e
46986e2
426edd0
8698d3d
9d0142f
0540ea5
ddff593
5140c33
1f08a36
2b0c1de
415ab3a
19467dc
faa4f77
3b3a435
f0edcd8
44d919d
1ee61b8
f0ee416
a930ef5
60edf5b
f4eba6b
b95c8e1
ecc8cb5
ee17b2b
95ff499
b15e351
76cd4be
5025f5e
7ac4c51
93833bb
ccce949
8f3c687
ab3ac4b
9c710c4
dafaf4a
13d753c
044e9d3
ffad857
ffa1bea
9a18cf5
189d768
7c5d205
02f8ae0
2c39e05
b7727f5
379f7b1
3ce07d3
84885d7
4246ba1
91518ca
0b10f4b
727f32b
43b7b53
1df4111
0c64e66
68ae561
cfcd6e2
fdc3797
333b3d8
26bcc1d
12283e7
839dac9
202b1be
4185f94
6943160
af11dbc
0d8c6b7
5474ab5
0b7988c
3b95ae9
5f067ce
8fcadc6
794b0c2
b1b3e85
efd7ecc
6437b48
01bff4b
24562bc
d269010
32d37ad
2bfd1b4
cbe4d84
2f3234e
e8b89a3
a142e77
78f536a
99274eb
68f3edc
153a94b
362a95d
cb9b9f7
11ffb5c
0709995
761c9a5
4a99b64
b8f554d
7d8d6ac
7452305
5c06e5d
198a259
936df9c
48c49a3
4157348
994a410
6ecede0
8c7c780
301604e
1504da8
f0f3383
86d24de
1442b94
799ac14
b5e1850
007aa64
cd68a9c
5aa167a
4095727
293b177
9e22d42
53b4b8c
edfb753
d4d04b5
054bd26
92ebf78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8280,8 +8280,8 @@ class Compiler | |||||||||
reg = REG_R11; | ||||||||||
regMask = RBM_R11; | ||||||||||
#elif defined(TARGET_WASM) | ||||||||||
reg = REG_R0; | ||||||||||
regMask = RBM_R0; | ||||||||||
reg = REG_STK; | ||||||||||
regMask = RBM_STK; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
If that runs into asserts, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have brought it back, just didn't seem to be a great idea, at least not in this PR. |
||||||||||
#elif defined(TARGET_LOONGARCH64) | ||||||||||
reg = REG_T8; | ||||||||||
regMask = RBM_T8; | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7545,6 +7545,20 @@ bool Compiler::IsTargetIntrinsic(NamedIntrinsic intrinsicName) | |
|
||
bool Compiler::IsIntrinsicImplementedByUserCall(NamedIntrinsic intrinsicName) | ||
{ | ||
#if defined(TARGET_WASM) | ||
// TODO-LLVM: Revisit when SIMD is enabled. | ||
// We want the fallback LIR expansions for these. | ||
switch(intrinsicName) | ||
{ | ||
case NI_System_Math_MultiplyAddEstimate: | ||
case NI_System_Math_ReciprocalEstimate: | ||
case NI_System_Math_ReciprocalSqrtEstimate: | ||
return false; | ||
default: | ||
break; | ||
} | ||
#endif //TARGET_WASM | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have done some time thinking about this, and looking at dotnet/runtime#102098, and I think the better fix for this issue is to augment
The actual CQ item here is to enable the better CQ for these intrinsic by actually exploiting the non-determinism, but it's a bit hard because LLVM doesn't have the same notion of intrinsics deterministic on "process granularity". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed public static double ReciprocalSqrtEstimate(double d)
{
#if MONO || TARGET_RISCV64 || TARGET_LOONGARCH64 || TARGET_WASM
return 1.0 / Sqrt(d);
#else
return ReciprocalSqrtEstimate(d);
#endif
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was it needed? It doesn't look expected to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its not needed, but I thought that' what you refered to in "requires a corresponding ...". I will revert it |
||
|
||
// Currently, if a math intrinsic is not implemented by target-specific | ||
// instructions, it will be implemented by a System.Math call. In the | ||
// future, if we turn to implementing some of them with helper calls, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1889,7 +1889,9 @@ void Compiler::lvaClassifyParameterABI() | |
// first stack arg is not considered to be at offset 0. | ||
// TODO-Cleanup: Unify things so that x86 is consistent with other platforms | ||
// here and change fgMorphExpandStackArgForVarArgs to account for that. | ||
#ifndef TARGET_X86 | ||
// LLVM: staock offsets are not aligned in the classifier, if they are then this passes and | ||
// assert(segment.Offset + segment.Size <= lvaLclExactSize(lclNum)) below fails. | ||
Comment on lines
+1892
to
+1893
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does the second assert fail? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question, I can change the classifier to if (type == TYP_STRUCT)
{
structPassingKind wbPassStruct;
type = comp->m_llvm->GetArgTypeForStructWasm(structLayout->GetClassHandle(), &wbPassStruct);
}
assert(type != TYP_STRUCT);
unsigned typeSize = genTypeSize(type);
ABIPassingSegment segment = ABIPassingSegment::OnStack(m_stackArgSize, 0, typeSize);
m_stackArgSize += AlignUp(typeSize, TARGET_POINTER_SIZE);
return ABIPassingInformation::FromSegment(comp, segment); But that doesn't match the values passed to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an assumption in the compiler that
We can delete this later - when the old classification is phased out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, Here the size is used as is, ignoring byref structs, and the value used to set the stack offset. However here https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/lclvars.cpp#L1904 the segment is checked against the size adusted for storing byrefs as pointers. How do we handle this to both pass this assert and the one that checks the classifer offsets with the stack offsets ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We would need to modify There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I left the |
||
#if !defined(TARGET_X86) && !defined(TARGET_WASM) | ||
assert(dscStackOffset == expected.GetStackOffset()); | ||
#endif | ||
} | ||
|
@@ -5947,6 +5949,7 @@ void Compiler::lvaUpdateArgsWithInitialReg() | |
} | ||
} | ||
|
||
#if !defined(TARGET_WASM) | ||
//----------------------------------------------------------------------------- | ||
// lvaAssignVirtualFrameOffsetsToArgs: | ||
// Assign virtual frame offsets to the incoming parameters. | ||
|
@@ -5970,25 +5973,12 @@ void Compiler::lvaAssignVirtualFrameOffsetsToArgs() | |
relativeZero = genCountBits(prespilled) * TARGET_POINTER_SIZE; | ||
#endif | ||
|
||
<<<<<<< HEAD | ||
#if defined(TARGET_X86) | ||
argOffs += TARGET_POINTER_SIZE; | ||
#elif defined(TARGET_AMD64) || defined(TARGET_WASM) // TODO Wasm | ||
// Register arguments on AMD64 also takes stack space. (in the backing store) | ||
varDsc->SetStackOffset(argOffs); | ||
argOffs += TARGET_POINTER_SIZE; | ||
#elif defined(TARGET_ARM64) | ||
// Register arguments on ARM64 only take stack space when they have a frame home. | ||
// Unless on windows and in a vararg method. | ||
if (compFeatureArgSplit() && this->info.compIsVarArgs) | ||
======= | ||
for (unsigned lclNum = 0; lclNum < info.compArgsCount; lclNum++) | ||
{ | ||
LclVarDsc* dsc = lvaGetDesc(lclNum); | ||
|
||
int startOffset; | ||
if (lvaGetRelativeOffsetToCallerAllocatedSpaceForParameter(lclNum, &startOffset)) | ||
>>>>>>> main | ||
{ | ||
dsc->SetStackOffset(startOffset + relativeZero); | ||
JITDUMP("Set V%02u to offset %d\n", lclNum, startOffset); | ||
|
@@ -6006,6 +5996,7 @@ void Compiler::lvaAssignVirtualFrameOffsetsToArgs() | |
} | ||
} | ||
} | ||
#endif // !TARGET_WASM | ||
|
||
//----------------------------------------------------------------------------- | ||
// lvaGetRelativeOffsetToCallerAllocatedSpaceForParameter: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,7 +396,7 @@ bool Llvm::helperCallMayPhysicallyThrow(CorInfoHelpFunc helperFunc) const | |
{ FUNC(CORINFO_HELP_ASSIGN_BYREF) }, // Not used on WASM. | ||
|
||
// Not used in NativeAOT (or at all in some cases). | ||
{ FUNC(CORINFO_HELP_ASSIGN_STRUCT) }, | ||
{ FUNC(CORINFO_HELP_BULK_WRITEBARRIER) }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one should go to the above group now with |
||
{ FUNC(CORINFO_HELP_GETFIELD8) }, | ||
{ FUNC(CORINFO_HELP_SETFIELD8) }, | ||
{ FUNC(CORINFO_HELP_GETFIELD16) }, | ||
|
@@ -615,7 +615,7 @@ CorInfoType Llvm::getLlvmArgTypeForArg(CorInfoType argSigType, CORINFO_CLASS_HAN | |
} | ||
// | ||
// WASM C ABI is documented here: https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md. | ||
// In essense, structs are passed by reference except if they are trivial wrappers of a primitive (scalar). | ||
// In essence, structs are passed by reference except if they are trivial wrappers of a primitive (scalar). | ||
// We follow this rule for the native calling convention as well as the managed one. | ||
// | ||
bool isByRef = false; | ||
|
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.
This should go upstream (probably the declarations should be ifdefed out too).