<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="">Hi Reid,<div class=""><br class=""></div><div class="">You can find the preprocess source here: <a href="https://reviews.llvm.org/P7928" class="">https://reviews.llvm.org/P7928</a></div><div class=""><br class=""></div><div class="">This is the compile line used: llvm3.9/bin/clang++ -O2 integer.cpp -E &> preprocess.txt</div><div class=""><br class=""></div><div class="">Greetings,</div><div class=""><br class=""></div><div class="">Johan<br class="">
<br class=""><div style=""><blockquote type="cite" class=""><div class="">On 11 Oct 2016, at 18:02, Reid Kleckner <<a href="mailto:rnk@google.com" class="">rnk@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="">That's an interesting bug. Can you post the pre-processed source code somewhere? I can't optimize the O0.ll file because it only contains the function, and none of the struct types.</div><div class=""><br class=""></div><div class="">Usually pre-processed source is large, so I wouldn't recommend mailing it to the list. I'd suggest our bugzilla, but you can't create new accounts right now without mailing llvm-admin.</div></div><div class="gmail_extra" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""><div class="gmail_quote">On Mon, Oct 10, 2016 at 11:30 PM, Johan Wehrli via llvm-dev<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>></span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class="">HI,<div class=""><br class=""></div><div class="">When compiling the open-source software cryptopp (<a href="https://www.cryptopp.com/#download" target="_blank" class="">https://www.cryptopp.com/#<wbr class="">download</a>) version 5.6.4 I found a strange issue with the IR generated.</div><div class=""><br class=""></div><div class="">The issue only appears when compiling with -O2 optimisation in the integer.cpp file (the function is _ZN8CryptoPPrsERNSt3__<wbr class="">113basic_istreamIcNS0_11char_<wbr class="">traitsIcEEEERNS_7IntegerE -> CryptoPP::operator>>(std::__1:<wbr class="">:basic_istream<char, std::__1::char_traits<char> >&, CryptoPP::Integer&)).</div><div class=""><br class=""></div><div class="">The verifier give me these errors:</div><div class=""><br class=""></div><div class=""><div class=""><i class="">EH pad cannot be in entry block. %4 = landingpad</i></div><div class=""><i class="">{ i8*, i32 } cleanupLandingPadInst not the first non-PHI instruction in the block. %4 = landingpad { i8*, i32 } cleanup</i></div><div class=""><br class=""></div><div class="">If I remove the verifier, I am able to compile the whole library and run the test suite without any issue.</div><div class=""><br class=""></div><div class="">When you look at the whole IR code for the function:</div><div class=""><br class=""></div><div class="">----------------------</div><div class=""><br class=""></div><div class=""><div class="">; Function Attrs: ssp uwtable</div><div class="">define nonnull dereferenceable(168) %"class.std::__1::basic_<wbr class="">istream"* @_ZN8CryptoPPrsERNSt3__<wbr class="">113basic_istreamIcNS0_11char_<wbr class="">traitsIcEEEERNS_7IntegerE(%"<wbr class="">class.std::__1::basic_istream"<wbr class="">* dereferenceable(168), %"class.CryptoPP::Integer"* dereferenceable(40)) local_unnamed_addr #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {</div><div class=""> <span class="Apple-converted-space"> </span>%3 = tail call i8* @_<wbr class="">ZN8CryptoPP17UnalignedAllocate<wbr class="">Em(i64 16)</div><div class=""> <span class="Apple-converted-space"> </span>%4 = landingpad { i8*, i32 }</div><div class=""> <span class="Apple-converted-space"> </span>cleanup</div><div class=""> <span class="Apple-converted-space"> </span>%5 = icmp eq i8* %3, null</div><div class=""> <span class="Apple-converted-space"> </span>br i1 %5, label %6, label %8, !prof !22</div><div class=""><br class=""></div><div class="">; <label>:6: ; preds = %2</div><div class=""> <span class="Apple-converted-space"> </span>invoke void @__assert_rtn(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__func__._<wbr class="">ZN8CryptoPP20AllocatorWithClea<wbr class="">nupIhLb0EE10deallocateEPvm, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.64, i64 0, i64 0), i32 197, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.75, i64 0, i64 0)) #58</div><div class=""> <span class="Apple-converted-space"> </span>to label %7 unwind label %10</div><div class=""><br class=""></div><div class="">; <label>:7: ; preds = %6</div><div class=""> <span class="Apple-converted-space"> </span>unreachable</div><div class=""><br class=""></div><div class="">; <label>:8: ; preds = %2</div><div class=""> <span class="Apple-converted-space"> </span>%9 = tail call { i64, i8* } asm sideeffect "rep stosb", "={cx},={di},{ax},0,1,~{<wbr class="">memory},~{dirflag},~{fpsr},~{<wbr class="">flags}"(i32 0, i64 16, i8* nonnull %3) #53, !srcloc !1070</div><div class=""> <span class="Apple-converted-space"> </span>invoke void @_<wbr class="">ZN8CryptoPP19UnalignedDealloca<wbr class="">teEPv(i8* nonnull %3)</div><div class=""> <span class="Apple-converted-space"> </span>to label %13 unwind label %10</div><div class=""><br class=""></div><div class="">; <label>:10: ; preds = %8, %6</div><div class=""> <span class="Apple-converted-space"> </span>%11 = landingpad { i8*, i32 }</div><div class=""> <span class="Apple-converted-space"> </span>catch i8* null</div><div class=""> <span class="Apple-converted-space"> </span>%12 = extractvalue { i8*, i32 } %11, 0</div><div class=""> <span class="Apple-converted-space"> </span>tail call void @__clang_call_terminate(i8* %12) #59</div><div class=""> <span class="Apple-converted-space"> </span>unreachable</div><div class=""><br class=""></div><div class="">; <label>:13: ; preds = %8</div><div class=""> <span class="Apple-converted-space"> </span>resume { i8*, i32 } %4</div><div class="">}</div></div><div class=""><br class=""></div><div class=""><div class="">----------------------</div></div><div class=""><br class=""></div><div class="">I was not able to understand which optimisation transforms the code like this.</div><div class=""><br class=""></div><div class="">I have attached the IR code from the function in O0 and O2.</div><div class=""><br class=""></div><div class="">Greetings,</div><div class=""><br class=""></div><div class="">Johan</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""></div></div></div><br class=""><div style="word-wrap: break-word;" class=""><div class=""><div class=""></div></div></div><br class=""><div style="word-wrap: break-word;" class=""><div class=""><div class=""></div><br class=""></div></div><br class="">______________________________<wbr class="">_________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-dev</a></blockquote></div></div></div></blockquote></div><br class=""></div></body></html>