diff --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt --- a/mlir/lib/ExecutionEngine/CMakeLists.txt +++ b/mlir/lib/ExecutionEngine/CMakeLists.txt @@ -13,6 +13,16 @@ JitRunner.cpp ) +if(LLVM_USE_INTEL_JITEVENTS) + set(LLVM_JIT_LISTENER_LIB + IntelJITEvents) +endif(LLVM_USE_INTEL_JITEVENTS) + +if(LLVM_USE_PERF) + set(LLVM_JIT_LISTENER_LIB + PerfJITEvents) +endif(LLVM_USE_PERF) + add_mlir_library(MLIRExecutionEngine ExecutionEngine.cpp OptUtils.cpp @@ -42,6 +52,7 @@ TransformUtils nativecodegen IPO + ${LLVM_JIT_LISTENER_LIB} LINK_LIBS PUBLIC MLIRLLVMIR diff --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp --- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp @@ -180,10 +180,10 @@ for (auto &indexedArg : llvm::enumerate(func.args())) { llvm::Value *argIndex = llvm::Constant::getIntegerValue( builder.getInt64Ty(), APInt(64, indexedArg.index())); - llvm::Value *argPtrPtr = builder.CreateGEP( - builder.getInt8PtrTy(), argList, argIndex); - llvm::Value *argPtr = builder.CreateLoad(builder.getInt8PtrTy(), - argPtrPtr); + llvm::Value *argPtrPtr = + builder.CreateGEP(builder.getInt8PtrTy(), argList, argIndex); + llvm::Value *argPtr = + builder.CreateLoad(builder.getInt8PtrTy(), argPtrPtr); llvm::Type *argTy = indexedArg.value().getType(); argPtr = builder.CreateBitCast(argPtr, argTy->getPointerTo()); llvm::Value *arg = builder.CreateLoad(argTy, argPtr); @@ -199,8 +199,8 @@ builder.getInt64Ty(), APInt(64, llvm::size(func.args()))); llvm::Value *retPtrPtr = builder.CreateGEP(builder.getInt8PtrTy(), argList, retIndex); - llvm::Value *retPtr = builder.CreateLoad(builder.getInt8PtrTy(), - retPtrPtr); + llvm::Value *retPtr = + builder.CreateLoad(builder.getInt8PtrTy(), retPtrPtr); retPtr = builder.CreateBitCast(retPtr, result->getType()->getPointerTo()); builder.CreateStore(result, retPtr); } @@ -217,9 +217,15 @@ gdbListener(enableGDBNotificationListener ? llvm::JITEventListener::createGDBRegistrationListener() : nullptr), - perfListener(enablePerfNotificationListener - ? llvm::JITEventListener::createPerfJITEventListener() - : nullptr) {} + perfListener(nullptr) { + if (enablePerfNotificationListener) { + if (auto *listener = llvm::JITEventListener::createPerfJITEventListener()) + perfListener = listener; + else if (auto *listener = + llvm::JITEventListener::createIntelJITEventListener()) + perfListener = listener; + } +} Expected> ExecutionEngine::create( ModuleOp m,