[PATCH] D52067: [inline Cost] Don't mark function accessing varargs as non-inlinable

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 20 05:07:40 PDT 2018


fhahn added a comment.

> I simplified it. I am not sure how I can get rid of va_list; what i am testing is va_start calledin the caller and va_end in the callee. I need to have va_list to pass it from the caller to the callee.

IIUC you can just pass the arglist pointer as i8*, like below

  +define void @caller_with_vastart(i8* %args, ...) {
  +entry:
  +  %ap = alloca i8*, align 4
  +  %ap.ptr = bitcast i8** %ap to i8*
  +  %ap2 = alloca i8*, align 4
  +  %ap2.ptr = bitcast i8** %ap2 to i8*
  +  call void @llvm.va_start(i8* nonnull %ap.ptr)
  +  call fastcc void @callee_with_vaend(i8* nonnull %ap.ptr)
  +  call void @llvm.va_start(i8* nonnull %ap2.ptr)
  +  call fastcc void @callee_with_vaend_alwaysinline(i8* nonnull %ap2.ptr)
  +  ret void
  +}
  +
  +define internal fastcc void @callee_with_vaend_alwaysinline(i8* %a) alwaysinline {
  +entry:
  +  tail call void @llvm.va_end(i8* %a)
  +  ret void
  +}
  +
  +define internal fastcc void @callee_with_vaend(i8* %a) {
  +entry:
  +  tail call void @llvm.va_end(i8* %a)
  +  ret void
  +}



================
Comment at: lib/Analysis/InlineCost.cpp:2081
         case llvm::Intrinsic::localescape:
         // Disallow inlining of functions that access VarArgs.
         case llvm::Intrinsic::vastart:
----------------
This needs changing I think to 'Disallow inlining of functions that initialize a vararg list' or something.


https://reviews.llvm.org/D52067





More information about the llvm-commits mailing list