<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">I didn’t take a detail look on the problem you encountered, but early this October(5.0 is released in Sep I remembered), I fixed a bug related to exitStub in CodeExtractor:</div><div class=""><a href="https://reviews.llvm.org/rL315041" class="">https://reviews.llvm.org/rL315041</a></div><div class="">In short, I change the behavior of output variable restoring</div><div class="">Hope this helps</div><div class=""><br class=""></div><div class="">Regards,</div><div class="">Min-Yih<br class=""><div><blockquote type="cite" class=""><div class="">Pei Wang via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> 於 2017年11月29日 上午9:26 寫道:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; 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; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class="">Hi All,<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class="">I’m currently working on a simple task which needs to transform loops into tail-recursive functions. I found the CodeExtractor class a handy helper to use, but later encountered a problem.<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class="">Consider the following CU<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">struct S { int a, b; };<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">int foo(struct S *s, unsigned n) {<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  struct S *next = s;<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  unsigned i;<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  for (i = 0; i < n; ++i) {<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">    if (!s[i].a)<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">      break;<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">    next = s + i;<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  }<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  return next->b;<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">}<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class="">clang 5.0 gives the following IR with O1 optimizations<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">%struct.S = type { i32, i32 }<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">; Function Attrs: norecurse nounwind readonly uwtable<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">define i32 @foo(%struct.S* nocapture readonly, i32) local_unnamed_addr #0 {<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %3 = icmp eq i32 %1, 0<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  br i1 %3, label %16, label %4<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">; <label>:4:                                      ; preds = %2<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  br label %7<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">; <label>:5:                                      ; preds = %7<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %6 = icmp ult i32 %15, %1<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  br i1 %6, label %7, label %16<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">; <label>:7:                                      ; preds = %4, %5<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %8 = phi i32 [ %15, %5 ], [ 0, %4 ]<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %9 = phi %struct.S* [ %11, %5 ], [ %0, %4 ]<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %10 = zext i32 %8 to i64<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %11 = getelementptr inbounds %struct.S, %struct.S* %0, i64 %10<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %12 = getelementptr inbounds %struct.S, %struct.S* %11, i64 0, i32 0<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %13 = load i32, i32* %12, align 4, !tbaa !2<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %14 = icmp eq i32 %13, 0<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %15 = add i32 %8, 1<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  br i1 %14, label %16, label %5<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">; <label>:16:                                     ; preds = %5, %7, %2<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %17 = phi %struct.S* [ %0, %2 ], [ %9, %7 ], [ %11, %5 ]<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %18 = getelementptr inbounds %struct.S, %struct.S* %17, i64 0, i32 1<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %19 = load i32, i32* %18, align 4, !tbaa !7<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  ret i32 %19<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">}<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class="">Here %17 should be noted, which is a phi with 3 incoming blocks, with two of them being part of the loop.<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class="">After using CodeExtractor to extract the loop into a new function, I got<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">%struct.S = type { i32, i32 }<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">; Function Attrs: norecurse nounwind readonly uwtable<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">define i32 @foo(%struct.S* nocapture readonly, i32) local_unnamed_addr #0 {<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %.loc1 = alloca %struct.S*<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %.loc = alloca %struct.S*<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %3 = icmp eq i32 %1, 0<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  br i1 %3, label %5, label %4<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">; <label>:4:                                      ; preds = %2<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  br label %codeRepl<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">codeRepl:                                         ; preds = %4<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  call void @foo_(%struct.S* %0, i32 %1, %struct.S** %.loc, %struct.S** %.loc1)<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %.reload = load %struct.S*, %struct.S** %.loc<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %.reload2 = load %struct.S*, %struct.S** %.loc1<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  br label %.loopexit<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">.loopexit:                                        ; preds = %codeRepl<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %.ph = phi %struct.S* [ %.reload2, %codeRepl ], [ %.reload, %codeRepl ]<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  br label %5<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">; <label>:5:                                      ; preds = %.loopexit, %2<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %6 = phi %struct.S* [ %0, %2 ], [ %.ph, %.loopexit ]<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %7 = getelementptr inbounds %struct.S, %struct.S* %6, i64 0, i32 1<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %8 = load i32, i32* %7, align 4, !tbaa !2<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  ret i32 %8<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">}<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">; Function Attrs: nounwind uwtable<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">define internal void @foo_(%struct.S*, i32, %struct.S** %.out, %struct.S** %.out1) #1 {<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">newFuncRoot:<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  br label %2<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">.loopexit.exitStub:                               ; preds = %11, %2<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  store %struct.S* %4, %struct.S** %.out<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  store %struct.S* %6, %struct.S** %.out1<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  ret void<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">; <label>:2:                                      ; preds = %newFuncRoot, %11<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %3 = phi i32 [ %10, %11 ], [ 0, %newFuncRoot ]<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %4 = phi %struct.S* [ %6, %11 ], [ %0, %newFuncRoot ]<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %5 = zext i32 %3 to i64<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %6 = getelementptr inbounds %struct.S, %struct.S* %0, i64 %5<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %7 = getelementptr inbounds %struct.S, %struct.S* %6, i64 0, i32 0<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %8 = load i32, i32* %7, align 4, !tbaa !7<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %9 = icmp eq i32 %8, 0<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %10 = add i32 %3, 1<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  br i1 %9, label %.loopexit.exitStub, label %11<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">; <label>:11:                                     ; preds = %2<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  %12 = icmp ult i32 %10, %1<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">  br i1 %12, label %2, label %.loopexit.exitStub<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt; font-family: 'Courier New', serif;" class="">}<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class="">Now, because the loop is coalesced into a function, the definition of %.ph (derived from %17 in the previous version of IR) in .loopexit becomes funny: two different incoming values for the same incoming block. I was wondering if this is a bug of CodeExtractor or the extractor makes assumptions about the code to be extracted which I’m not aware of.<span class="Apple-converted-space"> </span><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class="">Thanks,<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class="">Pei Wang<o:p class=""></o:p></span></div></div><span 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; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class="">_______________________________________________</span><br 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; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><span 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; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class="">LLVM Developers mailing list</span><br 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; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><a href="mailto:llvm-dev@lists.llvm.org" style="color: rgb(149, 79, 114); text-decoration: underline; 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-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class="">llvm-dev@lists.llvm.org</a><br 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; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" style="color: rgb(149, 79, 114); text-decoration: underline; 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-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br 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; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""></div></blockquote></div><br class=""></div></body></html>