]> granicus.if.org Git - clang/commit
CodeGen: Fix insertion position of addrspace cast for alloca
authorYaxun Liu <Yaxun.Liu@amd.com>
Mon, 30 Oct 2017 14:38:30 +0000 (14:38 +0000)
committerYaxun Liu <Yaxun.Liu@amd.com>
Mon, 30 Oct 2017 14:38:30 +0000 (14:38 +0000)
commit5aa4dd9f9d3038556d897395f07c1ea40ab7a28b
treec32877c2bc195bbe43ff03a3cc9903070e421664
parent1f7d6d2a2190730170a0d55d58cdc87aaffa7cb9
CodeGen: Fix insertion position of addrspace cast for alloca

For non-zero alloca addr space, alloca is usually casted to default addr
space immediately.

For non-vla, alloca is inserted at AllocaInsertPt, therefore the addr
space cast should also be insterted at AllocaInsertPt. However,
for vla, alloca is inserted at the current insertion point of IRBuilder,
therefore the addr space cast should also inserted at the current
insertion point of IRBuilder.

Currently clang always insert addr space cast at AllocaInsertPt, which
causes invalid IR.

This patch fixes that.

Differential Revision: https://reviews.llvm.org/D39374

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316909 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGExpr.cpp
test/CodeGenCXX/vla.cpp