aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 3644fab..ce0f710 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -514,8 +514,15 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace,
// Ensure intrinsics have the right parameter attributes.
// Note, the IntID field will have been set in Value::setName if this function
// name is a valid intrinsic ID.
- if (IntID)
- setAttributes(Intrinsic::getAttributes(getContext(), IntID));
+ if (IntID) {
+ // Don't set the attributes if the intrinsic signature is invalid. This
+ // case will either be auto-upgraded or fail verification.
+ SmallVector<Type *> OverloadTys;
+ if (!Intrinsic::getIntrinsicSignature(IntID, Ty, OverloadTys))
+ return;
+
+ setAttributes(Intrinsic::getAttributes(getContext(), IntID, Ty));
+ }
}
Function::~Function() {