[PerfMonitor] Use Intrinsics::getDeclaration

Instead of creating the declaration ourselves, we obtain it directly from the
LLVM intrinsic definitions. This addresses a post-review comment for r299359.

Suggested-by: Hongzing Zheng <etherzhhb@gmail.com>
llvm-svn: 299360
This commit is contained in:
Tobias Grosser 2017-04-03 15:23:08 +00:00
parent 65371af2e1
commit 637be04b77
1 changed files with 2 additions and 11 deletions

View File

@ -12,6 +12,7 @@
#include "polly/CodeGen/PerfMonitor.h"
#include "polly/CodeGen/RuntimeDebugBuilder.h"
#include "llvm/ADT/Triple.h"
#include "llvm/IR/Intrinsics.h"
using namespace llvm;
using namespace polly;
@ -56,17 +57,7 @@ void PerfMonitor::addToGlobalConstructors(Function *Fn) {
}
Function *PerfMonitor::getRDTSCP() {
const char *Name = "llvm.x86.rdtscp";
Function *F = M->getFunction(Name);
if (!F) {
GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
FunctionType *Ty = FunctionType::get(Builder.getInt64Ty(),
{Builder.getInt8PtrTy()}, false);
F = Function::Create(Ty, Linkage, Name, M);
}
return F;
return Intrinsic::getDeclaration(M, Intrinsic::x86_rdtscp);
}
PerfMonitor::PerfMonitor(Module *M) : M(M), Builder(M->getContext()) {