-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
error in backend: Cannot emit physreg copy instruction for 32-bit address space #56055
Comments
@llvm/issue-subscribers-backend-x86 |
cc @hvdijk who is familiar with 32-bit address space. |
This isn't exactly the 32-bit address space I'm familiar with, but I'm seeing the last IR before FastISel is
which looks valid, and then FastISel produces
where the copy between |
This specific problem is in --- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -549,7 +549,7 @@ bool FastISel::selectGetElementPtr(const User *I) {
uint64_t TotalOffs = 0;
// FIXME: What's a good SWAG number for MaxOffs?
uint64_t MaxOffs = 2048;
- MVT VT = TLI.getPointerTy(DL);
+ MVT VT = TLI.getPointerTy(DL, I->getType()->getPointerAddressSpace());
for (gep_type_iterator GTI = gep_type_begin(I), E = gep_type_end(I);
GTI != E; ++GTI) {
const Value *Idx = GTI.getOperand(); However, I will leave this for someone more familiar with |
getPointerTy should never use the default parameter. This fix is fine in isolation but all other instances should be passed an explicit value |
Yes, that is marked as a FIXME in the source code already. At some point, we would want to apply --- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -350,15 +350,13 @@ public:
/// Return the pointer type for the given address space, defaults to
/// the pointer type from the data layout.
- /// FIXME: The default needs to be removed once all the code is updated.
- virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS = 0) const {
+ virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS) const {
return MVT::getIntegerVT(DL.getPointerSizeInBits(AS));
}
/// Return the in-memory pointer type for the given address space, defaults to
- /// the pointer type from the data layout. FIXME: The default needs to be
- /// removed once all the code is updated.
- virtual MVT getPointerMemTy(const DataLayout &DL, uint32_t AS = 0) const {
+ /// the pointer type from the data layout.
+ virtual MVT getPointerMemTy(const DataLayout &DL, uint32_t AS) const {
return MVT::getIntegerVT(DL.getPointerSizeInBits(AS));
} However, we still have well over 500 calls that do not pass an explicit address space, and it looks to me like the default address space is the correct address space for the vast majority of them. If we update all of them as part of fixing this bug, the diff becomes so huge as to be un-reviewable. |
Thank you for your replies. Attaching the source of an example: |
Another example crashing with the same back-end error, this is extracted from AtomicOps test from LLVM test-suite and added ptr32 attribute.
The invalid COPY instruction is created in |
This problem also shows when trying to build recent versions of the Rust compiler for x32:
|
This was using the default address space instead of the correct one. Fixes #56055
This was using the default address space instead of the correct one. Fixes llvm#56055 (cherry picked from commit 81ba95c)
This was using the default address space instead of the correct one. Fixes llvm#56055 (cherry picked from commit 81ba95c)
This was using the default address space instead of the correct one. Fixes llvm#56055
The following C++ example using 32-bit address space crashes in back-end:
Checked with X86-64 clang 14.0.0.
Command to run:
clang test.cpp -S -fms-extensions
Here is the crash:
The text was updated successfully, but these errors were encountered: