mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Fix evaluator for non-zero alloca addr space
The evaluator goes through BB and creates global vars as temporary values to evaluate results of LLVM instructions. It creates undef for alloca, however it assumes alloca in addr space 0. If the next instruction is addrspace cast to 0, then we get an invalid cast instruction. This patch let the temp global var have an address space matching alloca addr space, so that the valuation can be done. Differential Revision: https://reviews.llvm.org/D47081 llvm-svn: 332794
This commit is contained in:
parent
53628c120e
commit
e144b4a71a
@ -377,7 +377,8 @@ bool Evaluator::EvaluateBlock(BasicBlock::iterator CurInst,
|
||||
Type *Ty = AI->getAllocatedType();
|
||||
AllocaTmps.push_back(llvm::make_unique<GlobalVariable>(
|
||||
Ty, false, GlobalValue::InternalLinkage, UndefValue::get(Ty),
|
||||
AI->getName()));
|
||||
AI->getName(), /*TLMode=*/GlobalValue::NotThreadLocal,
|
||||
AI->getType()->getPointerAddressSpace()));
|
||||
InstResult = AllocaTmps.back().get();
|
||||
LLVM_DEBUG(dbgs() << "Found an alloca. Result: " << *InstResult << "\n");
|
||||
} else if (isa<CallInst>(CurInst) || isa<InvokeInst>(CurInst)) {
|
||||
|
17
test/Transforms/GlobalOpt/amdgcn-ctor-alloca.ll
Normal file
17
test/Transforms/GlobalOpt/amdgcn-ctor-alloca.ll
Normal file
@ -0,0 +1,17 @@
|
||||
; RUN: opt -data-layout=A5 -globalopt %s -S -o - | FileCheck %s
|
||||
|
||||
; CHECK-NOT: @g
|
||||
@g = internal addrspace(1) global i32* zeroinitializer
|
||||
|
||||
; CHECK: @llvm.global_ctors = appending global [0 x { i32, void ()*, i8* }] zeroinitializer
|
||||
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }]
|
||||
[{ i32, void ()*, i8* } { i32 65535, void ()* @ctor, i8* null }]
|
||||
|
||||
; CHECK-NOT: @ctor
|
||||
define internal void @ctor() {
|
||||
%addr = alloca i32, align 8, addrspace(5)
|
||||
%tmp = addrspacecast i32 addrspace(5)* %addr to i32*
|
||||
store i32* %tmp, i32* addrspace(1)* @g
|
||||
ret void
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user