Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Commit

Permalink
When switched to llvm7.0 a test based an OCL benchmark cannot be comp…
Browse files Browse the repository at this point in the history
…iled. IGC crashes with

such output:

Assertion failed: isAllocaPromotable(AI) && "Cannot promote non-promotable alloca!", file llvm\src\lib\transforms\utils\promotememorytoregister.cpp, line 563

It's asserted in SROA optimization pass due to inappropriate bitcast
creation for a new slice allocated. Later when doing memory-to-reg
checking it detects that inserted bitcast is invalid.


Change-Id: I4e0d596a76e58fc9a7e811d355094ac3249db922
  • Loading branch information
lwesiers committed Dec 20, 2018
1 parent 5fc26d8 commit 703b033
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff -Naur a/lib/Transforms/Scalar/SROA.cpp b/lib/Transforms/Scalar/SROA.cpp
--- a/lib/Transforms/Scalar/SROA.cpp 2018-08-31 17:53:05.000000000 +0200
+++ b/lib/Transforms/Scalar/SROA.cpp 2018-12-20 18:48:12.788662000 +0100
@@ -3033,7 +3033,18 @@
ConstantInt *Size =
ConstantInt::get(cast<IntegerType>(II.getArgOperand(0)->getType()),
NewEndOffset - NewBeginOffset);
- Value *Ptr = getNewAllocaSlicePtr(IRB, OldPtr->getType());
+ // For lifetime intrinsics it's ok to cast a pointer type of a new slice
+ // to a generic i8* pointer. There is a case when using the pointer type
+ // from whole alloca leads to an assertion in PromoteMemToReg.
+ //
+ // A patch is posted to fix this in LLVM:
+ //
+ // https://reviews.llvm.org/D55934
+ // [PATCH] D55934: Assertion in isAllocaPromotable due to extra bitcast
+ // goes into lifetime marker
+ Type *PointerTy = IRB.getInt8PtrTy(OldPtr->getType()->getPointerAddressSpace());
+ Value *Ptr = getNewAllocaSlicePtr(IRB, PointerTy);
+
Value *New;
if (II.getIntrinsicID() == Intrinsic::lifetime_start)
New = IRB.CreateLifetimeStart(Ptr, Size);

0 comments on commit 703b033

Please sign in to comment.