From 637be04b77537d693923961821c05096a6c75c40 Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Mon, 3 Apr 2017 15:23:08 +0000 Subject: [PATCH] [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 llvm-svn: 299360 --- polly/lib/CodeGen/PerfMonitor.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/polly/lib/CodeGen/PerfMonitor.cpp b/polly/lib/CodeGen/PerfMonitor.cpp index cc0e277..3defeef 100644 --- a/polly/lib/CodeGen/PerfMonitor.cpp +++ b/polly/lib/CodeGen/PerfMonitor.cpp @@ -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()) { -- 2.7.4