<div dir="ltr">I wasn't able to reproduce the issue with a recent clang. If you want to debug this further, I would recommend emailing llvm-admin to get a bugzilla account and we can discuss further off list.<div><br></div><div>I compiled the pre-processed source code like this, after commenting out some xmmintrin.h prototypes that were recently promoted to builtins:</div><div>$ clang -cc1 -fblocks -fexceptions -fcxx-exceptions -triple x86_64-macosx -O2 integer.cpp -S -emit-llvm -o t.ll</div><div><br></div><div>The resulting IR had the landingpads in the right place.</div><div><br></div><div>If you can send along the -cc1 command line used to generate the invalid LLVM IR and the clang version used, that would be helpful. You can get the -cc1 line by running the normal compilation command and adding -###.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 12, 2016 at 6:00 AM, Johan Wehrli <span dir="ltr"><<a href="mailto:johan.wehrli@strong.codes" target="_blank">johan.wehrli@strong.codes</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Reid,<div><br></div><div>You can find the preprocess source here: <a href="https://reviews.llvm.org/P7928" target="_blank">https://reviews.llvm.<wbr>org/P7928</a></div><div><br></div><div>This is the compile line used: llvm3.9/bin/clang++ -O2 integer.cpp -E &> preprocess.txt</div><div><br></div><div>Greetings,</div><div><br></div><div>Johan<div><div class="h5"><br>
<br><div><blockquote type="cite"><div>On 11 Oct 2016, at 18:02, Reid Kleckner <<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>> wrote:</div><br class="m_-8195477867455923245Apple-interchange-newline"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div>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><br></div><div>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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br><div class="gmail_quote">On Mon, Oct 10, 2016 at 11:30 PM, Johan Wehrli via llvm-dev<span class="m_-8195477867455923245Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.<wbr>org</a>></span>wrote:<br><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">HI,<div><br></div><div>When compiling the open-source software cryptopp (<a href="https://www.cryptopp.com/#download" target="_blank">https://www.cryptopp.com/#dow<wbr>nload</a>) version 5.6.4 I found a strange issue with the IR generated.</div><div><br></div><div>The issue only appears when compiling with -O2 optimisation in the integer.cpp file (the function is _ZN8CryptoPPrsERNSt3__113basic<wbr>_istreamIcNS0_11char_traitsIcE<wbr>EEERNS_7IntegerE -> CryptoPP::operator>>(std::__1:<wbr>:basic_istream<char, std::__1::char_traits<char> >&, CryptoPP::Integer&)).</div><div><br></div><div>The verifier give me these errors:</div><div><br></div><div><div><i>EH pad cannot be in entry block. %4 = landingpad</i></div><div><i>{ i8*, i32 } cleanupLandingPadInst not the first non-PHI instruction in the block. %4 = landingpad { i8*, i32 } cleanup</i></div><div><br></div><div>If I remove the verifier, I am able to compile the whole library and run the test suite without any issue.</div><div><br></div><div>When you look at the whole IR code for the function:</div><div><br></div><div>----------------------</div><div><br></div><div><div>; Function Attrs: ssp uwtable</div><div>define nonnull dereferenceable(168) %"class.std::__1::basic_istrea<wbr>m"* @_ZN8CryptoPPrsERNSt3__113basi<wbr>c_istreamIcNS0_11char_traitsIc<wbr>EEEERNS_7IntegerE(%"class.std:<wbr>:__1::basic_istream"* dereferenceable(168), %"class.CryptoPP::Integer"* dereferenceable(40)) local_unnamed_addr #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {</div><div> <span class="m_-8195477867455923245Apple-converted-space"> </span>%3 = tail call i8* @_ZN8CryptoPP17UnalignedAlloca<wbr>teEm(i64 16)</div><div> <span class="m_-8195477867455923245Apple-converted-space"> </span>%4 = landingpad { i8*, i32 }</div><div>         <span class="m_-8195477867455923245Apple-converted-space"> </span>cleanup</div><div> <span class="m_-8195477867455923245Apple-converted-space"> </span>%5 = icmp eq i8* %3, null</div><div> <span class="m_-8195477867455923245Apple-converted-space"> </span>br i1 %5, label %6, label %8, !prof !22</div><div><br></div><div>; <label>:6:                                      ; preds = %2</div><div> <span class="m_-8195477867455923245Apple-converted-space"> </span>invoke void @__assert_rtn(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__func__._ZN8CryptoPP20Alloca<wbr>torWithCleanupIhLb0EE10dealloc<wbr>ateEPvm, 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>         <span class="m_-8195477867455923245Apple-converted-space"> </span>to label %7 unwind label %10</div><div><br></div><div>; <label>:7:                                      ; preds = %6</div><div> <span class="m_-8195477867455923245Apple-converted-space"> </span>unreachable</div><div><br></div><div>; <label>:8:                                      ; preds = %2</div><div> <span class="m_-8195477867455923245Apple-converted-space"> </span>%9 = tail call { i64, i8* } asm sideeffect "rep stosb", "={cx},={di},{ax},0,1,~{memory<wbr>},~{dirflag},~{fpsr},~{flags}"<wbr>(i32 0, i64 16, i8* nonnull %3) #53, !srcloc !1070</div><div> <span class="m_-8195477867455923245Apple-converted-space"> </span>invoke void @_ZN8CryptoPP19UnalignedDeallo<wbr>cateEPv(i8* nonnull %3)</div><div>         <span class="m_-8195477867455923245Apple-converted-space"> </span>to label %13 unwind label %10</div><div><br></div><div>; <label>:10:                                     ; preds = %8, %6</div><div> <span class="m_-8195477867455923245Apple-converted-space"> </span>%11 = landingpad { i8*, i32 }</div><div>         <span class="m_-8195477867455923245Apple-converted-space"> </span>catch i8* null</div><div> <span class="m_-8195477867455923245Apple-converted-space"> </span>%12 = extractvalue { i8*, i32 } %11, 0</div><div> <span class="m_-8195477867455923245Apple-converted-space"> </span>tail call void @__clang_call_terminate(i8* %12) #59</div><div> <span class="m_-8195477867455923245Apple-converted-space"> </span>unreachable</div><div><br></div><div>; <label>:13:                                     ; preds = %8</div><div> <span class="m_-8195477867455923245Apple-converted-space"> </span>resume { i8*, i32 } %4</div><div>}</div></div><div><br></div><div><div>----------------------</div></div><div><br></div><div>I was not able to understand which optimisation transforms the code like this.</div><div><br></div><div>I have attached the IR code from the function in O0 and O2.</div><div><br></div><div>Greetings,</div><div><br></div><div>Johan</div><div><br></div><div><br></div><div></div></div></div><br><div style="word-wrap:break-word"><div><div></div></div></div><br><div style="word-wrap:break-word"><div><div></div><br></div></div><br>______________________________<wbr>_________________<br>LLVM Developers mailing list<br><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a></blockquote></div></div></div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>