<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 9 April 2014 18:40, Reid Kleckner <span dir="ltr"><<a href="mailto:reid@kleckner.net" target="_blank">reid@kleckner.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Author: rnk<br>
Date: Wed Apr  9 20:40:15 2014<br>
New Revision: 205948<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=205948&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=205948&view=rev</a><br>
Log:<br>
Avoid crashing when failing to emit a thunk<br>
<br>
If we crash, we raise a crash handler dialog, and that's really<br>
annoying.  Even though we can't emit correct IR until we have musttail,<br>
don't crash.<br></blockquote><div><br></div><div>Two questions, does report_fatal_error raise the dialog? And what happened to running the tests under KillTheDoctor to prevent this?</div><div><br></div><div>Third question, you say "don't crash" but then what *does* it do?</div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Added:<br>
    cfe/trunk/test/CodeGenCXX/microsoft-abi-nontrivial-memptr-thunks.cpp<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/CGCall.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=205948&r1=205947&r2=205948&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=205948&r1=205947&r2=205948&view=diff</a><br>


==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Apr  9 20:40:15 2014<br>
@@ -2546,8 +2546,14 @@ RValue CodeGenFunction::EmitCall(const C<br>
   // FIXME: Do this earlier rather than hacking it in here!<br>
   llvm::Value *ArgMemory = 0;<br>
   if (llvm::StructType *ArgStruct = CallInfo.getArgStruct()) {<br>
-    llvm::AllocaInst *AI = new llvm::AllocaInst(<br>
-        ArgStruct, "argmem", CallArgs.getStackBase()->getNextNode());<br>
+    llvm::Instruction *IP = CallArgs.getStackBase();<br>
+    llvm::AllocaInst *AI;<br>
+    if (IP) {<br>
+      IP = IP->getNextNode();<br>
+      AI = new llvm::AllocaInst(ArgStruct, "argmem", IP);<br>
+    } else {<br>
+      AI = Builder.CreateAlloca(ArgStruct, nullptr, "argmem");<br>
+    }<br>
     AI->setUsedWithInAlloca(true);<br>
     assert(AI->isUsedWithInAlloca() && !AI->isStaticAlloca());<br>
     ArgMemory = AI;<br>
<br>
Added: cfe/trunk/test/CodeGenCXX/microsoft-abi-nontrivial-memptr-thunks.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-nontrivial-memptr-thunks.cpp?rev=205948&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-nontrivial-memptr-thunks.cpp?rev=205948&view=auto</a><br>


==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-nontrivial-memptr-thunks.cpp (added)<br>
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-nontrivial-memptr-thunks.cpp Wed Apr  9 20:40:15 2014<br>
@@ -0,0 +1,11 @@<br>
+// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple=i386-pc-win32 %s -verify<br>
+<br>
+struct A {<br>
+  A();<br>
+  ~A();<br>
+  int a;<br>
+};<br>
+struct B {<br>
+  virtual void f(A); // expected-error {{cannot compile this non-trivial argument copy for thunk yet}}<br>
+};<br>
+void (B::*mp)(A) = &B::f;<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>
</blockquote></div><br></div></div>