summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorFlorian Hahn <florian.hahn@arm.com>2018-02-04 18:27:47 +0000
committerFlorian Hahn <florian.hahn@arm.com>2018-02-04 18:27:47 +0000
commit8f804fc07d75dede212cee9718033fbfecef709c (patch)
tree60c8116ebbcef160ed09d61ac1bdbbf0d5a22e17 /llvm
parent5b691a10c0dedf626d7164c4f45d02dfb6129a06 (diff)
downloadbcm5719-llvm-8f804fc07d75dede212cee9718033fbfecef709c.tar.gz
bcm5719-llvm-8f804fc07d75dede212cee9718033fbfecef709c.zip
[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. llvm-svn: 324197
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp2
-rw-r--r--llvm/test/Transforms/CodeExtractor/PartialInlineVarArg.ll23
2 files changed, 24 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 5b4b45a69b4..9ad59315c32 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1843,7 +1843,7 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
// 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));
diff --git a/llvm/test/Transforms/CodeExtractor/PartialInlineVarArg.ll b/llvm/test/Transforms/CodeExtractor/PartialInlineVarArg.ll
index 415eb9ba175..fec37711fd9 100644
--- a/llvm/test/Transforms/CodeExtractor/PartialInlineVarArg.ll
+++ b/llvm/test/Transforms/CodeExtractor/PartialInlineVarArg.ll
@@ -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)
OpenPOWER on IntegriCloud