-
Notifications
You must be signed in to change notification settings - Fork 45
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
Optimised out capability loads and stores making code slower #292
Comments
You aren't actually using the capabilities so the compiler doesn't load via them |
Hmm actually it also happens if I use |
This is the IR at -O2: ; Function Attrs: norecurse nounwind
define void @doLoop(i8* nocapture readonly, i8* nocapture, i32 signext) local_unnamed_addr #0 {
%4 = add nsw i32 %2, 1
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = addrspacecast i8* %6 to i8 addrspace(200)*
%8 = load i8, i8 addrspace(200)* %7, align 1, !tbaa !3
%9 = getelementptr inbounds i8, i8* %1, i64 %5
%10 = addrspacecast i8* %9 to i8 addrspace(200)*
store i8 %8, i8 addrspace(200)* %10, align 1, !tbaa !3
%11 = add nsw i32 %2, 2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = addrspacecast i8* %13 to i8 addrspace(200)*
%15 = load i8, i8 addrspace(200)* %14, align 1, !tbaa !3
%16 = getelementptr inbounds i8, i8* %1, i64 %12
%17 = addrspacecast i8* %16 to i8 addrspace(200)*
store i8 %15, i8 addrspace(200)* %17, align 1, !tbaa !3
ret void
} |
This looks like a phase ordering problem in the CHERI addressing mode folder. It appears that we're trying to replace capability loads and stores with MIPS ones before trying to use complex addressing modes. |
There are a number of interesting things here, especially if you put it back into a loop: void doLoop(char * in, char * out, long i)
{
char * __capability inLocal = (char * __capability)in;
char * __capability outLocal = (char * __capability)out;
do {
outLocal[i]=inLocal[i];
i--;
} while (i>0);
} InstCombine appears to move the address space cast into the loop, which adds an extra instruction in a loop for us. |
Closing this since we don't care about improving MIPS codegen anymore. |
<Both C code and generated assembly updated in light of RichardsonAlex's comment>
C code:
Assembly generated:
Assembly desired:
Optimal assembly desired:
The text was updated successfully, but these errors were encountered: