aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Function.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2007-12-03 20:06:50 +0000
committerDuncan Sands <baldrick@free.fr>2007-12-03 20:06:50 +0000
commita3355ffb3d30d19d226bbb75707991c60f236e37 (patch)
tree926575d8f1c3a0104fa7ea7236dd1842120e29cd /lib/VMCore/Function.cpp
parent4cf4b69330f0b2a3ba325bcdb1ff41847c022260 (diff)
downloadexternal_llvm-a3355ffb3d30d19d226bbb75707991c60f236e37.zip
external_llvm-a3355ffb3d30d19d226bbb75707991c60f236e37.tar.gz
external_llvm-a3355ffb3d30d19d226bbb75707991c60f236e37.tar.bz2
Rather than having special rules like "intrinsics cannot
throw exceptions", just mark intrinsics with the nounwind attribute. Likewise, mark intrinsics as readnone/readonly and get rid of special aliasing logic (which didn't use anything more than this anyway). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44544 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Function.cpp')
-rw-r--r--lib/VMCore/Function.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index 3794955..04db3aa 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -18,6 +18,7 @@
#include "llvm/Support/LeakDetector.h"
#include "llvm/Support/ManagedStatic.h"
#include "SymbolTableListTraitsImpl.h"
+#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/StringExtras.h"
using namespace llvm;
@@ -435,12 +436,36 @@ const FunctionType *Intrinsic::getType(ID id, const Type **Tys,
return FunctionType::get(ResultTy, ArgTys, IsVarArg);
}
+const ParamAttrsList *Intrinsic::getParamAttrs(ID id) {
+ static const ParamAttrsList *IntrinsicAttributes[Intrinsic::num_intrinsics];
+
+ if (IntrinsicAttributes[id])
+ return IntrinsicAttributes[id];
+
+ ParamAttrsVector Attrs;
+ uint16_t Attr = ParamAttr::None;
+
+#define GET_INTRINSIC_ATTRIBUTES
+#include "llvm/Intrinsics.gen"
+#undef GET_INTRINSIC_ATTRIBUTES
+
+ // Intrinsics cannot throw exceptions.
+ Attr |= ParamAttr::NoUnwind;
+
+ Attrs.push_back(ParamAttrsWithIndex::get(0, Attr));
+ IntrinsicAttributes[id] = ParamAttrsList::get(Attrs);
+ return IntrinsicAttributes[id];
+}
+
Function *Intrinsic::getDeclaration(Module *M, ID id, const Type **Tys,
unsigned numTys) {
-// There can never be multiple globals with the same name of different types,
-// because intrinsics must be a specific type.
- return cast<Function>(M->getOrInsertFunction(getName(id, Tys, numTys),
- getType(id, Tys, numTys)));
+ // There can never be multiple globals with the same name of different types,
+ // because intrinsics must be a specific type.
+ Function *F =
+ cast<Function>(M->getOrInsertFunction(getName(id, Tys, numTys),
+ getType(id, Tys, numTys)));
+ F->setParamAttrs(getParamAttrs(id));
+ return F;
}
Value *IntrinsicInst::StripPointerCasts(Value *Ptr) {