r205948 - Avoid crashing when failing to emit a thunk

Nick Lewycky nlewycky at google.com
Tue Apr 22 16:03:06 PDT 2014


On 9 April 2014 18:40, Reid Kleckner <reid at kleckner.net> wrote:

> Author: rnk
> Date: Wed Apr  9 20:40:15 2014
> New Revision: 205948
>
> URL: http://llvm.org/viewvc/llvm-project?rev=205948&view=rev
> Log:
> Avoid crashing when failing to emit a thunk
>
> If we crash, we raise a crash handler dialog, and that's really
> annoying.  Even though we can't emit correct IR until we have musttail,
> don't crash.
>

Two questions, does report_fatal_error raise the dialog? And what happened
to running the tests under KillTheDoctor to prevent this?

Third question, you say "don't crash" but then what *does* it do?


>
> Added:
>     cfe/trunk/test/CodeGenCXX/microsoft-abi-nontrivial-memptr-thunks.cpp
> Modified:
>     cfe/trunk/lib/CodeGen/CGCall.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=205948&r1=205947&r2=205948&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Apr  9 20:40:15 2014
> @@ -2546,8 +2546,14 @@ RValue CodeGenFunction::EmitCall(const C
>    // FIXME: Do this earlier rather than hacking it in here!
>    llvm::Value *ArgMemory = 0;
>    if (llvm::StructType *ArgStruct = CallInfo.getArgStruct()) {
> -    llvm::AllocaInst *AI = new llvm::AllocaInst(
> -        ArgStruct, "argmem", CallArgs.getStackBase()->getNextNode());
> +    llvm::Instruction *IP = CallArgs.getStackBase();
> +    llvm::AllocaInst *AI;
> +    if (IP) {
> +      IP = IP->getNextNode();
> +      AI = new llvm::AllocaInst(ArgStruct, "argmem", IP);
> +    } else {
> +      AI = Builder.CreateAlloca(ArgStruct, nullptr, "argmem");
> +    }
>      AI->setUsedWithInAlloca(true);
>      assert(AI->isUsedWithInAlloca() && !AI->isStaticAlloca());
>      ArgMemory = AI;
>
> Added: cfe/trunk/test/CodeGenCXX/microsoft-abi-nontrivial-memptr-thunks.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-nontrivial-memptr-thunks.cpp?rev=205948&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/microsoft-abi-nontrivial-memptr-thunks.cpp
> (added)
> +++ cfe/trunk/test/CodeGenCXX/microsoft-abi-nontrivial-memptr-thunks.cpp
> Wed Apr  9 20:40:15 2014
> @@ -0,0 +1,11 @@
> +// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple=i386-pc-win32 %s
> -verify
> +
> +struct A {
> +  A();
> +  ~A();
> +  int a;
> +};
> +struct B {
> +  virtual void f(A); // expected-error {{cannot compile this non-trivial
> argument copy for thunk yet}}
> +};
> +void (B::*mp)(A) = &B::f;
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140422/037308b3/attachment.html>


More information about the cfe-commits mailing list