From ea988f1fd998d59f96a14bfb47db5470747f00d0 Mon Sep 17 00:00:00 2001 From: Yaxun Liu Date: Sat, 19 May 2018 02:58:16 +0000 Subject: 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 --- llvm/test/Transforms/GlobalOpt/amdgcn-ctor-alloca.ll | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 llvm/test/Transforms/GlobalOpt/amdgcn-ctor-alloca.ll (limited to 'llvm/test') diff --git a/llvm/test/Transforms/GlobalOpt/amdgcn-ctor-alloca.ll b/llvm/test/Transforms/GlobalOpt/amdgcn-ctor-alloca.ll new file mode 100644 index 00000000000..6bdcf49e95e --- /dev/null +++ b/llvm/test/Transforms/GlobalOpt/amdgcn-ctor-alloca.ll @@ -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 +} + -- cgit v1.2.3