[llvm] 4108326 - OpaquePtr: Make byval/sret types mandatory
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 20 18:23:42 PST 2020
Author: Matt Arsenault
Date: 2020-11-20T21:23:33-05:00
New Revision: 41083267a9d7a006cf5821344480650becd03c3c
URL: https://github.com/llvm/llvm-project/commit/41083267a9d7a006cf5821344480650becd03c3c
DIFF: https://github.com/llvm/llvm-project/commit/41083267a9d7a006cf5821344480650becd03c3c.diff
LOG: OpaquePtr: Make byval/sret types mandatory
Added:
llvm/test/Assembler/byval-parse-error0.ll
llvm/test/Assembler/sret-parse-error0.ll
Modified:
llvm/include/llvm/IR/Function.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/AsmParser/LLParser.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h
index 061223d3bd78..1736b3ed0363 100644
--- a/llvm/include/llvm/IR/Function.h
+++ b/llvm/include/llvm/IR/Function.h
@@ -472,14 +472,12 @@ class Function : public GlobalObject, public ilist_node<Function> {
/// Extract the byval type for a parameter.
Type *getParamByValType(unsigned ArgNo) const {
- Type *Ty = AttributeSets.getParamByValType(ArgNo);
- return Ty ? Ty : (arg_begin() + ArgNo)->getType()->getPointerElementType();
+ return AttributeSets.getParamByValType(ArgNo);
}
/// Extract the sret type for a parameter.
Type *getParamStructRetType(unsigned ArgNo) const {
- Type *Ty = AttributeSets.getParamStructRetType(ArgNo);
- return Ty ? Ty : (arg_begin() + ArgNo)->getType()->getPointerElementType();
+ return AttributeSets.getParamStructRetType(ArgNo);
}
/// Extract the byref type for a parameter.
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 4f343dc9595d..42403f7d6c46 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -1699,14 +1699,14 @@ bool LLParser::parseOptionalParamAttrs(AttrBuilder &B) {
}
case lltok::kw_byval: {
Type *Ty;
- if (parseOptionalTypeAttr(Ty, lltok::kw_byval))
+ if (parseRequiredTypeAttr(Ty, lltok::kw_byval))
return true;
B.addByValAttr(Ty);
continue;
}
case lltok::kw_sret: {
Type *Ty;
- if (parseOptionalTypeAttr(Ty, lltok::kw_sret))
+ if (parseRequiredTypeAttr(Ty, lltok::kw_sret))
return true;
B.addStructRetAttr(Ty);
continue;
@@ -2628,22 +2628,6 @@ bool LLParser::parseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
return false;
}
-/// parseByValWithOptionalType
-/// ::= byval
-/// ::= byval(<ty>)
-bool LLParser::parseOptionalTypeAttr(Type *&Result, lltok::Kind AttrName) {
- Result = nullptr;
- if (!EatIfPresent(AttrName))
- return true;
- if (!EatIfPresent(lltok::lparen))
- return false;
- if (parseType(Result))
- return true;
- if (!EatIfPresent(lltok::rparen))
- return error(Lex.getLoc(), "expected ')'");
- return false;
-}
-
/// parseRequiredTypeAttr
/// ::= attrname(<ty>)
bool LLParser::parseRequiredTypeAttr(Type *&Result, lltok::Kind AttrName) {
diff --git a/llvm/lib/AsmParser/LLParser.h b/llvm/lib/AsmParser/LLParser.h
index f891f7344398..d86921ebd25e 100644
--- a/llvm/lib/AsmParser/LLParser.h
+++ b/llvm/lib/AsmParser/LLParser.h
@@ -328,7 +328,6 @@ namespace llvm {
bool parseFnAttributeValuePairs(AttrBuilder &B,
std::vector<unsigned> &FwdRefAttrGrps,
bool inAttrGrp, LocTy &BuiltinLoc);
- bool parseOptionalTypeAttr(Type *&Result, lltok::Kind AttrName);
bool parseRequiredTypeAttr(Type *&Result, lltok::Kind AttrName);
bool parsePreallocated(Type *&Result);
bool parseByRef(Type *&Result);
diff --git a/llvm/test/Assembler/byval-parse-error0.ll b/llvm/test/Assembler/byval-parse-error0.ll
new file mode 100644
index 000000000000..c451ceea0ba2
--- /dev/null
+++ b/llvm/test/Assembler/byval-parse-error0.ll
@@ -0,0 +1,6 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+
+; CHECK: <stdin>:[[@LINE+1]]:34: error: expected '('{{$}}
+define void @test_byval(i8* byval) {
+ ret void
+}
diff --git a/llvm/test/Assembler/sret-parse-error0.ll b/llvm/test/Assembler/sret-parse-error0.ll
new file mode 100644
index 000000000000..47a4aac3fa4a
--- /dev/null
+++ b/llvm/test/Assembler/sret-parse-error0.ll
@@ -0,0 +1,6 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+
+; CHECK: <stdin>:[[@LINE+1]]:32: error: expected '('{{$}}
+define void @test_sret(i8* sret) {
+ ret void
+}
More information about the llvm-commits
mailing list