forked from OSchip/llvm-project
DAG: Fix assert when alloca has inconsistent pointer size
Take the type from the alloca, not the type to use for allocas. Fixes issue 59250.
This commit is contained in:
parent
91ba8b2b8d
commit
ee29a846c6
|
@ -1698,8 +1698,8 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) {
|
|||
DenseMap<const AllocaInst*, int>::iterator SI =
|
||||
FuncInfo.StaticAllocaMap.find(AI);
|
||||
if (SI != FuncInfo.StaticAllocaMap.end())
|
||||
return DAG.getFrameIndex(SI->second,
|
||||
TLI.getFrameIndexTy(DAG.getDataLayout()));
|
||||
return DAG.getFrameIndex(
|
||||
SI->second, TLI.getValueType(DAG.getDataLayout(), AI->getType()));
|
||||
}
|
||||
|
||||
// If this is an instruction which fast-isel has deferred, select it now.
|
||||
|
@ -4030,7 +4030,7 @@ void SelectionDAGBuilder::visitAlloca(const AllocaInst &I) {
|
|||
|
||||
SDValue AllocSize = getValue(I.getArraySize());
|
||||
|
||||
EVT IntPtr = TLI.getPointerTy(DAG.getDataLayout(), DL.getAllocaAddrSpace());
|
||||
EVT IntPtr = TLI.getPointerTy(DAG.getDataLayout(), I.getAddressSpace());
|
||||
if (AllocSize.getValueType() != IntPtr)
|
||||
AllocSize = DAG.getZExtOrTrunc(AllocSize, dl, IntPtr);
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
; RUN: not llc -march=amdgcn -mcpu=gfx900 -filetype=null %s 2>&1 | FileCheck
|
||||
|
||||
; The alloca has the wrong address space and is passed to a call. The
|
||||
; FrameIndex was created with the natural 32-bit pointer type instead
|
||||
; of the declared 64-bit. Make sure we don't assert.
|
||||
|
||||
; CHECK: LLVM ERROR: Cannot select: {{.*}}: i64 = FrameIndex<0>
|
||||
|
||||
declare void @func(ptr)
|
||||
|
||||
define void @main() {
|
||||
bb:
|
||||
%alloca = alloca i32, align 4
|
||||
call void @func(ptr %alloca)
|
||||
ret void
|
||||
}
|
Loading…
Reference in New Issue