[llvm] r324197 - [InlineFunction] Set arg attrs even if there only are VarArg attrs.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 4 10:27:47 PST 2018


Author: fhahn
Date: Sun Feb  4 10:27:47 2018
New Revision: 324197

URL: http://llvm.org/viewvc/llvm-project?rev=324197&view=rev
Log:
[InlineFunction] Set arg attrs even if there only are VarArg attrs.

When using the partial inliner, we might have attributes for forwarded
varargs, but the CodeExtractor does not create an empty argument
attribute set for regular arguments in that case, because it does not know
of the additional arguments. So in case we have attributes for VarArgs, we
also have to make sure we create (empty) attributes for all regular arguments.

This fixes PR36210.


Modified:
    llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
    llvm/trunk/test/Transforms/CodeExtractor/PartialInlineVarArg.ll

Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=324197&r1=324196&r2=324197&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Sun Feb  4 10:27:47 2018
@@ -1843,7 +1843,7 @@ bool llvm::InlineFunction(CallSite CS, I
           // Collect attributes for non-vararg parameters.
           AttributeList Attrs = CI->getAttributes();
           SmallVector<AttributeSet, 8> ArgAttrs;
-          if (!Attrs.isEmpty()) {
+          if (!Attrs.isEmpty() || !VarArgsAttrs.empty()) {
             for (unsigned ArgNo = 0;
                  ArgNo < CI->getFunctionType()->getNumParams(); ++ArgNo)
               ArgAttrs.push_back(Attrs.getParamAttributes(ArgNo));

Modified: llvm/trunk/test/Transforms/CodeExtractor/PartialInlineVarArg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/CodeExtractor/PartialInlineVarArg.ll?rev=324197&r1=324196&r2=324197&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/CodeExtractor/PartialInlineVarArg.ll (original)
+++ llvm/trunk/test/Transforms/CodeExtractor/PartialInlineVarArg.ll Sun Feb  4 10:27:47 2018
@@ -81,3 +81,26 @@ bb:
   %res = tail call i32 (i32, ...) @vararg_not_legal(i32 %arg, i32 %arg)
   ret i32 %res
 }
+
+declare i32* @err(i32*)
+
+define signext i32 @vararg2(i32 * %l, ...) {
+entry:
+  br i1 undef, label %cleanup, label %cond.end
+
+cond.end:                                         ; preds = %entry
+  %call51 = call i32* @err(i32* nonnull %l)
+  unreachable
+
+cleanup:                                          ; preds = %entry
+  ret i32 0
+}
+
+define i32* @caller_with_signext(i32* %foo) {
+entry:
+  %call1 = tail call signext i32 (i32*, ...) @varargs2(i32* %foo, i32 signext 8)
+  unreachable
+}
+; CHECK-LABEL: @caller_with_signext
+; CHECK: codeRepl.i:
+; CHECK-NEXT: call void (i32*, ...) @callee.1_cond.end(i32* %foo, i32 signext 8)




More information about the llvm-commits mailing list