[PATCH] D47099: Disable casting of alloca for ActiveFlag

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 18 19:30:27 PDT 2018


yaxunl created this revision.
yaxunl added a reviewer: rjmccall.

ActiveFlag is a temporary variable emitted for clean up. It is defined as AllocaInst* type and there is
a cast to AlllocaInst in SetActiveFlag. An alloca casted to generic pointer causes assertion in
SetActiveFlag.

Since there is only load/store of ActiveFlag, it is safe to use the original alloca, therefore disable
the cast.


https://reviews.llvm.org/D47099

Files:
  lib/CodeGen/CGCleanup.cpp
  test/CodeGenCXX/conditional-temporaries.cpp


Index: test/CodeGenCXX/conditional-temporaries.cpp
===================================================================
--- test/CodeGenCXX/conditional-temporaries.cpp
+++ test/CodeGenCXX/conditional-temporaries.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -O3 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=amdgcn-amd-amdhsa -O3 | FileCheck %s
 
 namespace {
 
Index: lib/CodeGen/CGCleanup.cpp
===================================================================
--- lib/CodeGen/CGCleanup.cpp
+++ lib/CodeGen/CGCleanup.cpp
@@ -284,7 +284,8 @@
 void CodeGenFunction::initFullExprCleanup() {
   // Create a variable to decide whether the cleanup needs to be run.
   Address active = CreateTempAlloca(Builder.getInt1Ty(), CharUnits::One(),
-                                    "cleanup.cond");
+                                    "cleanup.cond", /*ArraySize=*/nullptr,
+                                    /*Alloca=*/nullptr, /*Cast=*/false);
 
   // Initialize it to false at a site that's guaranteed to be run
   // before each evaluation.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47099.147638.patch
Type: text/x-patch
Size: 1097 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180519/0ba1d7ad/attachment-0001.bin>


More information about the cfe-commits mailing list