ARM64EC Performance Issue
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
When building the following code for ARM64EC, I noticed that the call to Point in method2 results in the insertion of __os_arm64x_check_icall, which negatively impacts performance compared to method1.
Is there an attribute or compiler directive I can use to disable this check, If I can guarantee that pfun1 and pfun2 will never point to x64 code?
```
#include
#include
#include
#include
#include
int fun1(int a, int b) {
return a + b;
}
int fun2(int a, int b) {
return a * b;
}
typedef int (*AddFunc)(int, int);
int main() {
HANDLE hProcess = GetCurrentProcess();
DWORD_PTR mask = 1 << 10;
SetProcessAffinityMask(hProcess, mask);
AddFunc pfun1 = fun1; //Point the function pointer to fun1
AddFunc pfun2 = fun2; //Point the function pointer to fun1
//# Method 1
int sum = 0;
Sleep(1000);
for (int i = 0; i < 10000; i++) {
for(int j = 0; j < 200000; j++) {
sum = sum + fun1(i, j); //Function call
sum = sum + fun2(i, j);
}
}
printf("sum=%d\n", sum);
//# Method 2
sum = 0;
Sleep(1000);
for (int i = 0; i < 10000; i++) {
for (int j = 0; j < 200000; j++) {
sum = sum + pfun1(i, j); //Pointer call
sum = sum + pfun2(i, j);
}
}
printf("sum=%d\n", sum);
}
```
Contributor guide
Research direction
Start with the supplied ARM64EC sample and compare the generated code for direct calls in method 1 with the function-pointer calls in method 2, focusing on __os_arm64x_check_icall. Determine whether the compiler provides a supported way to omit this check when the pointers cannot target x64 code; done means documenting the applicable behavior or identifying the required compiler change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100