<div dir="ltr">Thanks for the debugging help! Relanded with tests fixed for -Asserts in r230503.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 25, 2015 at 2:15 AM, NAKAMURA Takumi <span dir="ltr"><<a href="mailto:geek4civic@gmail.com" target="_blank">geek4civic@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The test was failing with -Asserts.<br>
<br>
--- a/clang/test/CodeGen/exceptions-seh-finally.c<br>
+++ b/clang/test/CodeGen/exceptions-seh-finally.c<br>
@@ -189,12 +189,12 @@ int nested___finally___finally() {<br>
   return 0;<br>
 }<br>
 // CHECK-LABEL: define i32 @nested___finally___finally<br>
<span class="">-// CHECK: store i8 0, i8* %<br>
</span>+// CHECK: store i8 0, i8* [[ABT:%.+]]<br>
<span class=""> // CHECK-NEXT: br label %[[finally:[^ ]*]]<br>
</span> //<br>
<span class=""> // CHECK: [[finally]]<br>
-// CHECK-NEXT:  store i32 1, i32* %cleanup.dest.slot<br>
-// CHECK-NEXT:  store i8 0, i8* %abnormal.termination.slot<br>
</span>+// CHECK-NEXT:  store i32 1, i32* %<br>
+// CHECK-NEXT:  store i8 0, i8* [[ABT]]<br>
<span class=""> // CHECK-NEXT: br label %[[outerfinally:[^ ]*]]<br>
</span> //<br>
 // CHECK: [[outerfinally]]<br>
<div class="HOEnZb"><div class="h5"><br>
2015-02-25 19:06 GMT+09:00 Daniel Jasper <<a href="mailto:djasper@google.com">djasper@google.com</a>>:<br>
> This is breaking tests on buildbots:<br>
> <a href="http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/2279/" target="_blank">http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/2279/</a><br>
><br>
> Rolling back.<br>
><br>
> On Wed, Feb 25, 2015 at 5:05 AM, Nico Weber <<a href="mailto:nicolasweber@gmx.de">nicolasweber@gmx.de</a>> wrote:<br>
>><br>
>> Author: nico<br>
>> Date: Tue Feb 24 22:05:18 2015<br>
>> New Revision: 230460<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=230460&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=230460&view=rev</a><br>
>> Log:<br>
>> Produce less broken basic block sequences for __finally blocks.<br>
>><br>
>> The way cleanups (such as PerformSEHFinally) get emitted is that codegen<br>
>> generates some initialization code, then calls the cleanup's Emit() with<br>
>> the<br>
>> insertion point set to a good place, then the cleanup is supposed to emit<br>
>> its<br>
>> stuff, and then codegen might tack in a jump or similar to where the<br>
>> insertion<br>
>> point is after the cleanup.<br>
>><br>
>> The PerformSEHFinally cleanup tries to just stash away the block it's<br>
>> supposed<br>
>> to codegen into, and then does codegen later, into that stashed block.<br>
>> However,<br>
>> after codegen'ing the __finally block, it used to set the insertion point<br>
>> to<br>
>> the finally's continuation block (where the __finally cleanup goes when<br>
>> its body<br>
>> is completed after regular, non-exceptional control flow).  That's not<br>
>> correct,<br>
>> as that block can (and generally does) already ends in a jump.  Instead,<br>
>> remember the insertion point that was current before the __finally got<br>
>> emitted,<br>
>> and restore that.<br>
>><br>
>> Fixes two of the crashes in PR22553.<br>
>><br>
>> Modified:<br>
>>     cfe/trunk/lib/CodeGen/CGException.cpp<br>
>>     cfe/trunk/test/CodeGen/exceptions-seh-finally.c<br>
>><br>
>> Modified: cfe/trunk/lib/CodeGen/CGException.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=230460&r1=230459&r2=230460&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=230460&r1=230459&r2=230460&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/lib/CodeGen/CGException.cpp (original)<br>
>> +++ cfe/trunk/lib/CodeGen/CGException.cpp Tue Feb 24 22:05:18 2015<br>
>> @@ -813,8 +813,8 @@ llvm::BasicBlock *CodeGenFunction::EmitL<br>
>>    bool hasFilter = false;<br>
>>    SmallVector<llvm::Value*, 4> filterTypes;<br>
>>    llvm::SmallPtrSet<llvm::Value*, 4> catchTypes;<br>
>> -  for (EHScopeStack::iterator I = EHStack.begin(), E = EHStack.end();<br>
>> -         I != E; ++I) {<br>
>> +  for (EHScopeStack::iterator I = EHStack.begin(), E = EHStack.end(); I<br>
>> != E;<br>
>> +       ++I) {<br>
>><br>
>>      switch (I->getKind()) {<br>
>>      case EHScope::Cleanup:<br>
>> @@ -1927,6 +1927,7 @@ void CodeGenFunction::ExitSEHTryStmt(con<br>
>>      assert(FI.ContBB && "did not emit normal cleanup");<br>
>><br>
>>      // Emit the code into FinallyBB.<br>
>> +    CGBuilderTy::InsertPoint SavedIP = Builder.saveIP();<br>
>>      Builder.SetInsertPoint(FI.FinallyBB);<br>
>>      EmitStmt(Finally->getBlock());<br>
>><br>
>> @@ -1949,7 +1950,7 @@ void CodeGenFunction::ExitSEHTryStmt(con<br>
>>        Builder.CreateBr(FI.ContBB);<br>
>>      }<br>
>><br>
>> -    Builder.SetInsertPoint(FI.ContBB);<br>
>> +    Builder.restoreIP(SavedIP);<br>
>><br>
>>      return;<br>
>>    }<br>
>><br>
>> Modified: cfe/trunk/test/CodeGen/exceptions-seh-finally.c<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exceptions-seh-finally.c?rev=230460&r1=230459&r2=230460&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exceptions-seh-finally.c?rev=230460&r1=230459&r2=230460&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/CodeGen/exceptions-seh-finally.c (original)<br>
>> +++ cfe/trunk/test/CodeGen/exceptions-seh-finally.c Tue Feb 24 22:05:18<br>
>> 2015<br>
>> @@ -160,3 +160,45 @@ void noreturn_finally() {<br>
>>  // CHECK-NEXT: cleanup<br>
>>  // CHECK: store i8 1, i8* %<br>
>>  // CHECK: br label %[[finally]]<br>
>> +<br>
>> +int finally_with_return() {<br>
>> +  __try {<br>
>> +    return 42;<br>
>> +  } __finally {<br>
>> +  }<br>
>> +}<br>
>> +// CHECK-LABEL: define i32 @finally_with_return()<br>
>> +// CHECK: store i8 0, i8* %<br>
>> +// CHECK-NEXT: br label %[[finally:[^ ]*]]<br>
>> +//<br>
>> +// CHECK: [[finally]]<br>
>> +// CHECK-NEXT: br label %[[finallycont:[^ ]*]]<br>
>> +//<br>
>> +// CHECK: [[finallycont]]<br>
>> +// CHECK-NEXT: ret i32 42<br>
>> +<br>
>> +int nested___finally___finally() {<br>
>> +  __try {<br>
>> +    __try {<br>
>> +    } __finally {<br>
>> +      return 1;<br>
>> +    }<br>
>> +  } __finally {<br>
>> +    // Intentionally no return here.<br>
>> +  }<br>
>> +  return 0;<br>
>> +}<br>
>> +// CHECK-LABEL: define i32 @nested___finally___finally<br>
>> +// CHECK: store i8 0, i8* %<br>
>> +// CHECK-NEXT: br label %[[finally:[^ ]*]]<br>
>> +//<br>
>> +// CHECK: [[finally]]<br>
>> +// CHECK-NEXT:  store i32 1, i32* %cleanup.dest.slot<br>
>> +// CHECK-NEXT:  store i8 0, i8* %abnormal.termination.slot<br>
>> +// CHECK-NEXT: br label %[[outerfinally:[^ ]*]]<br>
>> +//<br>
>> +// CHECK: [[outerfinally]]<br>
>> +// CHECK-NEXT: br label %[[finallycont:[^ ]*]]<br>
>> +//<br>
>> +// CHECK: [[finallycont]]<br>
>> +// CHECK-NEXT: ret i32 1<br>
>><br>
>><br>
>> _______________________________________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
><br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div>