- Notifications
You must be signed in to change notification settings - Fork 15.3k
[CodeGen] Allow mixed scalar type constraints for inline asm #65465
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
Conversation
| Are there existing bug issues associated with this? |
I don't know. Found this issue in our downstream target. |
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.
What IR does this generate?
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 test is using -emit-llvm, but the patch is in SelectionDAG. SelectionDAG doesn't run with -emit-llvm
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.
Thanks for the review. You are right, indeed the test was pointless, the problem is with CodeGen. Updated the issue accordingly.
5d403b7 to 22c95d7 Compare 22c95d7 to 04f13a6 Compare 04f13a6 to ea6ac87 Compare | Ping |
1 similar comment
| Ping |
| %i = alloca i32, align 4 | ||
| store float %f, ptr %f.addr, align 4 | ||
| %0 = load float, ptr %f.addr, align 4 | ||
| %1 = call i32 asm sideeffect "", "=r,0,~{dirflag},~{fpsr},~{flags}"(float %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.
Use named values in tests
| store i32 %1, ptr %i, align 4 | ||
| %2 = load i32, ptr %i, align 4 | ||
| ret i32 %2 | ||
| } |
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.
Can you also try the same, except with a mixed pointer and int/float? Also some vector cases?
eb8afd2 to 0a3516b Compare | %f.addr = alloca float*, align 4 | ||
| %i = alloca i32, align 4 | ||
| store float* %f, ptr %f.addr, align 4 | ||
| %load_f = load float*, ptr %f.addr, align 4 |
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.
Test needs to be updated to use opaque pointers. Also you don't need all of this intermediate alloca stuff, you can simplify the incoming values and uses
arsenm 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.
Test needs cleanup
| ; return i; | ||
| ; } | ||
| | ||
| |
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.
Add some comments explaining what this is showing
GCC supports code like "asm volatile ("" : "=r" (i) : "0" (f))" where i is integer type and f is floating point type. Currently this code produces an error with Clang. The change allows mixed scalar types between input and output constraints. 52423a1 to 52e62c6 Compare | ; CHECK-NEXT: # kill: def $eax killed $eax killed $rax | ||
| ; CHECK-NEXT: retq | ||
| entry: | ||
| %asm_call = call i32 asm sideeffect "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %f) |
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.
Is it really allowed to have the mismatched sizes, pointer 64 with i32? Should that be an x86-only thing?
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.
What about double + i32? Or i16 + float?
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.
Ugh. GCC seems to accept whatever garbage you give it.
| ; CHECK-NEXT: # kill: def $eax killed $eax killed $rax | ||
| ; CHECK-NEXT: retq | ||
| entry: | ||
| %asm_call = call i32 asm sideeffect "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %f) |
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.
Ugh. GCC seems to accept whatever garbage you give it.
| Well if approved, then can someone merge it? |
GCC supports code like "asm volatile ("" : "=r" (i) : "0" (f))" where i is integer type and f is floating point type. Currently this code produces an error with Clang. The change allows mixed scalar types between input and output constraints.