[PATCH] Verifier: Don't reject varargs callee cleanup functions

Reid Kleckner rnk at google.com
Thu Aug 28 14:01:53 PDT 2014


Clang also used to generate code like:

  define x86_thiscallcc i32 @my_vmemptr(i8*, i32, i32) {
  entry:
    %retslot = alloca i32
    %r = musttail call @my_target(i8* %0, i32 %1, i32 %2)
    ret i32 %r
  exit: ; no predecessors!
    %ret = load i32* %retslot
    ret i32 %ret
  }

While we don't do that today, should the verifier reject such code? Should it ignore unreachable blocks?

We could report_fatal_error in TLI::LowerReturn if isVarArgs&&isCalleeCleanup, but then we would abort on this precise example at -O0.

You can also imagine replacing the musttail call with a call to abort + unreachable.

================
Comment at: lib/Target/X86/X86ISelLowering.cpp:3550
@@ -3552,4 +3549,3 @@
     return false;
   case CallingConv::X86_StdCall:
   case CallingConv::X86_FastCall:
----------------
nlewycky wrote:
> Isn't there a fallthrough annotation or comment to use here?
I thought it was OK to have multiple case labels one after another without annotating fallthrough. The whitespace in phab isn't actually present in the code, see the missing line number on the left.

http://reviews.llvm.org/D5059






More information about the llvm-commits mailing list