mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-02 16:56:50 +00:00
Bug 31948: Fix assertion when bitcasting constantexpr pointers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295387 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
59a5fdf3ae
commit
e67c4a1dbe
@ -448,6 +448,12 @@ static Value *cloneConstantExprWithNewAddressSpace(
|
||||
return ConstantExpr::getBitCast(CE->getOperand(0), TargetType);
|
||||
}
|
||||
|
||||
if (CE->getOpcode() == Instruction::BitCast) {
|
||||
if (Value *NewOperand = ValueWithNewAddrSpace.lookup(CE->getOperand(0)))
|
||||
return ConstantExpr::getBitCast(cast<Constant>(NewOperand), TargetType);
|
||||
return ConstantExpr::getAddrSpaceCast(CE, TargetType);
|
||||
}
|
||||
|
||||
if (CE->getOpcode() == Instruction::Select) {
|
||||
Constant *Src0 = CE->getOperand(1);
|
||||
Constant *Src1 = CE->getOperand(2);
|
||||
|
24
test/Transforms/InferAddressSpaces/NVPTX/bug31948.ll
Normal file
24
test/Transforms/InferAddressSpaces/NVPTX/bug31948.ll
Normal file
@ -0,0 +1,24 @@
|
||||
; RUN: opt -S -mtriple=nvptx64-nvidia-cuda -infer-address-spaces %s | FileCheck %s
|
||||
|
||||
target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
|
||||
|
||||
%struct.bar = type { float, float* }
|
||||
|
||||
@var1 = local_unnamed_addr addrspace(3) externally_initialized global %struct.bar undef, align 8
|
||||
|
||||
; CHECK-LABEL: @bug31948(
|
||||
; CHECK: %tmp = load float*, float* addrspace(3)* getelementptr inbounds (%struct.bar, %struct.bar addrspace(3)* @var1, i64 0, i32 1), align 8
|
||||
; CHECK: %tmp1 = load float, float* %tmp, align 4
|
||||
; CHECK: store float %conv1, float* %tmp, align 4
|
||||
; CHECK: store i32 32, i32 addrspace(3)* addrspacecast (i32* bitcast (float** getelementptr (%struct.bar, %struct.bar* addrspacecast (%struct.bar addrspace(3)* @var1 to %struct.bar*), i64 0, i32 1) to i32*) to i32 addrspace(3)*), align 4
|
||||
define void @bug31948(float %a, float* nocapture readnone %x, float* nocapture readnone %y) local_unnamed_addr #0 {
|
||||
entry:
|
||||
%tmp = load float*, float** getelementptr (%struct.bar, %struct.bar* addrspacecast (%struct.bar addrspace(3)* @var1 to %struct.bar*), i64 0, i32 1), align 8
|
||||
%tmp1 = load float, float* %tmp, align 4
|
||||
%conv1 = fadd float %tmp1, 1.000000e+00
|
||||
store float %conv1, float* %tmp, align 4
|
||||
store i32 32, i32* bitcast (float** getelementptr (%struct.bar, %struct.bar* addrspacecast (%struct.bar addrspace(3)* @var1 to %struct.bar*), i64 0, i32 1) to i32*), align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
attributes #0 = { norecurse nounwind }
|
2
test/Transforms/InferAddressSpaces/NVPTX/lit.local.cfg
Normal file
2
test/Transforms/InferAddressSpaces/NVPTX/lit.local.cfg
Normal file
@ -0,0 +1,2 @@
|
||||
if not 'NVPTX' in config.root.targets:
|
||||
config.unsupported = True
|
Loading…
Reference in New Issue
Block a user