<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">Committed revision 270479</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-family: Helvetica;" class="">Thanks, David!</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On May 16, 2016, at 11:37 PM, Gerolf Hoflehner <<a href="mailto:ghoflehner@apple.com" class="">ghoflehner@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Gerolf created this revision.<br class="">Gerolf added a reviewer: llvm-commits.<br class=""><br class="">When an aggregate contains an opaque type its size cannot be<br class="">determined. This triggers an "Invalid GetElementPtrInst indices for type" assert<br class="">in function checkGEPType. The patch suppresses the conversion in this case.<br class=""><br class=""><a href="http://reviews.llvm.org/D20319" class="">http://reviews.llvm.org/D20319</a><br class=""><br class="">Files:<br class="">  lib/Transforms/InstCombine/InstCombineCasts.cpp<br class="">  test/Transforms/InstCombine/opaque.ll<br class=""><br class="">Index: test/Transforms/InstCombine/opaque.ll<br class="">===================================================================<br class="">--- /dev/null<br class="">+++ test/Transforms/InstCombine/opaque.ll<br class="">@@ -0,0 +1,32 @@<br class="">+; RUN: opt < %s -instcombine -disable-output<br class="">+; Checks that bitcasts are not converted into GEP when<br class="">+; when the size of an aggregate cannot be determined.<br class="">+%swift.opaque = type opaque<br class="">+%SQ = type <{ [8 x i8] }><br class="">+%Si = type <{ i64 }><br class="">+<br class="">+%V = type <{ <{ %Vs4Int8, %Vs4Int8, %Vs4Int8, %Vs4Int8, %Vs4Int8, %Vs4Int8, %Vs4Int8, %Vs4Int8 }>, %Si, %SQ, %SQ, %Si, %swift.opaque }><br class="">+%Vs4Int8 = type <{ i8 }><br class="">+%swift.type = type { i64 }<br class="">+<br class="">+declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly,<br class="">+i64, i32, i1) #8<br class="">+<br class="">+@_swift_slowAlloc = external global i8* (i64, i64)*<br class="">+<br class="">+declare i8* @rt_swift_slowAlloc(i64, i64)<br class="">+<br class="">+define  %swift.opaque* @_TwTkV([24 x i8]* %dest, %swift.opaque* %src,<br class="">+%swift.type* %bios_boot_params) #0 {<br class="">+entry:<br class="">+  %0 = bitcast %swift.opaque* %src to %V*<br class="">+  %1 = call noalias i8* @rt_swift_slowAlloc(i64 40, i64 0) #11<br class="">+  %2 = bitcast [24 x i8]* %dest to i8**<br class="">+  store i8* %1, i8** %2, align 8<br class="">+  %3 = bitcast i8* %1 to %V*<br class="">+  %4 = bitcast %V* %3 to i8*<br class="">+  %5 = bitcast %V* %0 to i8*<br class="">+  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %4, i8* %5, i64 40, i32 1, i1 false)<br class="">+  %6 = bitcast %V* %3 to %swift.opaque*<br class="">+  ret %swift.opaque* %6<br class="">+}<br class="">Index: lib/Transforms/InstCombine/InstCombineCasts.cpp<br class="">===================================================================<br class="">--- lib/Transforms/InstCombine/InstCombineCasts.cpp<br class="">+++ lib/Transforms/InstCombine/InstCombineCasts.cpp<br class="">@@ -1915,6 +1915,11 @@<br class="">       if (Instruction *V = PromoteCastOfAllocation(CI, *AI))<br class="">         return V;<br class=""><br class="">+    Type *PointeeType =<br class="">+        cast<PointerType>(Src->getType()->getScalarType())->getElementType();<br class="">+    if (!PointeeType->isSized())<br class="">+      return nullptr;<br class="">+<br class="">     // If the source and destination are pointers, and this cast is equivalent<br class="">     // to a getelementptr X, 0, 0, 0...  turn it into the appropriate gep.<br class="">     // This can enhance SROA and other transforms that want type-safe pointers.<br class=""><br class=""><br class=""><span id="cid:BE902CD7-4FF2-4B6D-B166-2BA1EF4C80EB@apple.com"><D20319.57435.patch></span></div></div></blockquote></div><br class=""></div></body></html>