https://llvm.org/bugs/show_bug.cgi?id=26154
Bug ID: 26154 Summary: Wrong address space in load pre-splitting in SROA Product: libraries Version: trunk Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: Scalar Optimizations Assignee: unassignedb...@nondot.org Reporter: es...@apple.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified This is a copy-paste of an internal bug report; I might be able to conjure up a test case if necessary (it's GPU code with multiple address spaces), but the bug looks pretty straightforward. The reporter supplied a patch. The context is a load from addrspace(1) which is then stored to the stack, which SROA mishandles. Report: The problem appears to be that when pre-splitting the load, SROA seems to be using the address space of the store instead of the address space of the load. The function is SROA::presplitLoadsAndStores and the code is: auto *PartTy = Type::getIntNTy(Ty->getContext(), PartSize * 8); auto *PartPtrTy = PartTy->getPointerTo(SI->getPointerAddressSpace()); … PLoad = IRB.CreateAlignedLoad( getAdjustedPtr(IRB, DL, LoadBasePtr, APInt(DL.getPointerSizeInBits(), PartOffset), PartPtrTy, LoadBasePtr->getName() + “.”), diff --git a/lib/Transforms/Scalar/SROA.cpp b/lib/Transforms/Scalar/SROA.cpp index 9c69b6c..48c907f 100644 --- a/lib/Transforms/Scalar/SROA.cpp +++ b/lib/Transforms/Scalar/SROA.cpp @@ -3919,7 +3919,8 @@ bool SROA::presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS) { PLoad = IRB.CreateAlignedLoad( getAdjustedPtr(IRB, DL, LoadBasePtr, APInt(DL.getPointerSizeInBits(), PartOffset), - PartPtrTy, LoadBasePtr->getName() + "."), + PartTy->getPointerTo(LI->getPointerAddressSpace()), + LoadBasePtr->getName() + "."), getAdjustedAlignment(LI, PartOffset, DL), /*IsVolatile*/ false, LI->getName()); } -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs