summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-04-07 13:45:04 +0000
committerDuncan Sands <baldrick@free.fr>2008-04-07 13:45:04 +0000
commite2c4304654442ca353b307d73c86dce2a4acadbf (patch)
tree9af3752cb94fdcdfdd719ba7917427fd01ac97ca /lib
parent3d292aca0306fbb65da4622c80df01432ab6559b (diff)
downloadllvm-e2c4304654442ca353b307d73c86dce2a4acadbf.tar.gz
llvm-e2c4304654442ca353b307d73c86dce2a4acadbf.tar.bz2
llvm-e2c4304654442ca353b307d73c86dce2a4acadbf.tar.xz
Use Intrinsic::getDeclaration in more places.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49338 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/IPO/SimplifyLibCalls.cpp28
-rw-r--r--lib/Transforms/Instrumentation/RSProfiling.cpp3
2 files changed, 9 insertions, 22 deletions
diff --git a/lib/Transforms/IPO/SimplifyLibCalls.cpp b/lib/Transforms/IPO/SimplifyLibCalls.cpp
index bbfd1d2da3..ed32daa398 100644
--- a/lib/Transforms/IPO/SimplifyLibCalls.cpp
+++ b/lib/Transforms/IPO/SimplifyLibCalls.cpp
@@ -21,6 +21,7 @@
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Instructions.h"
+#include "llvm/Intrinsics.h"
#include "llvm/Module.h"
#include "llvm/Pass.h"
#include "llvm/ADT/StringMap.h"
@@ -320,12 +321,9 @@ public:
/// @brief Return a Function* for the memcpy libcall
Constant *get_memcpy() {
if (!memcpy_func) {
- const Type *SBP = PointerType::getUnqual(Type::Int8Ty);
- const char *N = TD->getIntPtrType() == Type::Int32Ty ?
- "llvm.memcpy.i32" : "llvm.memcpy.i64";
- memcpy_func = M->getOrInsertFunction(N, Type::VoidTy, SBP, SBP,
- TD->getIntPtrType(), Type::Int32Ty,
- NULL);
+ Intrinsic::ID IID = (TD->getIntPtrType() == Type::Int32Ty) ?
+ Intrinsic::memcpy_i32 : Intrinsic::memcpy_i64;
+ memcpy_func = Intrinsic::getDeclaration(M, IID);
}
return memcpy_func;
}
@@ -1696,23 +1694,11 @@ public:
// ffsl(x) -> x == 0 ? 0 : llvm.cttz(x)+1
// ffsll(x) -> x == 0 ? 0 : llvm.cttz(x)+1
const Type *ArgType = TheCall->getOperand(1)->getType();
- const char *CTTZName;
assert(ArgType->getTypeID() == Type::IntegerTyID &&
"llvm.cttz argument is not an integer?");
- unsigned BitWidth = cast<IntegerType>(ArgType)->getBitWidth();
- if (BitWidth == 8)
- CTTZName = "llvm.cttz.i8";
- else if (BitWidth == 16)
- CTTZName = "llvm.cttz.i16";
- else if (BitWidth == 32)
- CTTZName = "llvm.cttz.i32";
- else {
- assert(BitWidth == 64 && "Unknown bitwidth");
- CTTZName = "llvm.cttz.i64";
- }
-
- Constant *F = SLC.getModule()->getOrInsertFunction(CTTZName, ArgType,
- ArgType, NULL);
+ Constant *F = Intrinsic::getDeclaration(SLC.getModule(),
+ Intrinsic::cttz, &ArgType, 1);
+
Value *V = CastInst::createIntegerCast(TheCall->getOperand(1), ArgType,
false/*ZExt*/, "tmp", TheCall);
Value *V2 = CallInst::Create(F, V, "tmp", TheCall);
diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp
index e7e8efea88..15249c2e1a 100644
--- a/lib/Transforms/Instrumentation/RSProfiling.cpp
+++ b/lib/Transforms/Instrumentation/RSProfiling.cpp
@@ -37,6 +37,7 @@
#include "llvm/Instructions.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
+#include "llvm/Intrinsics.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Support/CommandLine.h"
@@ -301,7 +302,7 @@ void GlobalRandomCounterOpt::ProcessChoicePoint(BasicBlock* bb) {
CycleCounter::CycleCounter(Module& m, uint64_t resetmask) : rm(resetmask) {
- F = m.getOrInsertFunction("llvm.readcyclecounter", Type::Int64Ty, NULL);
+ F = Intrinsic::getDeclaration(&m, Intrinsic::readcyclecounter);
}
CycleCounter::~CycleCounter() {}