From ea4e1835beccc67ff79976fc0ca53f9c9e862526 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Wed, 18 Sep 2024 23:00:10 -0700 Subject: [PATCH 01/62] Initial Structure for updating to the NewPassManager --- src/c/CMakeLists.txt | 8 ++++++-- src/c/weaver/weave/CMakeLists.txt | 17 +++++++++++++---- ...weave.cpp => perfflow_weave_legacy_pass.cpp} | 2 +- ...weave.hpp => perfflow_weave_legacy_pass.hpp} | 0 src/c/weaver/weave/perfflow_weave_new_pass.cpp | 0 src/c/weaver/weave/perfflow_weave_new_pass.hpp | 0 6 files changed, 20 insertions(+), 7 deletions(-) rename src/c/weaver/weave/{perfflow_weave.cpp => perfflow_weave_legacy_pass.cpp} (99%) rename src/c/weaver/weave/{perfflow_weave.hpp => perfflow_weave_legacy_pass.hpp} (100%) create mode 100644 src/c/weaver/weave/perfflow_weave_new_pass.cpp create mode 100644 src/c/weaver/weave/perfflow_weave_new_pass.hpp diff --git a/src/c/CMakeLists.txt b/src/c/CMakeLists.txt index 77564d01..85a5b5cb 100644 --- a/src/c/CMakeLists.txt +++ b/src/c/CMakeLists.txt @@ -7,11 +7,15 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # require at least Clang 9.0 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) message(FATAL_ERROR "Clang++ version must be at least 9.0!") - elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11) + elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 14) + set(PERFFLOWASPECT_CLANG_14_NEWER TRUE CACHE BOOL "using >=clang14") + add_definitions(-DPERFFLOWASPECT_CLANG_14_NEWER) + elseif ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)) set(PERFFLOWASPECT_CLANG_11_NEWER TRUE CACHE BOOL "using >=clang11") + set(PERFFLOWASPECT_CLANG_14_NEWER FALSE CACHE BOOL "using < clang14") add_definitions(-DPERFFLOWASPECT_CLANG_11_NEWER) elseif (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11) - set(PERFFLOWASPECT_CLANG_11_NEWER FALSE CACHE BOOL "using >=clang11") + set(PERFFLOWASPECT_CLANG_11_NEWER FALSE CACHE BOOL "using < clang11") endif() else() message(FATAL_ERROR "Unsupported CXX compiler: please use Clang >= 9.0") diff --git a/src/c/weaver/weave/CMakeLists.txt b/src/c/weaver/weave/CMakeLists.txt index 1702a662..30aebd1e 100644 --- a/src/c/weaver/weave/CMakeLists.txt +++ b/src/c/weaver/weave/CMakeLists.txt @@ -1,7 +1,16 @@ -add_library(WeavePass MODULE - # List your source files here. - perfflow_weave.cpp -) +if (PERFFLOWASPECT_CLANG_14_NEWER) + # Add the new pass + add_library(WeavePass MODULE + # List your source files here. + perfflow_weave_new_pass.cpp + ) +else() + # Add the legacy pass if we have Clang < 14. + add_library(WeavePass MODULE + # List your source files here. + perfflow_weave_legacy_pass.cpp + ) +endif() # Use C++11 to compile our pass (i.e., supply -std=c++11). target_compile_features(WeavePass PRIVATE cxx_range_for cxx_auto_type) diff --git a/src/c/weaver/weave/perfflow_weave.cpp b/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp similarity index 99% rename from src/c/weaver/weave/perfflow_weave.cpp rename to src/c/weaver/weave/perfflow_weave_legacy_pass.cpp index 4e81003c..fba59678 100644 --- a/src/c/weaver/weave/perfflow_weave.cpp +++ b/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp @@ -24,7 +24,7 @@ #include "llvm/Support/raw_ostream.h" #include "../../parser/perfflow_parser.hpp" -#include "perfflow_weave.hpp" +#include "perfflow_weave_legacy_pass.hpp" using namespace llvm; diff --git a/src/c/weaver/weave/perfflow_weave.hpp b/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp similarity index 100% rename from src/c/weaver/weave/perfflow_weave.hpp rename to src/c/weaver/weave/perfflow_weave_legacy_pass.hpp diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.hpp b/src/c/weaver/weave/perfflow_weave_new_pass.hpp new file mode 100644 index 00000000..e69de29b From 723ba84d6f1c4756127cb9839da40b25a8a67e79 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Wed, 18 Sep 2024 23:46:25 -0700 Subject: [PATCH 02/62] Add a basic module pass structure for perfflow_weave_new_pass. Untested. --- .../weave/perfflow_weave_legacy_pass.hpp | 6 +- .../weaver/weave/perfflow_weave_new_pass.cpp | 107 ++++++++++++++++++ .../weaver/weave/perfflow_weave_new_pass.hpp | 61 ++++++++++ 3 files changed, 171 insertions(+), 3 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp b/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp index 3db17445..b534da19 100644 --- a/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp +++ b/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp @@ -8,8 +8,8 @@ * SPDX-License-Identifier: LGPL-3.0 \************************************************************/ -#ifndef PERFFLOW_WEAVE_H -#define PERFFLOW_WEAVE_H +#ifndef PERFFLOW_WEAVE_LEGACY_PASS_H +#define PERFFLOW_WEAVE_LEGACY_PASS_H #include "llvm/IR/Function.h" #include "llvm/IR/Module.h" @@ -38,7 +38,7 @@ class WeavingPass : public FunctionPass } -#endif // PERFFLOW_WEAVE_H +#endif // PERFFLOW_WEAVE_LEGACY_PASS_H /* diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index e69de29b..d4c4df6c 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -0,0 +1,107 @@ +/************************************************************\ + * Copyright 2021 Lawrence Livermore National Security, LLC + * (c.f. AUTHORS, NOTICE.LLNS, COPYING) + * + * This file is part of the Flux resource manager framework. + * For details, see https://github.com/flux-framework. + * + * SPDX-License-Identifier: LGPL-3.0 +\************************************************************/ + +#include "llvm/IR/Value.h" +#include "llvm/IR/Attributes.h" +#include "llvm/IR/Constants.h" +#include "llvm/IR/LegacyPassManager.h" +#include "llvm/IR/AbstractCallSite.h" +#include "llvm/IR/Module.h" +#include "llvm/IR/Argument.h" +#include "llvm/IR/IRBuilder.h" +#include "llvm/Transforms/IPO/PassManagerBuilder.h" +#include "llvm/Support/raw_ostream.h" + +#include "../../parser/perfflow_parser.hpp" +#include "perfflow_weave_new_pass.hpp" + +using namespace llvm; + +// Implement the runOnModule Function +bool NewWeavingPass::runOnModule(Module &M) +{ + bool PatkiTest = true; + // We do nothing right now, let's build to see if this goes through and loads correctly. + // The build will probably fail as we are not parsing the annotations. + + outs() << "NewWeavePass loaded successfully. \n"; + errs() << "NewWeavePass had some error. \n"; + + // The following loops through each function. This is where we need to check annotation + // (from doInitialization in the legacy pass and add the insertBefore/insertAfter) + // for (auto &F : M) + // { + // if (F.isDeclaration()) + // continue; + + // // Get an IR builder. Sets the insertion point to the top of the function + // IRBuilder<> Builder(&*F.getEntryBlock().getFirstInsertionPt()); + + // // Inject a global variable that contains the function name + // auto FuncName = Builder.CreateGlobalStringPtr(F.getName()); + + // // Printf requires i8*, but PrintfFormatStrVar is an array: [n x i8]. Add + // // a cast: [n x i8] -> i8* + // llvm::Value *FormatStrPtr = + // Builder.CreatePointerCast(PrintfFormatStrVar, PrintfArgTy, "formatStr"); + + // // The following is visible only if you pass -debug on the command line + // // *and* you have an assert build. + // LLVM_DEBUG(dbgs() << " Injecting call to printf inside " << F.getName() + // << "\n"); + + // // Finally, inject a call to printf + // Builder.CreateCall( + // Printf, {FormatStrPtr, FuncName, Builder.getInt32(F.arg_size())}); + + // InsertedAtLeastOnePrintf = true; + // } + + return PatkiTest; +} + +// Run on module function. +PreservedAnalyses NewWeavingPass::run(llvm::Module &M, + llvm::ModuleAnalysisManager &) +{ + bool Changed = runOnModule(M); + + return (Changed ? llvm::PreservedAnalyses::none() + : llvm::PreservedAnalyses::all()); +} + +// Register the new pass. +// See docs here: https://github.com/banach-space/llvm-tutor/blob/main/lib/InjectFuncCall.cpp#L139 +// And here: https://rocmdocs.amd.com/projects/llvm-project/en/latest/LLVM/llvm/html/WritingAnLLVMNewPMPass.html + +llvm::PassPluginLibraryInfo getNewWeavingPassPluginInfo() +{ + return {LLVM_PLUGIN_API_VERSION, "inject-func-call", LLVM_VERSION_STRING, + [](PassBuilder &PB) + { + PB.registerPipelineParsingCallback( + [](StringRef Name, ModulePassManager &MPM, + ArrayRef) + { + if (Name == "new-weaving-pass") + { + MPM.addPass(NewWeavingPass()); + return true; + } + return false; + }); + }}; +} + +extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo +llvmGetPassPluginInfo() +{ + return getNewWeavingPassPluginInfo(); +} \ No newline at end of file diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.hpp b/src/c/weaver/weave/perfflow_weave_new_pass.hpp index e69de29b..fb3420b8 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.hpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.hpp @@ -0,0 +1,61 @@ +/************************************************************\ + * Copyright 2021 Lawrence Livermore National Security, LLC + * (c.f. AUTHORS, NOTICE.LLNS, COPYING) + * + * This file is part of the Flux resource manager framework. + * For details, see https://github.com/flux-framework. + * + * SPDX-License-Identifier: LGPL-3.0 +\************************************************************/ + +#ifndef PERFFLOW_WEAVE_NEW_PASS_H +#define PERFFLOW_WEAVE_NEW_PASS_H + +#include "llvm/IR/PassManager.h" +#include "llvm/Pass.h" + +#include + +using namespace llvm; + +namespace { + +class NewWeavingPass : public PassInfoMixin { +public: + // Revist this if we really need a function pass + // PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Module &M, ModuleAnalysisManager &); + bool runOnModule(Module &M); + + // Without isRequired returning true, this pass will be skipped for functions + // decorated with the optnone LLVM attribute. Note that clang -O0 decorates + // all functions with optnone. + static bool isRequired() { return true; } + +}; + + + +// class WeavingPass : public FunctionPass +// { +// public: +// static char ID; +// WeavingPass () : FunctionPass (ID) {} +// virtual bool doInitialization (Module &m); +// virtual bool runOnFunction (Function &F); + +// private: +// bool insertAfter (Module &m, Function &f, StringRef &a, +// int async, std::string &scope, std::string &flow, std::string pcut); +// bool insertBefore (Module &m, Function &f, StringRef &a, +// int async, std::string &scope, std::string &flow, std::string pcut); +// }; + +// } + +#endif // PERFFLOW_WEAVE_NEW_PASS_H + + +/* + * vi:tabstop=4 shiftwidth=4 expandtab + */ From 622d82b520f07a3f19f672855ffdc6d39590b549 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Wed, 18 Sep 2024 23:53:25 -0700 Subject: [PATCH 03/62] Formatted. --- .../weaver/weave/perfflow_weave_new_pass.cpp | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index d4c4df6c..c81943b0 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -34,7 +34,7 @@ bool NewWeavingPass::runOnModule(Module &M) outs() << "NewWeavePass loaded successfully. \n"; errs() << "NewWeavePass had some error. \n"; - // The following loops through each function. This is where we need to check annotation + // The following loops through each function. This is where we need to check annotation // (from doInitialization in the legacy pass and add the insertBefore/insertAfter) // for (auto &F : M) // { @@ -74,7 +74,7 @@ PreservedAnalyses NewWeavingPass::run(llvm::Module &M, bool Changed = runOnModule(M); return (Changed ? llvm::PreservedAnalyses::none() - : llvm::PreservedAnalyses::all()); + : llvm::PreservedAnalyses::all()); } // Register the new pass. @@ -84,20 +84,20 @@ PreservedAnalyses NewWeavingPass::run(llvm::Module &M, llvm::PassPluginLibraryInfo getNewWeavingPassPluginInfo() { return {LLVM_PLUGIN_API_VERSION, "inject-func-call", LLVM_VERSION_STRING, - [](PassBuilder &PB) + [](PassBuilder & PB) + { + PB.registerPipelineParsingCallback( + [](StringRef Name, ModulePassManager & MPM, + ArrayRef) + { + if (Name == "new-weaving-pass") { - PB.registerPipelineParsingCallback( - [](StringRef Name, ModulePassManager &MPM, - ArrayRef) - { - if (Name == "new-weaving-pass") - { - MPM.addPass(NewWeavingPass()); - return true; - } - return false; - }); - }}; + MPM.addPass(NewWeavingPass()); + return true; + } + return false; + }); + }}; } extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo From b880e84dcbb144ae1222c1c1a46a65f6598a99f9 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 19 Sep 2024 17:47:03 -0700 Subject: [PATCH 04/62] Add headers, comment one registration technique --- src/c/weaver/weave/perfflow_weave_new_pass.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index c81943b0..02f109e5 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -11,18 +11,23 @@ #include "llvm/IR/Value.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/Constants.h" -#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/AbstractCallSite.h" #include "llvm/IR/Module.h" #include "llvm/IR/Argument.h" #include "llvm/IR/IRBuilder.h" +#include "llvm/IR/PassManager.h" +#include "llvm/Passes/PassBuilder.h" +#include "llvm/Passes/PassPlugin.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" #include "llvm/Support/raw_ostream.h" #include "../../parser/perfflow_parser.hpp" #include "perfflow_weave_new_pass.hpp" +#include + using namespace llvm; +// using namespace std; // Implement the runOnModule Function bool NewWeavingPass::runOnModule(Module &M) @@ -100,8 +105,8 @@ llvm::PassPluginLibraryInfo getNewWeavingPassPluginInfo() }}; } -extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo -llvmGetPassPluginInfo() -{ - return getNewWeavingPassPluginInfo(); -} \ No newline at end of file +// extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo +// llvmGetPassPluginInfo() +// { +// return getNewWeavingPassPluginInfo(); +// } \ No newline at end of file From e3e3469ca2bbcfa890425efb3c324d5ba738fe1e Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 19 Sep 2024 17:48:58 -0700 Subject: [PATCH 05/62] Formatted. --- .../weaver/weave/perfflow_weave_new_pass.cpp | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index 02f109e5..a3b3c159 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -25,7 +25,6 @@ #include "perfflow_weave_new_pass.hpp" #include - using namespace llvm; // using namespace std; @@ -79,7 +78,7 @@ PreservedAnalyses NewWeavingPass::run(llvm::Module &M, bool Changed = runOnModule(M); return (Changed ? llvm::PreservedAnalyses::none() - : llvm::PreservedAnalyses::all()); + : llvm::PreservedAnalyses::all()); } // Register the new pass. @@ -89,20 +88,20 @@ PreservedAnalyses NewWeavingPass::run(llvm::Module &M, llvm::PassPluginLibraryInfo getNewWeavingPassPluginInfo() { return {LLVM_PLUGIN_API_VERSION, "inject-func-call", LLVM_VERSION_STRING, - [](PassBuilder & PB) - { - PB.registerPipelineParsingCallback( - [](StringRef Name, ModulePassManager & MPM, - ArrayRef) - { - if (Name == "new-weaving-pass") + [](PassBuilder &PB) { - MPM.addPass(NewWeavingPass()); - return true; - } - return false; - }); - }}; + PB.registerPipelineParsingCallback( + [](StringRef Name, ModulePassManager &MPM, + ArrayRef) + { + if (Name == "new-weaving-pass") + { + MPM.addPass(NewWeavingPass()); + return true; + } + return false; + }); + }}; } // extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo From 51ab4e97947b2ea601668173e363bfcd183c8381 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 19 Sep 2024 18:01:26 -0700 Subject: [PATCH 06/62] Add missing brace --- src/c/weaver/weave/perfflow_weave_new_pass.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.hpp b/src/c/weaver/weave/perfflow_weave_new_pass.hpp index fb3420b8..ad0b1fdc 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.hpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.hpp @@ -51,7 +51,7 @@ class NewWeavingPass : public PassInfoMixin { // int async, std::string &scope, std::string &flow, std::string pcut); // }; -// } + } #endif // PERFFLOW_WEAVE_NEW_PASS_H From 8b5a89f15d8939875dcb33844cb8ac5345b3f227 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 19 Sep 2024 18:21:48 -0700 Subject: [PATCH 07/62] Builds, but pass is not picked up with -XClang -load --- src/c/weaver/weave/perfflow_weave_new_pass.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index a3b3c159..9ffb43eb 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -87,7 +87,7 @@ PreservedAnalyses NewWeavingPass::run(llvm::Module &M, llvm::PassPluginLibraryInfo getNewWeavingPassPluginInfo() { - return {LLVM_PLUGIN_API_VERSION, "inject-func-call", LLVM_VERSION_STRING, + return {LLVM_PLUGIN_API_VERSION, "new-weaving-pass", LLVM_VERSION_STRING, [](PassBuilder &PB) { PB.registerPipelineParsingCallback( @@ -104,8 +104,8 @@ llvm::PassPluginLibraryInfo getNewWeavingPassPluginInfo() }}; } -// extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo -// llvmGetPassPluginInfo() -// { -// return getNewWeavingPassPluginInfo(); -// } \ No newline at end of file +extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo +llvmGetPassPluginInfo() +{ + return getNewWeavingPassPluginInfo(); +} \ No newline at end of file From d2578eccb475cfec3168d7f7d0ae31e96ba05ddc Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 19 Sep 2024 19:06:40 -0700 Subject: [PATCH 08/62] Try the EP Early Simplification Callback, similar to our legacy pass --- .../weaver/weave/perfflow_weave_new_pass.cpp | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index 9ffb43eb..a4388cf9 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -85,23 +85,41 @@ PreservedAnalyses NewWeavingPass::run(llvm::Module &M, // See docs here: https://github.com/banach-space/llvm-tutor/blob/main/lib/InjectFuncCall.cpp#L139 // And here: https://rocmdocs.amd.com/projects/llvm-project/en/latest/LLVM/llvm/html/WritingAnLLVMNewPMPass.html +PassPluginLibraryInfo getPassPluginInfo() { + const auto callback = [](PassBuilder &PB) { + PB.registerPipelineEarlySimplificationEPCallback( + [&](ModulePassManager &MPM, auto) { + MPM.addPass(createModuleToFunctionPassAdaptor(MyPass())); + return true; + }); + }; + + + llvm::PassPluginLibraryInfo getNewWeavingPassPluginInfo() { return {LLVM_PLUGIN_API_VERSION, "new-weaving-pass", LLVM_VERSION_STRING, [](PassBuilder &PB) { - PB.registerPipelineParsingCallback( - [](StringRef Name, ModulePassManager &MPM, - ArrayRef) - { - if (Name == "new-weaving-pass") - { + PB.registerPipelineEarlySimplificationEPCallback( + [](ModulePassManager &MPM, auto) { MPM.addPass(NewWeavingPass()); - return true; - } - return false; - }); - }}; + return true; + } + ) + }}; + // PB.registerPipelineParsingCallback( + // [](StringRef Name, ModulePassManager &MPM, + // ArrayRef) + // { + // if (Name == "new-weaving-pass") + // { + // MPM.addPass(NewWeavingPass()); + // return true; + // } + // return false; + // }); + // }}; } extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo From 8506007068900893d7de5d5ebd44acada9e120a0 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 19 Sep 2024 19:09:05 -0700 Subject: [PATCH 09/62] Comment out the example code --- src/c/weaver/weave/perfflow_weave_new_pass.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index a4388cf9..8e36e409 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -85,17 +85,6 @@ PreservedAnalyses NewWeavingPass::run(llvm::Module &M, // See docs here: https://github.com/banach-space/llvm-tutor/blob/main/lib/InjectFuncCall.cpp#L139 // And here: https://rocmdocs.amd.com/projects/llvm-project/en/latest/LLVM/llvm/html/WritingAnLLVMNewPMPass.html -PassPluginLibraryInfo getPassPluginInfo() { - const auto callback = [](PassBuilder &PB) { - PB.registerPipelineEarlySimplificationEPCallback( - [&](ModulePassManager &MPM, auto) { - MPM.addPass(createModuleToFunctionPassAdaptor(MyPass())); - return true; - }); - }; - - - llvm::PassPluginLibraryInfo getNewWeavingPassPluginInfo() { return {LLVM_PLUGIN_API_VERSION, "new-weaving-pass", LLVM_VERSION_STRING, From 633c1210d103692619d344574b0c6560fe943ad2 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 19 Sep 2024 19:10:05 -0700 Subject: [PATCH 10/62] Add missing ; --- src/c/weaver/weave/perfflow_weave_new_pass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index 8e36e409..e452303f 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -95,7 +95,7 @@ llvm::PassPluginLibraryInfo getNewWeavingPassPluginInfo() MPM.addPass(NewWeavingPass()); return true; } - ) + ); }}; // PB.registerPipelineParsingCallback( // [](StringRef Name, ModulePassManager &MPM, From 656cd9d793a4fbd6aa7a7ecb2e77d81430e6105c Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 19 Sep 2024 23:03:00 -0700 Subject: [PATCH 11/62] Try adding the -fpass-plugin for clang 14+ --- src/c/test/CMakeLists.txt | 6 +- .../weaver/weave/perfflow_weave_new_pass.cpp | 66 +++++++++++-------- 2 files changed, 45 insertions(+), 27 deletions(-) diff --git a/src/c/test/CMakeLists.txt b/src/c/test/CMakeLists.txt index aae008c8..87299e3a 100644 --- a/src/c/test/CMakeLists.txt +++ b/src/c/test/CMakeLists.txt @@ -11,7 +11,11 @@ message(STATUS "Adding CXX unit tests") foreach(TEST ${SMOKETESTS}) message(STATUS " [*] Adding test: ${TEST}") add_executable(${TEST} ${TEST}.cpp) - set_source_files_properties(${TEST}.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fPIC") + if (PERFFLOWASPECT_CLANG_14_NEWER) + set_source_files_properties(${TEST}.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fpass-plugin=../weaver/weave/libWeavePass.so -fPIC") +else() +set_source_files_properties(smoketest_MT.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fPIC") +endif() target_link_libraries(${TEST} ${perfflow_deps}) endforeach() diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index e452303f..3d87a10b 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -84,35 +84,49 @@ PreservedAnalyses NewWeavingPass::run(llvm::Module &M, // Register the new pass. // See docs here: https://github.com/banach-space/llvm-tutor/blob/main/lib/InjectFuncCall.cpp#L139 // And here: https://rocmdocs.amd.com/projects/llvm-project/en/latest/LLVM/llvm/html/WritingAnLLVMNewPMPass.html +// https://stackoverflow.com/questions/54447985/how-to-automatically-register-and-load-modern-pass-in-clang/75999804#75999804 -llvm::PassPluginLibraryInfo getNewWeavingPassPluginInfo() +PassPluginLibraryInfo getNewWeavingPassPluginInfo() { - return {LLVM_PLUGIN_API_VERSION, "new-weaving-pass", LLVM_VERSION_STRING, - [](PassBuilder &PB) - { - PB.registerPipelineEarlySimplificationEPCallback( - [](ModulePassManager &MPM, auto) { - MPM.addPass(NewWeavingPass()); - return true; - } - ); - }}; - // PB.registerPipelineParsingCallback( - // [](StringRef Name, ModulePassManager &MPM, - // ArrayRef) - // { - // if (Name == "new-weaving-pass") - // { - // MPM.addPass(NewWeavingPass()); - // return true; - // } - // return false; - // }); - // }}; + + const auto pass_callback = [](PassBuilder &PB) { + PB.registerPipelineEarlySimplificationEPCallback( + [&](ModulePassManager &MPM, auto) { + MPM.addPass(NewWeavingPass()); + return true; + } + ); + }; + + return {LLVM_PLUGIN_API_VERSION, "new-weaving-pass", LLVM_VERSION_STRING, pass_callback}; } -extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo -llvmGetPassPluginInfo() +extern "C" LLVM_ATTRIBUTE_WEAK PassPluginLibraryInfo llvmGetPassPluginInfo() { return getNewWeavingPassPluginInfo(); -} \ No newline at end of file +} + + +// return {LLVM_PLUGIN_API_VERSION, "new-weaving-pass", LLVM_VERSION_STRING, +// [](PassBuilder &PB) +// { +// PB.registerPipelineEarlySimplificationEPCallback( +// [](ModulePassManager &MPM, auto) { +// MPM.addPass(NewWeavingPass()); +// return true; +// } +// ); +// }}; +// // PB.registerPipelineParsingCallback( +// // [](StringRef Name, ModulePassManager &MPM, +// // ArrayRef) +// // { +// // if (Name == "new-weaving-pass") +// // { +// // MPM.addPass(NewWeavingPass()); +// // return true; +// // } +// // return false; +// // }); +// // }}; +// } \ No newline at end of file From ff32d8cde9d49a2866bee8d6e5176cf2305681b3 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 19 Sep 2024 23:11:55 -0700 Subject: [PATCH 12/62] Clean up, edit CMake to add -fpass-plugin for Clang14+, edit host-config --- ....14.0-ppc64le-clang@14.0.5-gcc@8.3.1.cmake | 8 +++-- src/c/test/CMakeLists.txt | 24 ++++++++++---- .../weaver/weave/perfflow_weave_new_pass.cpp | 31 ++----------------- 3 files changed, 27 insertions(+), 36 deletions(-) diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@14.0.5-gcc@8.3.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@14.0.5-gcc@8.3.1.cmake index 43651809..34f1ff71 100644 --- a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@14.0.5-gcc@8.3.1.cmake +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@14.0.5-gcc@8.3.1.cmake @@ -11,6 +11,10 @@ set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-14.0.5-gcc-8.3.1/bin/clang" CACHE PATH "") set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-14.0.5-gcc-8.3.1/bin/clang++" CACHE PATH "") set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-14.0.5-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") + +# Clang 14 supports both legacy and new pass manager. +# Use the -flegacy-pass-manager if you want to use the legacy pass. +# Use -fpass-plugin= to use the new pass # Use both C and CXX flags to support both targets. -set(CMAKE_C_FLAGS "-flegacy-pass-manager" CACHE STRING "") -set(CMAKE_CXX_FLAGS "-flegacy-pass-manager" CACHE STRING "") +# set(CMAKE_C_FLAGS "-flegacy-pass-manager" CACHE STRING "") +# set(CMAKE_CXX_FLAGS "-flegacy-pass-manager" CACHE STRING "") diff --git a/src/c/test/CMakeLists.txt b/src/c/test/CMakeLists.txt index 87299e3a..0b44a54a 100644 --- a/src/c/test/CMakeLists.txt +++ b/src/c/test/CMakeLists.txt @@ -13,9 +13,9 @@ foreach(TEST ${SMOKETESTS}) add_executable(${TEST} ${TEST}.cpp) if (PERFFLOWASPECT_CLANG_14_NEWER) set_source_files_properties(${TEST}.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fpass-plugin=../weaver/weave/libWeavePass.so -fPIC") -else() -set_source_files_properties(smoketest_MT.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fPIC") -endif() + else() + set_source_files_properties(${TEST}.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fPIC") + endif() target_link_libraries(${TEST} ${perfflow_deps}) endforeach() @@ -37,7 +37,11 @@ endif() if(PERFFLOWASPECT_WITH_MULTITHREADS) message(STATUS " [*] Adding test: smoketest_MT") add_executable(smoketest_MT smoketest_MT.cpp) - set_source_files_properties(smoketest_MT.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fPIC") + if (PERFFLOWASPECT_CLANG_14_NEWER) + set_source_files_properties(smoketest_MT.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fpass-plugin=../weaver/weave/libWeavePass.so -fPIC") + else() + set_source_files_properties(smoketest_MT.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fPIC") + endif() set(THREADS_PREFER_PTHREAD_FLAG ON) target_link_libraries(smoketest_MT ${perfflow_deps} pthread) endif() @@ -45,14 +49,22 @@ endif() if(PERFFLOWASPECT_WITH_MPI) message(STATUS " [*] Adding test: smoketest_MPI") add_executable(smoketest_MPI smoketest_MPI.cpp) - set_source_files_properties(smoketest_MPI.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fPIC") + if (PERFFLOWASPECT_CLANG_14_NEWER) + set_source_files_properties(smoketest_MPI.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fpass-plugin=../weaver/weave/libWeavePass.so -fPIC") + else() + set_source_files_properties(smoketest_MPI.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fPIC") + endif() include_directories(${MPI_INCLUDE_PATH}) target_link_libraries(smoketest_MPI ${perfflow_deps} ${MPI_LIBRARIES}) endif() if(PERFFLOWASPECT_WITH_CUDA) message(STATUS " [*] Adding test: smoketest_cuda") - set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} -Xcompiler=-Xclang -Xcompiler=-load -Xcompiler=-Xclang -Xcompiler=../../../weaver/weave/libWeavePass.so") + if (PERFFLOWASPECT_CLANG_14_NEWER) + set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} -Xcompiler=-Xclang -Xcompiler=-load -Xcompiler=-Xclang -Xcompiler=../../../weaver/weave/libWeavePass.so -fpass-plugin=../weaver/weave/libWeavePass.so") + else() + set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} -Xcompiler=-Xclang -Xcompiler=-load -Xcompiler=-Xclang -Xcompiler=../../../weaver/weave/libWeavePass.so") + endif() cuda_add_executable(smoketest_cuda smoketest_cuda_wrapper.cpp smoketest_cuda_kernel.cu) target_link_libraries(smoketest_cuda ${perfflow_deps} ${CUDA_LIBRARIES}) endif() diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index 3d87a10b..0eb5f71d 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -35,8 +35,7 @@ bool NewWeavingPass::runOnModule(Module &M) // We do nothing right now, let's build to see if this goes through and loads correctly. // The build will probably fail as we are not parsing the annotations. - outs() << "NewWeavePass loaded successfully. \n"; - errs() << "NewWeavePass had some error. \n"; + outs() << "NewWeavePass loaded successfully! \n"; // The following loops through each function. This is where we need to check annotation // (from doInitialization in the legacy pass and add the insertBefore/insertAfter) @@ -85,6 +84,7 @@ PreservedAnalyses NewWeavingPass::run(llvm::Module &M, // See docs here: https://github.com/banach-space/llvm-tutor/blob/main/lib/InjectFuncCall.cpp#L139 // And here: https://rocmdocs.amd.com/projects/llvm-project/en/latest/LLVM/llvm/html/WritingAnLLVMNewPMPass.html // https://stackoverflow.com/questions/54447985/how-to-automatically-register-and-load-modern-pass-in-clang/75999804#75999804 +// https://github.com/llvm/llvm-project/issues/56137 PassPluginLibraryInfo getNewWeavingPassPluginInfo() { @@ -104,29 +104,4 @@ PassPluginLibraryInfo getNewWeavingPassPluginInfo() extern "C" LLVM_ATTRIBUTE_WEAK PassPluginLibraryInfo llvmGetPassPluginInfo() { return getNewWeavingPassPluginInfo(); -} - - -// return {LLVM_PLUGIN_API_VERSION, "new-weaving-pass", LLVM_VERSION_STRING, -// [](PassBuilder &PB) -// { -// PB.registerPipelineEarlySimplificationEPCallback( -// [](ModulePassManager &MPM, auto) { -// MPM.addPass(NewWeavingPass()); -// return true; -// } -// ); -// }}; -// // PB.registerPipelineParsingCallback( -// // [](StringRef Name, ModulePassManager &MPM, -// // ArrayRef) -// // { -// // if (Name == "new-weaving-pass") -// // { -// // MPM.addPass(NewWeavingPass()); -// // return true; -// // } -// // return false; -// // }); -// // }}; -// } \ No newline at end of file +} \ No newline at end of file From 4c3d2bf63916543c18e1153ddd32cefd46dab811 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 19 Sep 2024 23:18:19 -0700 Subject: [PATCH 13/62] Update the CUDA compiler -Xcompiler flag. --- src/c/test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c/test/CMakeLists.txt b/src/c/test/CMakeLists.txt index 0b44a54a..6dad01a7 100644 --- a/src/c/test/CMakeLists.txt +++ b/src/c/test/CMakeLists.txt @@ -61,7 +61,7 @@ endif() if(PERFFLOWASPECT_WITH_CUDA) message(STATUS " [*] Adding test: smoketest_cuda") if (PERFFLOWASPECT_CLANG_14_NEWER) - set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} -Xcompiler=-Xclang -Xcompiler=-load -Xcompiler=-Xclang -Xcompiler=../../../weaver/weave/libWeavePass.so -fpass-plugin=../weaver/weave/libWeavePass.so") + set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} -Xcompiler=-Xclang -Xcompiler=-load -Xcompiler=-Xclang -Xcompiler=../../../weaver/weave/libWeavePass.so -Xcompiler=-fpass-plugin=../../../weaver/weave/libWeavePass.so") else() set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} -Xcompiler=-Xclang -Xcompiler=-load -Xcompiler=-Xclang -Xcompiler=../../../weaver/weave/libWeavePass.so") endif() From acf39c7f9ab3eb07cd99426e537c8dd2640c4015 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 19 Sep 2024 23:19:15 -0700 Subject: [PATCH 14/62] Formatted --- src/c/weaver/weave/perfflow_weave_new_pass.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index 0eb5f71d..57d6510b 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -77,7 +77,7 @@ PreservedAnalyses NewWeavingPass::run(llvm::Module &M, bool Changed = runOnModule(M); return (Changed ? llvm::PreservedAnalyses::none() - : llvm::PreservedAnalyses::all()); + : llvm::PreservedAnalyses::all()); } // Register the new pass. @@ -89,12 +89,14 @@ PreservedAnalyses NewWeavingPass::run(llvm::Module &M, PassPluginLibraryInfo getNewWeavingPassPluginInfo() { - const auto pass_callback = [](PassBuilder &PB) { + const auto pass_callback = [](PassBuilder & PB) + { PB.registerPipelineEarlySimplificationEPCallback( - [&](ModulePassManager &MPM, auto) { - MPM.addPass(NewWeavingPass()); - return true; - } + [&](ModulePassManager & MPM, auto) + { + MPM.addPass(NewWeavingPass()); + return true; + } ); }; From b94231a167d1521410c8307343289b7c90dd809d Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Mon, 23 Sep 2024 21:46:02 -0700 Subject: [PATCH 15/62] Check if we can intercept main, so we know where to insert the Adiak call --- .../weaver/weave/perfflow_weave_new_pass.cpp | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index 57d6510b..cf77d935 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -39,16 +39,22 @@ bool NewWeavingPass::runOnModule(Module &M) // The following loops through each function. This is where we need to check annotation // (from doInitialization in the legacy pass and add the insertBefore/insertAfter) - // for (auto &F : M) - // { - // if (F.isDeclaration()) - // continue; + for (auto &F : M) + { + if (F.isDeclaration()) + continue; // // Get an IR builder. Sets the insertion point to the top of the function - // IRBuilder<> Builder(&*F.getEntryBlock().getFirstInsertionPt()); + IRBuilder<> Builder(&*F.getEntryBlock().getFirstInsertionPt()); // // Inject a global variable that contains the function name - // auto FuncName = Builder.CreateGlobalStringPtr(F.getName()); + auto FuncName = Builder.CreateGlobalStringPtr(F.getName()); + + if (strcmp(F.getName(),"main")==0) + { + outs("We found main! We will insert Adiak call here eventually") + continue; + } // // Printf requires i8*, but PrintfFormatStrVar is an array: [n x i8]. Add // // a cast: [n x i8] -> i8* @@ -65,7 +71,7 @@ bool NewWeavingPass::runOnModule(Module &M) // Printf, {FormatStrPtr, FuncName, Builder.getInt32(F.arg_size())}); // InsertedAtLeastOnePrintf = true; - // } + } return PatkiTest; } From 40885fabf08232182d519c6e5962b217a42d159f Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Mon, 23 Sep 2024 22:12:35 -0700 Subject: [PATCH 16/62] Builds correctly, can intercept main. --- src/c/weaver/weave/perfflow_weave_new_pass.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index cf77d935..5f4b8f64 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -24,6 +24,7 @@ #include "../../parser/perfflow_parser.hpp" #include "perfflow_weave_new_pass.hpp" #include +#include using namespace llvm; // using namespace std; @@ -50,9 +51,9 @@ bool NewWeavingPass::runOnModule(Module &M) // // Inject a global variable that contains the function name auto FuncName = Builder.CreateGlobalStringPtr(F.getName()); - if (strcmp(F.getName(),"main")==0) + if (F.getName().str()=="main") { - outs("We found main! We will insert Adiak call here eventually") + outs() << "We found main! We will insert Adiak call here eventually.\n"; continue; } @@ -112,4 +113,4 @@ PassPluginLibraryInfo getNewWeavingPassPluginInfo() extern "C" LLVM_ATTRIBUTE_WEAK PassPluginLibraryInfo llvmGetPassPluginInfo() { return getNewWeavingPassPluginInfo(); -} \ No newline at end of file +} From ad887362895d953dfb7a802fd9d355e7db6ee768 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Mon, 23 Sep 2024 23:25:29 -0700 Subject: [PATCH 17/62] First attempt at restructuring. Will probably not build. May split into common.hpp/cpp as opposed to just the current hpp file. --- src/c/weaver/weave/perfflow_weave_common.hpp | 224 +++++++++++ .../weave/perfflow_weave_legacy_pass.cpp | 347 +++++++++--------- .../weaver/weave/perfflow_weave_new_pass.cpp | 48 +-- 3 files changed, 426 insertions(+), 193 deletions(-) create mode 100644 src/c/weaver/weave/perfflow_weave_common.hpp diff --git a/src/c/weaver/weave/perfflow_weave_common.hpp b/src/c/weaver/weave/perfflow_weave_common.hpp new file mode 100644 index 00000000..ea08e433 --- /dev/null +++ b/src/c/weaver/weave/perfflow_weave_common.hpp @@ -0,0 +1,224 @@ +/************************************************************\ + * Copyright 2021 Lawrence Livermore National Security, LLC + * (c.f. AUTHORS, NOTICE.LLNS, COPYING) + * + * This file is part of the Flux resource manager framework. + * For details, see https://github.com/flux-framework. + * + * SPDX-License-Identifier: LGPL-3.0 +\************************************************************/ + +#ifndef PERFFLOW_WEAVE_COMMON_H +#define PERFFLOW_WEAVE_COMMON_H + +#include "llvm/IR/Value.h" +#include "llvm/IR/Attributes.h" +#include "llvm/IR/Constants.h" +#include "llvm/IR/LegacyPassManager.h" +#ifdef PERFFLOWASPECT_CLANG_11_NEWER +#include "llvm/IR/AbstractCallSite.h" +#else +#include "llvm/IR/CallSite.h" +#endif +#include "llvm/IR/Module.h" +#include "llvm/IR/Argument.h" +#include "llvm/IR/IRBuilder.h" +#include "llvm/Transforms/IPO/PassManagerBuilder.h" +#include "llvm/Support/raw_ostream.h" + +#include "../../parser/perfflow_parser.hpp" + +namespace { + +class WeaveCommon +{ +private: + bool insertAfter(Module &m, Function &f, StringRef &a, + int async, std::string &scope, std::string &flow, std::string pcut); + + + bool insertBefore(Module &m, Function &f, StringRef &a, + int async, std::string &scope, std::string &flow, std::string pcut); + +public: + bool modifyAnnotatedFunctions(Module &m); + +}; + +/* +Public Member definition. +Need to clean this up so it reads better, and doesn't look like C++ jargon with random casts and is explainable. +*/ + +bool WeaveCommon::modifyAnnotatedFunctions(Module &m) +{ + auto annotations = m.getNamedGlobal("llvm.global.annotations"); + if (!annotations) + { + return false; + } + + bool changed = false; + auto a = cast (annotations->getOperand(0)); + for (unsigned int i = 0; i < a->getNumOperands(); i++) + { + auto e = cast (a->getOperand(i)); + if (auto *fn = dyn_cast (e->getOperand(0)->getOperand(0))) + { + auto anno = cast( + cast(e->getOperand(1)->getOperand(0)) + ->getOperand(0)) + ->getAsCString(); + std::string pcut, scope, flow; + if (perfflow_parser_parse(anno.data(), pcut, scope, flow) == 0) + { + if (pcut == "around" || pcut == "before") + changed = insertBefore(m, *fn, + anno, 0, scope, flow, pcut) || changed; + else if (pcut == "around_async" || pcut == "before_async") + { + changed = insertBefore(m, *fn, + anno, 1, scope, flow, pcut) || changed; + } + if (pcut == "around" || pcut == "after") + { + if (pcut == "around") + { + if (flow == "in" || flow == "out") + { + flow = "NA"; + } + } + changed = insertAfter(m, *fn, + anno, 0, scope, flow, pcut) || changed; + } + else if (pcut == "around_async" || pcut == "after_async") + { + if (pcut == "around") + { + if (flow == "in" || flow == "out") + { + flow = "NA"; + } + } + changed = insertAfter(m, *fn, + anno, 1, scope, flow, pcut) || changed; + } + } + else + { + errs() << "WeavePass[WARN]: Ignoring " << anno << "\n"; + } + } + } + return changed; + +} + +/* +Private Member Function Definitions +*/ + +bool WeaveCommon::insertAfter(Module &m, Function &f, StringRef &a, + int async, std::string &scope, std::string &flow, std::string pcut) +{ + if (m.empty() || f.empty()) + { + return false; + } + + auto &context = m.getContext(); + Type *voidType = Type::getVoidTy(context); + Type *int32Type = Type::getInt32Ty(context); + Type *int8PtrType = Type::getInt8PtrTy(context); + std::vector params; + params.push_back(int32Type); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + + // voidType is return type, params are parameters and no variable length args + FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false); + // Note: Use FunctionCallee after for Clang 9 or higher + FunctionCallee after = m.getOrInsertFunction("perfflow_weave_after", + weaveFuncTy); + // Constant *after = m.getOrInsertFunction("perfflow_weave_after", + // weaveFuncTy); + + // iterate through blocks + for (BasicBlock &bb : f) + { + Instruction *inst = bb.getTerminator(); + if (isa(inst) || isa(inst)) + { + IRBuilder<> builder(inst); + Value *v1 = builder.CreateGlobalStringPtr(m.getName(), "str"); + Value *v2 = builder.CreateGlobalStringPtr(f.getName(), "str"); + Value *v3 = builder.CreateGlobalStringPtr(StringRef(scope), "str"); + Value *v4 = builder.CreateGlobalStringPtr(StringRef(flow), "str"); + Value *v5 = builder.CreateGlobalStringPtr(StringRef(pcut), "str"); + std::vector args; + args.push_back(ConstantInt::get(Type::getInt32Ty(context), async)); + args.push_back(v1); + args.push_back(v2); + args.push_back(v3); + args.push_back(v4); + args.push_back(v5); + builder.CreateCall(after, args); + } + } + return true; +} + +bool WeaveCommon::insertBefore(Module &m, Function &f, StringRef &a, + int async, std::string &scope, std::string &flow, std::string pcut) +{ + if (m.empty() || f.empty()) + { + return false; + } + + auto &context = m.getContext(); + Type *voidType = Type::getVoidTy(context); + Type *int32Type = Type::getInt32Ty(context); + Type *int8PtrType = Type::getInt8PtrTy(context); + std::vector params; + params.push_back(int32Type); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + + // voidType is return type, params are parameters and no variable length args + FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false); + // Note: User FunctionCallee before for Clang >= 9.0 + FunctionCallee before = m.getOrInsertFunction("perfflow_weave_before", + weaveFuncTy); + //Constant *before = m.getOrInsertFunction ("perfflow_weave_before", + // weaveFuncTy); + auto &entry = f.getEntryBlock(); + IRBuilder<> builder(&entry); + Value *v1 = builder.CreateGlobalStringPtr(m.getName(), "str"); + Value *v2 = builder.CreateGlobalStringPtr(f.getName(), "str"); + Value *v3 = builder.CreateGlobalStringPtr(StringRef(scope), "str"); + Value *v4 = builder.CreateGlobalStringPtr(StringRef(flow), "str"); + Value *v5 = builder.CreateGlobalStringPtr(StringRef(pcut), "str"); + builder.SetInsertPoint(&entry, entry.begin()); + std::vector args; + args.push_back(ConstantInt::get(Type::getInt32Ty(context), async)); + args.push_back(v1); + args.push_back(v2); + args.push_back(v3); + args.push_back(v4); + args.push_back(v5); + builder.CreateCall(before, args); + + return true; +} + +} // End namespace + +#endif // PERFFLOW_WEAVE_COMMON_H diff --git a/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp b/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp index fba59678..4772bd33 100644 --- a/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp @@ -8,132 +8,132 @@ * SPDX-License-Identifier: LGPL-3.0 \************************************************************/ -#include "llvm/IR/Value.h" -#include "llvm/IR/Attributes.h" -#include "llvm/IR/Constants.h" +// #include "llvm/IR/Value.h" +// #include "llvm/IR/Attributes.h" +// #include "llvm/IR/Constants.h" #include "llvm/IR/LegacyPassManager.h" #ifdef PERFFLOWASPECT_CLANG_11_NEWER #include "llvm/IR/AbstractCallSite.h" #else #include "llvm/IR/CallSite.h" #endif -#include "llvm/IR/Module.h" -#include "llvm/IR/Argument.h" -#include "llvm/IR/IRBuilder.h" -#include "llvm/Transforms/IPO/PassManagerBuilder.h" +//#include "llvm/IR/Module.h" +// #include "llvm/IR/Argument.h" +// #include "llvm/IR/IRBuilder.h" +// #include "llvm/Transforms/IPO/PassManagerBuilder.h" #include "llvm/Support/raw_ostream.h" -#include "../../parser/perfflow_parser.hpp" +// #include "../../parser/perfflow_parser.hpp" #include "perfflow_weave_legacy_pass.hpp" using namespace llvm; -/****************************************************************************** - * * - * Private Methods of WeavingPass Class * - * * - ******************************************************************************/ - -bool WeavingPass::insertAfter(Module &m, Function &f, StringRef &a, - int async, std::string &scope, std::string &flow, std::string pcut) -{ - if (m.empty() || f.empty()) - { - return false; - } - - auto &context = m.getContext(); - Type *voidType = Type::getVoidTy(context); - Type *int32Type = Type::getInt32Ty(context); - Type *int8PtrType = Type::getInt8PtrTy(context); - std::vector params; - params.push_back(int32Type); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - - // voidType is return type, params are parameters and no variable length args - FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false); - // Note: Use FunctionCallee after for Clang 9 or higher - FunctionCallee after = m.getOrInsertFunction("perfflow_weave_after", - weaveFuncTy); - // Constant *after = m.getOrInsertFunction("perfflow_weave_after", - // weaveFuncTy); - - // iterate through blocks - for (BasicBlock &bb : f) - { - Instruction *inst = bb.getTerminator(); - if (isa(inst) || isa(inst)) - { - IRBuilder<> builder(inst); - Value *v1 = builder.CreateGlobalStringPtr(m.getName(), "str"); - Value *v2 = builder.CreateGlobalStringPtr(f.getName(), "str"); - Value *v3 = builder.CreateGlobalStringPtr(StringRef(scope), "str"); - Value *v4 = builder.CreateGlobalStringPtr(StringRef(flow), "str"); - Value *v5 = builder.CreateGlobalStringPtr(StringRef(pcut), "str"); - std::vector args; - args.push_back(ConstantInt::get(Type::getInt32Ty(context), async)); - args.push_back(v1); - args.push_back(v2); - args.push_back(v3); - args.push_back(v4); - args.push_back(v5); - builder.CreateCall(after, args); - } - } - return true; -} - -bool WeavingPass::insertBefore(Module &m, Function &f, StringRef &a, - int async, std::string &scope, std::string &flow, std::string pcut) -{ - if (m.empty() || f.empty()) - { - return false; - } - - auto &context = m.getContext(); - Type *voidType = Type::getVoidTy(context); - Type *int32Type = Type::getInt32Ty(context); - Type *int8PtrType = Type::getInt8PtrTy(context); - std::vector params; - params.push_back(int32Type); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - - // voidType is return type, params are parameters and no variable length args - FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false); - // Note: User FunctionCallee before for Clang >= 9.0 - FunctionCallee before = m.getOrInsertFunction("perfflow_weave_before", - weaveFuncTy); - //Constant *before = m.getOrInsertFunction ("perfflow_weave_before", - // weaveFuncTy); - auto &entry = f.getEntryBlock(); - IRBuilder<> builder(&entry); - Value *v1 = builder.CreateGlobalStringPtr(m.getName(), "str"); - Value *v2 = builder.CreateGlobalStringPtr(f.getName(), "str"); - Value *v3 = builder.CreateGlobalStringPtr(StringRef(scope), "str"); - Value *v4 = builder.CreateGlobalStringPtr(StringRef(flow), "str"); - Value *v5 = builder.CreateGlobalStringPtr(StringRef(pcut), "str"); - builder.SetInsertPoint(&entry, entry.begin()); - std::vector args; - args.push_back(ConstantInt::get(Type::getInt32Ty(context), async)); - args.push_back(v1); - args.push_back(v2); - args.push_back(v3); - args.push_back(v4); - args.push_back(v5); - builder.CreateCall(before, args); - - return true; -} +// /****************************************************************************** +// * * +// * Private Methods of WeavingPass Class * +// * * +// ******************************************************************************/ + +// bool WeavingPass::insertAfter(Module &m, Function &f, StringRef &a, +// int async, std::string &scope, std::string &flow, std::string pcut) +// { +// if (m.empty() || f.empty()) +// { +// return false; +// } + +// auto &context = m.getContext(); +// Type *voidType = Type::getVoidTy(context); +// Type *int32Type = Type::getInt32Ty(context); +// Type *int8PtrType = Type::getInt8PtrTy(context); +// std::vector params; +// params.push_back(int32Type); +// params.push_back(int8PtrType); +// params.push_back(int8PtrType); +// params.push_back(int8PtrType); +// params.push_back(int8PtrType); +// params.push_back(int8PtrType); + +// // voidType is return type, params are parameters and no variable length args +// FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false); +// // Note: Use FunctionCallee after for Clang 9 or higher +// FunctionCallee after = m.getOrInsertFunction("perfflow_weave_after", +// weaveFuncTy); +// // Constant *after = m.getOrInsertFunction("perfflow_weave_after", +// // weaveFuncTy); + +// // iterate through blocks +// for (BasicBlock &bb : f) +// { +// Instruction *inst = bb.getTerminator(); +// if (isa(inst) || isa(inst)) +// { +// IRBuilder<> builder(inst); +// Value *v1 = builder.CreateGlobalStringPtr(m.getName(), "str"); +// Value *v2 = builder.CreateGlobalStringPtr(f.getName(), "str"); +// Value *v3 = builder.CreateGlobalStringPtr(StringRef(scope), "str"); +// Value *v4 = builder.CreateGlobalStringPtr(StringRef(flow), "str"); +// Value *v5 = builder.CreateGlobalStringPtr(StringRef(pcut), "str"); +// std::vector args; +// args.push_back(ConstantInt::get(Type::getInt32Ty(context), async)); +// args.push_back(v1); +// args.push_back(v2); +// args.push_back(v3); +// args.push_back(v4); +// args.push_back(v5); +// builder.CreateCall(after, args); +// } +// } +// return true; +// } + +// bool WeavingPass::insertBefore(Module &m, Function &f, StringRef &a, +// int async, std::string &scope, std::string &flow, std::string pcut) +// { +// if (m.empty() || f.empty()) +// { +// return false; +// } + +// auto &context = m.getContext(); +// Type *voidType = Type::getVoidTy(context); +// Type *int32Type = Type::getInt32Ty(context); +// Type *int8PtrType = Type::getInt8PtrTy(context); +// std::vector params; +// params.push_back(int32Type); +// params.push_back(int8PtrType); +// params.push_back(int8PtrType); +// params.push_back(int8PtrType); +// params.push_back(int8PtrType); +// params.push_back(int8PtrType); + +// // voidType is return type, params are parameters and no variable length args +// FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false); +// // Note: User FunctionCallee before for Clang >= 9.0 +// FunctionCallee before = m.getOrInsertFunction("perfflow_weave_before", +// weaveFuncTy); +// //Constant *before = m.getOrInsertFunction ("perfflow_weave_before", +// // weaveFuncTy); +// auto &entry = f.getEntryBlock(); +// IRBuilder<> builder(&entry); +// Value *v1 = builder.CreateGlobalStringPtr(m.getName(), "str"); +// Value *v2 = builder.CreateGlobalStringPtr(f.getName(), "str"); +// Value *v3 = builder.CreateGlobalStringPtr(StringRef(scope), "str"); +// Value *v4 = builder.CreateGlobalStringPtr(StringRef(flow), "str"); +// Value *v5 = builder.CreateGlobalStringPtr(StringRef(pcut), "str"); +// builder.SetInsertPoint(&entry, entry.begin()); +// std::vector args; +// args.push_back(ConstantInt::get(Type::getInt32Ty(context), async)); +// args.push_back(v1); +// args.push_back(v2); +// args.push_back(v3); +// args.push_back(v4); +// args.push_back(v5); +// builder.CreateCall(before, args); + +// return true; +// } /****************************************************************************** @@ -146,65 +146,68 @@ bool WeavingPass::doInitialization(Module &m) { outs() << "WeavePass loaded successfully. \n"; - auto annotations = m.getNamedGlobal("llvm.global.annotations"); - if (!annotations) - { - return false; - } - - bool changed = false; - auto a = cast (annotations->getOperand(0)); - for (unsigned int i = 0; i < a->getNumOperands(); i++) - { - auto e = cast (a->getOperand(i)); - if (auto *fn = dyn_cast (e->getOperand(0)->getOperand(0))) - { - auto anno = cast( - cast(e->getOperand(1)->getOperand(0)) - ->getOperand(0)) - ->getAsCString(); - std::string pcut, scope, flow; - if (perfflow_parser_parse(anno.data(), pcut, scope, flow) == 0) - { - if (pcut == "around" || pcut == "before") - changed = insertBefore(m, *fn, - anno, 0, scope, flow, pcut) || changed; - else if (pcut == "around_async" || pcut == "before_async") - { - changed = insertBefore(m, *fn, - anno, 1, scope, flow, pcut) || changed; - } - if (pcut == "around" || pcut == "after") - { - if (pcut == "around") - { - if (flow == "in" || flow == "out") - { - flow = "NA"; - } - } - changed = insertAfter(m, *fn, - anno, 0, scope, flow, pcut) || changed; - } - else if (pcut == "around_async" || pcut == "after_async") - { - if (pcut == "around") - { - if (flow == "in" || flow == "out") - { - flow = "NA"; - } - } - changed = insertAfter(m, *fn, - anno, 1, scope, flow, pcut) || changed; - } - } - else - { - errs() << "WeavePass[WARN]: Ignoring " << anno << "\n"; - } - } - } + WeaveCommon weaver; + weaver.modifyAnnotatedFunctions(m); + + // auto annotations = m.getNamedGlobal("llvm.global.annotations"); + // if (!annotations) + // { + // return false; + // } + + // bool changed = false; + // auto a = cast (annotations->getOperand(0)); + // for (unsigned int i = 0; i < a->getNumOperands(); i++) + // { + // auto e = cast (a->getOperand(i)); + // if (auto *fn = dyn_cast (e->getOperand(0)->getOperand(0))) + // { + // auto anno = cast( + // cast(e->getOperand(1)->getOperand(0)) + // ->getOperand(0)) + // ->getAsCString(); + // std::string pcut, scope, flow; + // if (perfflow_parser_parse(anno.data(), pcut, scope, flow) == 0) + // { + // if (pcut == "around" || pcut == "before") + // changed = insertBefore(m, *fn, + // anno, 0, scope, flow, pcut) || changed; + // else if (pcut == "around_async" || pcut == "before_async") + // { + // changed = insertBefore(m, *fn, + // anno, 1, scope, flow, pcut) || changed; + // } + // if (pcut == "around" || pcut == "after") + // { + // if (pcut == "around") + // { + // if (flow == "in" || flow == "out") + // { + // flow = "NA"; + // } + // } + // changed = insertAfter(m, *fn, + // anno, 0, scope, flow, pcut) || changed; + // } + // else if (pcut == "around_async" || pcut == "after_async") + // { + // if (pcut == "around") + // { + // if (flow == "in" || flow == "out") + // { + // flow = "NA"; + // } + // } + // changed = insertAfter(m, *fn, + // anno, 1, scope, flow, pcut) || changed; + // } + // } + // else + // { + // errs() << "WeavePass[WARN]: Ignoring " << anno << "\n"; + // } + // } + // } return changed; } diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index 5f4b8f64..b48c8812 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -8,20 +8,20 @@ * SPDX-License-Identifier: LGPL-3.0 \************************************************************/ -#include "llvm/IR/Value.h" -#include "llvm/IR/Attributes.h" -#include "llvm/IR/Constants.h" -#include "llvm/IR/AbstractCallSite.h" -#include "llvm/IR/Module.h" -#include "llvm/IR/Argument.h" -#include "llvm/IR/IRBuilder.h" -#include "llvm/IR/PassManager.h" -#include "llvm/Passes/PassBuilder.h" -#include "llvm/Passes/PassPlugin.h" -#include "llvm/Transforms/IPO/PassManagerBuilder.h" +// #include "llvm/IR/Value.h" +// #include "llvm/IR/Attributes.h" +// #include "llvm/IR/Constants.h" +// #include "llvm/IR/AbstractCallSite.h" +// #include "llvm/IR/Module.h" +// #include "llvm/IR/Argument.h" +// #include "llvm/IR/IRBuilder.h" +// #include "llvm/IR/PassManager.h" +// #include "llvm/Passes/PassBuilder.h" +// #include "llvm/Passes/PassPlugin.h" +// #include "llvm/Transforms/IPO/PassManagerBuilder.h" #include "llvm/Support/raw_ostream.h" -#include "../../parser/perfflow_parser.hpp" +// #include "../../parser/perfflow_parser.hpp" #include "perfflow_weave_new_pass.hpp" #include #include @@ -32,7 +32,7 @@ using namespace llvm; // Implement the runOnModule Function bool NewWeavingPass::runOnModule(Module &M) { - bool PatkiTest = true; + bool changed = false; // We do nothing right now, let's build to see if this goes through and loads correctly. // The build will probably fail as we are not parsing the annotations. @@ -40,23 +40,29 @@ bool NewWeavingPass::runOnModule(Module &M) // The following loops through each function. This is where we need to check annotation // (from doInitialization in the legacy pass and add the insertBefore/insertAfter) - for (auto &F : M) + + WeaveCommon weaver; + changed = weaver.modifyAnnotatedFunctions(M); + + for (auto &F : M) { if (F.isDeclaration()) continue; - // // Get an IR builder. Sets the insertion point to the top of the function - IRBuilder<> Builder(&*F.getEntryBlock().getFirstInsertionPt()); - - // // Inject a global variable that contains the function name - auto FuncName = Builder.CreateGlobalStringPtr(F.getName()); - if (F.getName().str()=="main") { outs() << "We found main! We will insert Adiak call here eventually.\n"; continue; } + // // Get an IR builder. Sets the insertion point to the top of the function + // IRBuilder<> Builder(&*F.getEntryBlock().getFirstInsertionPt()); + + // // Inject a global variable that contains the function name + // auto FuncName = Builder.CreateGlobalStringPtr(F.getName()); + + + // // Printf requires i8*, but PrintfFormatStrVar is an array: [n x i8]. Add // // a cast: [n x i8] -> i8* // llvm::Value *FormatStrPtr = @@ -74,7 +80,7 @@ bool NewWeavingPass::runOnModule(Module &M) // InsertedAtLeastOnePrintf = true; } - return PatkiTest; + return changed; } // Run on module function. From d880a226e79dc745bfadd0a27582f6f9284ccb50 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Mon, 23 Sep 2024 23:27:38 -0700 Subject: [PATCH 18/62] Add relevant headers, only testing New pass --- src/c/weaver/weave/perfflow_weave_new_pass.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index b48c8812..a56a00c9 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -15,14 +15,15 @@ // #include "llvm/IR/Module.h" // #include "llvm/IR/Argument.h" // #include "llvm/IR/IRBuilder.h" -// #include "llvm/IR/PassManager.h" -// #include "llvm/Passes/PassBuilder.h" -// #include "llvm/Passes/PassPlugin.h" -// #include "llvm/Transforms/IPO/PassManagerBuilder.h" +#include "llvm/IR/PassManager.h" +#include "llvm/Passes/PassBuilder.h" +#include "llvm/Passes/PassPlugin.h" +#include "llvm/Transforms/IPO/PassManagerBuilder.h" #include "llvm/Support/raw_ostream.h" // #include "../../parser/perfflow_parser.hpp" #include "perfflow_weave_new_pass.hpp" +#include "perfflow_weave_common.hpp" #include #include From 4d575189ac86b94ab0ea30070b3541bb603cd282 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Mon, 23 Sep 2024 23:34:53 -0700 Subject: [PATCH 19/62] Pick the right flag --- src/c/weaver/weave/perfflow_weave_common.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c/weaver/weave/perfflow_weave_common.hpp b/src/c/weaver/weave/perfflow_weave_common.hpp index ea08e433..6e968e87 100644 --- a/src/c/weaver/weave/perfflow_weave_common.hpp +++ b/src/c/weaver/weave/perfflow_weave_common.hpp @@ -15,7 +15,7 @@ #include "llvm/IR/Attributes.h" #include "llvm/IR/Constants.h" #include "llvm/IR/LegacyPassManager.h" -#ifdef PERFFLOWASPECT_CLANG_11_NEWER +#if defined(PERFFLOWASPECT_CLANG_11_NEWER) || defined(PERFFLOWASPECT_CLANG_14_NEWER) #include "llvm/IR/AbstractCallSite.h" #else #include "llvm/IR/CallSite.h" From a24825da92d5a4caa9cdbc52002306e45ac73249 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Mon, 23 Sep 2024 23:41:00 -0700 Subject: [PATCH 20/62] NewPassMgr builds correctly. Buildlegacy pass now --- src/c/weaver/weave/perfflow_weave_legacy_pass.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp b/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp index 4772bd33..47593e0a 100644 --- a/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp @@ -20,11 +20,12 @@ //#include "llvm/IR/Module.h" // #include "llvm/IR/Argument.h" // #include "llvm/IR/IRBuilder.h" -// #include "llvm/Transforms/IPO/PassManagerBuilder.h" +#include "llvm/Transforms/IPO/PassManagerBuilder.h" #include "llvm/Support/raw_ostream.h" // #include "../../parser/perfflow_parser.hpp" #include "perfflow_weave_legacy_pass.hpp" +#include "perfflow_weave_common.hpp" using namespace llvm; @@ -146,8 +147,10 @@ bool WeavingPass::doInitialization(Module &m) { outs() << "WeavePass loaded successfully. \n"; + bool changed = false; WeaveCommon weaver; - weaver.modifyAnnotatedFunctions(m); + + changed = weaver.modifyAnnotatedFunctions(m); // auto annotations = m.getNamedGlobal("llvm.global.annotations"); // if (!annotations) From f2b3ffede8ce597dc17ada026d06fe9dca6c2540 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Mon, 23 Sep 2024 23:46:31 -0700 Subject: [PATCH 21/62] Woohoo! We have a working NewPassManager that generates PFW files. Formatting pass --- .../weave/perfflow_weave_legacy_pass.cpp | 6 +-- .../weaver/weave/perfflow_weave_new_pass.cpp | 46 ++++++++++--------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp b/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp index 47593e0a..6f9b6ff3 100644 --- a/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp @@ -147,10 +147,10 @@ bool WeavingPass::doInitialization(Module &m) { outs() << "WeavePass loaded successfully. \n"; - bool changed = false; + bool changed = false; WeaveCommon weaver; - - changed = weaver.modifyAnnotatedFunctions(m); + + changed = weaver.modifyAnnotatedFunctions(m); // auto annotations = m.getNamedGlobal("llvm.global.annotations"); // if (!annotations) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index a56a00c9..17d92ff4 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -42,43 +42,45 @@ bool NewWeavingPass::runOnModule(Module &M) // The following loops through each function. This is where we need to check annotation // (from doInitialization in the legacy pass and add the insertBefore/insertAfter) - WeaveCommon weaver; + WeaveCommon weaver; changed = weaver.modifyAnnotatedFunctions(M); for (auto &F : M) { if (F.isDeclaration()) - continue; + { + continue; + } - if (F.getName().str()=="main") + if (F.getName().str() == "main") { - outs() << "We found main! We will insert Adiak call here eventually.\n"; - continue; + outs() << "We found main! We will insert Adiak call here eventually.\n"; + continue; } - // // Get an IR builder. Sets the insertion point to the top of the function - // IRBuilder<> Builder(&*F.getEntryBlock().getFirstInsertionPt()); + // // Get an IR builder. Sets the insertion point to the top of the function + // IRBuilder<> Builder(&*F.getEntryBlock().getFirstInsertionPt()); + + // // Inject a global variable that contains the function name + // auto FuncName = Builder.CreateGlobalStringPtr(F.getName()); - // // Inject a global variable that contains the function name - // auto FuncName = Builder.CreateGlobalStringPtr(F.getName()); - - // // Printf requires i8*, but PrintfFormatStrVar is an array: [n x i8]. Add - // // a cast: [n x i8] -> i8* - // llvm::Value *FormatStrPtr = - // Builder.CreatePointerCast(PrintfFormatStrVar, PrintfArgTy, "formatStr"); + // // Printf requires i8*, but PrintfFormatStrVar is an array: [n x i8]. Add + // // a cast: [n x i8] -> i8* + // llvm::Value *FormatStrPtr = + // Builder.CreatePointerCast(PrintfFormatStrVar, PrintfArgTy, "formatStr"); - // // The following is visible only if you pass -debug on the command line - // // *and* you have an assert build. - // LLVM_DEBUG(dbgs() << " Injecting call to printf inside " << F.getName() - // << "\n"); + // // The following is visible only if you pass -debug on the command line + // // *and* you have an assert build. + // LLVM_DEBUG(dbgs() << " Injecting call to printf inside " << F.getName() + // << "\n"); - // // Finally, inject a call to printf - // Builder.CreateCall( - // Printf, {FormatStrPtr, FuncName, Builder.getInt32(F.arg_size())}); + // // Finally, inject a call to printf + // Builder.CreateCall( + // Printf, {FormatStrPtr, FuncName, Builder.getInt32(F.arg_size())}); - // InsertedAtLeastOnePrintf = true; + // InsertedAtLeastOnePrintf = true; } return changed; From 5fb02b74ec8f1104e283776651adf4caafeb868e Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Mon, 23 Sep 2024 23:59:01 -0700 Subject: [PATCH 22/62] Comment out some parts of legacy code --- src/c/weaver/weave/perfflow_weave_legacy_pass.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp b/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp index b534da19..c1e6f6ac 100644 --- a/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp +++ b/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp @@ -29,11 +29,11 @@ class WeavingPass : public FunctionPass virtual bool doInitialization (Module &m); virtual bool runOnFunction (Function &F); -private: - bool insertAfter (Module &m, Function &f, StringRef &a, - int async, std::string &scope, std::string &flow, std::string pcut); - bool insertBefore (Module &m, Function &f, StringRef &a, - int async, std::string &scope, std::string &flow, std::string pcut); +// private: +// bool insertAfter (Module &m, Function &f, StringRef &a, +// int async, std::string &scope, std::string &flow, std::string pcut); +// bool insertBefore (Module &m, Function &f, StringRef &a, +// int async, std::string &scope, std::string &flow, std::string pcut); }; } From 54347525fd2f276990e527d575cc43e85478b5e7 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Tue, 24 Sep 2024 12:41:16 -0700 Subject: [PATCH 23/62] Code Cleanup Pass 1. Rename some classes, variables, remove commented code. --- src/c/weaver/weave/perfflow_weave_common.hpp | 5 + .../weave/perfflow_weave_legacy_pass.cpp | 189 +----------------- .../weave/perfflow_weave_legacy_pass.hpp | 9 +- .../weaver/weave/perfflow_weave_new_pass.cpp | 48 +---- .../weaver/weave/perfflow_weave_new_pass.hpp | 21 +- 5 files changed, 17 insertions(+), 255 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_common.hpp b/src/c/weaver/weave/perfflow_weave_common.hpp index 6e968e87..4881c560 100644 --- a/src/c/weaver/weave/perfflow_weave_common.hpp +++ b/src/c/weaver/weave/perfflow_weave_common.hpp @@ -222,3 +222,8 @@ bool WeaveCommon::insertBefore(Module &m, Function &f, StringRef &a, } // End namespace #endif // PERFFLOW_WEAVE_COMMON_H + + +/* + * vi:tabstop=4 shiftwidth=4 expandtab + */ diff --git a/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp b/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp index 6f9b6ff3..778c36e6 100644 --- a/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp @@ -8,225 +8,46 @@ * SPDX-License-Identifier: LGPL-3.0 \************************************************************/ -// #include "llvm/IR/Value.h" -// #include "llvm/IR/Attributes.h" -// #include "llvm/IR/Constants.h" #include "llvm/IR/LegacyPassManager.h" -#ifdef PERFFLOWASPECT_CLANG_11_NEWER -#include "llvm/IR/AbstractCallSite.h" -#else -#include "llvm/IR/CallSite.h" -#endif -//#include "llvm/IR/Module.h" -// #include "llvm/IR/Argument.h" -// #include "llvm/IR/IRBuilder.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" #include "llvm/Support/raw_ostream.h" -// #include "../../parser/perfflow_parser.hpp" #include "perfflow_weave_legacy_pass.hpp" #include "perfflow_weave_common.hpp" using namespace llvm; - -// /****************************************************************************** -// * * -// * Private Methods of WeavingPass Class * -// * * -// ******************************************************************************/ - -// bool WeavingPass::insertAfter(Module &m, Function &f, StringRef &a, -// int async, std::string &scope, std::string &flow, std::string pcut) -// { -// if (m.empty() || f.empty()) -// { -// return false; -// } - -// auto &context = m.getContext(); -// Type *voidType = Type::getVoidTy(context); -// Type *int32Type = Type::getInt32Ty(context); -// Type *int8PtrType = Type::getInt8PtrTy(context); -// std::vector params; -// params.push_back(int32Type); -// params.push_back(int8PtrType); -// params.push_back(int8PtrType); -// params.push_back(int8PtrType); -// params.push_back(int8PtrType); -// params.push_back(int8PtrType); - -// // voidType is return type, params are parameters and no variable length args -// FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false); -// // Note: Use FunctionCallee after for Clang 9 or higher -// FunctionCallee after = m.getOrInsertFunction("perfflow_weave_after", -// weaveFuncTy); -// // Constant *after = m.getOrInsertFunction("perfflow_weave_after", -// // weaveFuncTy); - -// // iterate through blocks -// for (BasicBlock &bb : f) -// { -// Instruction *inst = bb.getTerminator(); -// if (isa(inst) || isa(inst)) -// { -// IRBuilder<> builder(inst); -// Value *v1 = builder.CreateGlobalStringPtr(m.getName(), "str"); -// Value *v2 = builder.CreateGlobalStringPtr(f.getName(), "str"); -// Value *v3 = builder.CreateGlobalStringPtr(StringRef(scope), "str"); -// Value *v4 = builder.CreateGlobalStringPtr(StringRef(flow), "str"); -// Value *v5 = builder.CreateGlobalStringPtr(StringRef(pcut), "str"); -// std::vector args; -// args.push_back(ConstantInt::get(Type::getInt32Ty(context), async)); -// args.push_back(v1); -// args.push_back(v2); -// args.push_back(v3); -// args.push_back(v4); -// args.push_back(v5); -// builder.CreateCall(after, args); -// } -// } -// return true; -// } - -// bool WeavingPass::insertBefore(Module &m, Function &f, StringRef &a, -// int async, std::string &scope, std::string &flow, std::string pcut) -// { -// if (m.empty() || f.empty()) -// { -// return false; -// } - -// auto &context = m.getContext(); -// Type *voidType = Type::getVoidTy(context); -// Type *int32Type = Type::getInt32Ty(context); -// Type *int8PtrType = Type::getInt8PtrTy(context); -// std::vector params; -// params.push_back(int32Type); -// params.push_back(int8PtrType); -// params.push_back(int8PtrType); -// params.push_back(int8PtrType); -// params.push_back(int8PtrType); -// params.push_back(int8PtrType); - -// // voidType is return type, params are parameters and no variable length args -// FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false); -// // Note: User FunctionCallee before for Clang >= 9.0 -// FunctionCallee before = m.getOrInsertFunction("perfflow_weave_before", -// weaveFuncTy); -// //Constant *before = m.getOrInsertFunction ("perfflow_weave_before", -// // weaveFuncTy); -// auto &entry = f.getEntryBlock(); -// IRBuilder<> builder(&entry); -// Value *v1 = builder.CreateGlobalStringPtr(m.getName(), "str"); -// Value *v2 = builder.CreateGlobalStringPtr(f.getName(), "str"); -// Value *v3 = builder.CreateGlobalStringPtr(StringRef(scope), "str"); -// Value *v4 = builder.CreateGlobalStringPtr(StringRef(flow), "str"); -// Value *v5 = builder.CreateGlobalStringPtr(StringRef(pcut), "str"); -// builder.SetInsertPoint(&entry, entry.begin()); -// std::vector args; -// args.push_back(ConstantInt::get(Type::getInt32Ty(context), async)); -// args.push_back(v1); -// args.push_back(v2); -// args.push_back(v3); -// args.push_back(v4); -// args.push_back(v5); -// builder.CreateCall(before, args); - -// return true; -// } - - /****************************************************************************** * * * Public Methods of WeavingPass Class * * * ******************************************************************************/ -bool WeavingPass::doInitialization(Module &m) +bool LegacyWeavingPass::doInitialization(Module &m) { outs() << "WeavePass loaded successfully. \n"; bool changed = false; - WeaveCommon weaver; + WeaveCommon weaver; changed = weaver.modifyAnnotatedFunctions(m); - // auto annotations = m.getNamedGlobal("llvm.global.annotations"); - // if (!annotations) - // { - // return false; - // } - - // bool changed = false; - // auto a = cast (annotations->getOperand(0)); - // for (unsigned int i = 0; i < a->getNumOperands(); i++) - // { - // auto e = cast (a->getOperand(i)); - // if (auto *fn = dyn_cast (e->getOperand(0)->getOperand(0))) - // { - // auto anno = cast( - // cast(e->getOperand(1)->getOperand(0)) - // ->getOperand(0)) - // ->getAsCString(); - // std::string pcut, scope, flow; - // if (perfflow_parser_parse(anno.data(), pcut, scope, flow) == 0) - // { - // if (pcut == "around" || pcut == "before") - // changed = insertBefore(m, *fn, - // anno, 0, scope, flow, pcut) || changed; - // else if (pcut == "around_async" || pcut == "before_async") - // { - // changed = insertBefore(m, *fn, - // anno, 1, scope, flow, pcut) || changed; - // } - // if (pcut == "around" || pcut == "after") - // { - // if (pcut == "around") - // { - // if (flow == "in" || flow == "out") - // { - // flow = "NA"; - // } - // } - // changed = insertAfter(m, *fn, - // anno, 0, scope, flow, pcut) || changed; - // } - // else if (pcut == "around_async" || pcut == "after_async") - // { - // if (pcut == "around") - // { - // if (flow == "in" || flow == "out") - // { - // flow = "NA"; - // } - // } - // changed = insertAfter(m, *fn, - // anno, 1, scope, flow, pcut) || changed; - // } - // } - // else - // { - // errs() << "WeavePass[WARN]: Ignoring " << anno << "\n"; - // } - // } - // } return changed; } -bool WeavingPass::runOnFunction(Function &F) +bool LegacyWeavingPass::runOnFunction(Function &F) { return false; } -char WeavingPass::ID = 0; +char LegacyWeavingPass::ID = 0; // Automatically enable the pass. // http://adriansampson.net/blog/clangpass.html static void registerWeavingPass(const PassManagerBuilder &, legacy::PassManagerBase &PM) { - PM.add(new WeavingPass()); + PM.add(new LegacyWeavingPass()); } static RegisterStandardPasses diff --git a/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp b/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp index c1e6f6ac..8ce6a41c 100644 --- a/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp +++ b/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp @@ -21,21 +21,14 @@ using namespace llvm; namespace { -class WeavingPass : public FunctionPass +class LegacyWeavingPass : public FunctionPass { public: static char ID; WeavingPass () : FunctionPass (ID) {} virtual bool doInitialization (Module &m); virtual bool runOnFunction (Function &F); - -// private: -// bool insertAfter (Module &m, Function &f, StringRef &a, -// int async, std::string &scope, std::string &flow, std::string pcut); -// bool insertBefore (Module &m, Function &f, StringRef &a, -// int async, std::string &scope, std::string &flow, std::string pcut); }; - } #endif // PERFFLOW_WEAVE_LEGACY_PASS_H diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index 17d92ff4..fc25cfb1 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -8,43 +8,29 @@ * SPDX-License-Identifier: LGPL-3.0 \************************************************************/ -// #include "llvm/IR/Value.h" -// #include "llvm/IR/Attributes.h" -// #include "llvm/IR/Constants.h" -// #include "llvm/IR/AbstractCallSite.h" -// #include "llvm/IR/Module.h" -// #include "llvm/IR/Argument.h" -// #include "llvm/IR/IRBuilder.h" #include "llvm/IR/PassManager.h" #include "llvm/Passes/PassBuilder.h" #include "llvm/Passes/PassPlugin.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" #include "llvm/Support/raw_ostream.h" -// #include "../../parser/perfflow_parser.hpp" #include "perfflow_weave_new_pass.hpp" #include "perfflow_weave_common.hpp" #include #include using namespace llvm; -// using namespace std; // Implement the runOnModule Function bool NewWeavingPass::runOnModule(Module &M) { bool changed = false; - // We do nothing right now, let's build to see if this goes through and loads correctly. - // The build will probably fail as we are not parsing the annotations. - outs() << "NewWeavePass loaded successfully! \n"; - // The following loops through each function. This is where we need to check annotation - // (from doInitialization in the legacy pass and add the insertBefore/insertAfter) - WeaveCommon weaver; changed = weaver.modifyAnnotatedFunctions(M); + // Placeholder: search for the main() function to insert an Adiak call for (auto &F : M) { if (F.isDeclaration()) @@ -57,42 +43,18 @@ bool NewWeavingPass::runOnModule(Module &M) outs() << "We found main! We will insert Adiak call here eventually.\n"; continue; } - - // // Get an IR builder. Sets the insertion point to the top of the function - // IRBuilder<> Builder(&*F.getEntryBlock().getFirstInsertionPt()); - - // // Inject a global variable that contains the function name - // auto FuncName = Builder.CreateGlobalStringPtr(F.getName()); - - - - // // Printf requires i8*, but PrintfFormatStrVar is an array: [n x i8]. Add - // // a cast: [n x i8] -> i8* - // llvm::Value *FormatStrPtr = - // Builder.CreatePointerCast(PrintfFormatStrVar, PrintfArgTy, "formatStr"); - - // // The following is visible only if you pass -debug on the command line - // // *and* you have an assert build. - // LLVM_DEBUG(dbgs() << " Injecting call to printf inside " << F.getName() - // << "\n"); - - // // Finally, inject a call to printf - // Builder.CreateCall( - // Printf, {FormatStrPtr, FuncName, Builder.getInt32(F.arg_size())}); - - // InsertedAtLeastOnePrintf = true; } return changed; } // Run on module function. -PreservedAnalyses NewWeavingPass::run(llvm::Module &M, - llvm::ModuleAnalysisManager &) +PreservedAnalyses NewWeavingPass::run(Module &M, + ModuleAnalysisManager &) { - bool Changed = runOnModule(M); + bool changed = runOnModule(M); - return (Changed ? llvm::PreservedAnalyses::none() + return (changed ? llvm::PreservedAnalyses::none() : llvm::PreservedAnalyses::all()); } diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.hpp b/src/c/weaver/weave/perfflow_weave_new_pass.hpp index ad0b1fdc..83f0439e 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.hpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.hpp @@ -22,8 +22,6 @@ namespace { class NewWeavingPass : public PassInfoMixin { public: - // Revist this if we really need a function pass - // PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); PreservedAnalyses run(Module &M, ModuleAnalysisManager &); bool runOnModule(Module &M); @@ -34,24 +32,7 @@ class NewWeavingPass : public PassInfoMixin { }; - - -// class WeavingPass : public FunctionPass -// { -// public: -// static char ID; -// WeavingPass () : FunctionPass (ID) {} -// virtual bool doInitialization (Module &m); -// virtual bool runOnFunction (Function &F); - -// private: -// bool insertAfter (Module &m, Function &f, StringRef &a, -// int async, std::string &scope, std::string &flow, std::string pcut); -// bool insertBefore (Module &m, Function &f, StringRef &a, -// int async, std::string &scope, std::string &flow, std::string pcut); -// }; - - } +} #endif // PERFFLOW_WEAVE_NEW_PASS_H From 259b9d86729d4327e0a9e6d75ddf73e0ed3d81f4 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Tue, 24 Sep 2024 15:06:35 -0700 Subject: [PATCH 24/62] Split perfflow_weave_common into hpp and cpp --- src/c/weaver/weave/perfflow_weave_common.cpp | 193 ++++++++++++++++++ .../weave/perfflow_weave_legacy_pass.cpp | 2 +- .../weaver/weave/perfflow_weave_new_pass.cpp | 7 + .../weaver/weave/perfflow_weave_new_pass.hpp | 1 - 4 files changed, 201 insertions(+), 2 deletions(-) create mode 100644 src/c/weaver/weave/perfflow_weave_common.cpp diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp new file mode 100644 index 00000000..84a4b93e --- /dev/null +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -0,0 +1,193 @@ +/************************************************************\ + * Copyright 2021 Lawrence Livermore National Security, LLC + * (c.f. AUTHORS, NOTICE.LLNS, COPYING) + * + * This file is part of the Flux resource manager framework. + * For details, see https://github.com/flux-framework. + * + * SPDX-License-Identifier: LGPL-3.0 +\************************************************************/ + +#include "perfflow_weave_common.hpp" + +/****************************************************************************** + * * + * Public Method of WeaveCommon Class * + * * + ******************************************************************************/ + +bool WeaveCommon::modifyAnnotatedFunctions(Module &m) +{ + auto annotations = m.getNamedGlobal("llvm.global.annotations"); + if (!annotations) + { + return false; + } + + bool changed = false; + auto a = cast (annotations->getOperand(0)); + for (unsigned int i = 0; i < a->getNumOperands(); i++) + { + auto e = cast (a->getOperand(i)); + if (auto *fn = dyn_cast (e->getOperand(0)->getOperand(0))) + { + auto anno = cast( + cast(e->getOperand(1)->getOperand(0)) + ->getOperand(0)) + ->getAsCString(); + std::string pcut, scope, flow; + if (perfflow_parser_parse(anno.data(), pcut, scope, flow) == 0) + { + if (pcut == "around" || pcut == "before") + changed = insertBefore(m, *fn, + anno, 0, scope, flow, pcut) || changed; + else if (pcut == "around_async" || pcut == "before_async") + { + changed = insertBefore(m, *fn, + anno, 1, scope, flow, pcut) || changed; + } + if (pcut == "around" || pcut == "after") + { + if (pcut == "around") + { + if (flow == "in" || flow == "out") + { + flow = "NA"; + } + } + changed = insertAfter(m, *fn, + anno, 0, scope, flow, pcut) || changed; + } + else if (pcut == "around_async" || pcut == "after_async") + { + if (pcut == "around") + { + if (flow == "in" || flow == "out") + { + flow = "NA"; + } + } + changed = insertAfter(m, *fn, + anno, 1, scope, flow, pcut) || changed; + } + } + else + { + errs() << "WeavePass[WARN]: Ignoring " << anno << "\n"; + } + } + } + return changed; + +} + + +/****************************************************************************** + * * + * Private Methods of WeaveCommon Class * + * * + ******************************************************************************/ + +bool WeaveCommon::insertAfter(Module &m, Function &f, StringRef &a, + int async, std::string &scope, std::string &flow, std::string pcut) +{ + if (m.empty() || f.empty()) + { + return false; + } + + auto &context = m.getContext(); + Type *voidType = Type::getVoidTy(context); + Type *int32Type = Type::getInt32Ty(context); + Type *int8PtrType = Type::getInt8PtrTy(context); + std::vector params; + params.push_back(int32Type); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + + // voidType is return type, params are parameters and no variable length args + FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false); + // Note: Use FunctionCallee after for Clang 9 or higher + FunctionCallee after = m.getOrInsertFunction("perfflow_weave_after", + weaveFuncTy); + // Constant *after = m.getOrInsertFunction("perfflow_weave_after", + // weaveFuncTy); + + // iterate through blocks + for (BasicBlock &bb : f) + { + Instruction *inst = bb.getTerminator(); + if (isa(inst) || isa(inst)) + { + IRBuilder<> builder(inst); + Value *v1 = builder.CreateGlobalStringPtr(m.getName(), "str"); + Value *v2 = builder.CreateGlobalStringPtr(f.getName(), "str"); + Value *v3 = builder.CreateGlobalStringPtr(StringRef(scope), "str"); + Value *v4 = builder.CreateGlobalStringPtr(StringRef(flow), "str"); + Value *v5 = builder.CreateGlobalStringPtr(StringRef(pcut), "str"); + std::vector args; + args.push_back(ConstantInt::get(Type::getInt32Ty(context), async)); + args.push_back(v1); + args.push_back(v2); + args.push_back(v3); + args.push_back(v4); + args.push_back(v5); + builder.CreateCall(after, args); + } + } + return true; +} + +bool WeaveCommon::insertBefore(Module &m, Function &f, StringRef &a, + int async, std::string &scope, std::string &flow, std::string pcut) +{ + if (m.empty() || f.empty()) + { + return false; + } + + auto &context = m.getContext(); + Type *voidType = Type::getVoidTy(context); + Type *int32Type = Type::getInt32Ty(context); + Type *int8PtrType = Type::getInt8PtrTy(context); + std::vector params; + params.push_back(int32Type); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + params.push_back(int8PtrType); + + // voidType is return type, params are parameters and no variable length args + FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false); + // Note: User FunctionCallee before for Clang >= 9.0 + FunctionCallee before = m.getOrInsertFunction("perfflow_weave_before", + weaveFuncTy); + //Constant *before = m.getOrInsertFunction ("perfflow_weave_before", + // weaveFuncTy); + auto &entry = f.getEntryBlock(); + IRBuilder<> builder(&entry); + Value *v1 = builder.CreateGlobalStringPtr(m.getName(), "str"); + Value *v2 = builder.CreateGlobalStringPtr(f.getName(), "str"); + Value *v3 = builder.CreateGlobalStringPtr(StringRef(scope), "str"); + Value *v4 = builder.CreateGlobalStringPtr(StringRef(flow), "str"); + Value *v5 = builder.CreateGlobalStringPtr(StringRef(pcut), "str"); + builder.SetInsertPoint(&entry, entry.begin()); + std::vector args; + args.push_back(ConstantInt::get(Type::getInt32Ty(context), async)); + args.push_back(v1); + args.push_back(v2); + args.push_back(v3); + args.push_back(v4); + args.push_back(v5); + builder.CreateCall(before, args); + + return true; +} + +/* + * vi:tabstop=4 shiftwidth=4 expandtab + */ diff --git a/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp b/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp index 778c36e6..11d317b7 100644 --- a/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp @@ -19,7 +19,7 @@ using namespace llvm; /****************************************************************************** * * - * Public Methods of WeavingPass Class * + * Public Methods of LegacyWeavingPass Class * * * ******************************************************************************/ diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index fc25cfb1..fe7ded37 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -21,6 +21,13 @@ using namespace llvm; + +/****************************************************************************** + * * + * Public Methods of NewWeavingPass Class * + * * + ******************************************************************************/ + // Implement the runOnModule Function bool NewWeavingPass::runOnModule(Module &M) { diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.hpp b/src/c/weaver/weave/perfflow_weave_new_pass.hpp index 83f0439e..b93c3e6d 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.hpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.hpp @@ -36,7 +36,6 @@ class NewWeavingPass : public PassInfoMixin { #endif // PERFFLOW_WEAVE_NEW_PASS_H - /* * vi:tabstop=4 shiftwidth=4 expandtab */ From 15c3f2fa1400e6470e95e96811b8ca9569483be1 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Tue, 24 Sep 2024 15:06:59 -0700 Subject: [PATCH 25/62] Formatting pass --- src/c/weaver/weave/perfflow_weave_common.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index 84a4b93e..21d07fc6 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -18,7 +18,7 @@ bool WeaveCommon::modifyAnnotatedFunctions(Module &m) { - auto annotations = m.getNamedGlobal("llvm.global.annotations"); + auto annotations = m.getNamedGlobal("llvm.global.annotations"); if (!annotations) { return false; @@ -77,7 +77,7 @@ bool WeaveCommon::modifyAnnotatedFunctions(Module &m) } } } - return changed; + return changed; } From 2c6e2fff110a6f34133b09ff599a3345ae06d01e Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Tue, 24 Sep 2024 15:40:49 -0700 Subject: [PATCH 26/62] Remove Adiak testing and main function hooks from this PR --- .../weaver/weave/perfflow_weave_new_pass.cpp | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index fe7ded37..a69457dd 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -21,7 +21,6 @@ using namespace llvm; - /****************************************************************************** * * * Public Methods of NewWeavingPass Class * @@ -36,22 +35,7 @@ bool NewWeavingPass::runOnModule(Module &M) WeaveCommon weaver; changed = weaver.modifyAnnotatedFunctions(M); - - // Placeholder: search for the main() function to insert an Adiak call - for (auto &F : M) - { - if (F.isDeclaration()) - { - continue; - } - - if (F.getName().str() == "main") - { - outs() << "We found main! We will insert Adiak call here eventually.\n"; - continue; - } - } - + return changed; } @@ -92,3 +76,7 @@ extern "C" LLVM_ATTRIBUTE_WEAK PassPluginLibraryInfo llvmGetPassPluginInfo() { return getNewWeavingPassPluginInfo(); } + +/* + * vi:tabstop=4 shiftwidth=4 expandtab + */ From 3596fed0de39fa9b7eeffb07244ef46ae2222b3e Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Tue, 24 Sep 2024 15:42:06 -0700 Subject: [PATCH 27/62] Formatting pass --- src/c/weaver/weave/perfflow_weave_new_pass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index a69457dd..0a604fc5 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -35,7 +35,7 @@ bool NewWeavingPass::runOnModule(Module &M) WeaveCommon weaver; changed = weaver.modifyAnnotatedFunctions(M); - + return changed; } From b2ee0f27e48a8da36681a9c346c13a9af62b2e98 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Wed, 25 Sep 2024 17:35:34 -0700 Subject: [PATCH 28/62] Edit the Weaver CMake to allow c++17 build. --- src/c/weaver/weave/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/c/weaver/weave/CMakeLists.txt b/src/c/weaver/weave/CMakeLists.txt index 30aebd1e..b728e2f3 100644 --- a/src/c/weaver/weave/CMakeLists.txt +++ b/src/c/weaver/weave/CMakeLists.txt @@ -12,8 +12,14 @@ else() ) endif() -# Use C++11 to compile our pass (i.e., supply -std=c++11). -target_compile_features(WeavePass PRIVATE cxx_range_for cxx_auto_type) +if (PERFFLOWASPECT_CLANG_14_NEWER) + # Use C++17 to compile our pass + target_compile_features(WeavePass PRIVATE cxx_std_17 cxx_range_for cxx_auto_type) +else() + # Use C++11/C++14 to compile our pass (i.e., supply -std=c++11) (pick default) + target_compile_features(WeavePass PRIVATE cxx_range_for cxx_auto_type) +endif() + # LLVM is (typically) built with no C++ RTTI. We need to match that; # otherwise, we'll get linker errors about missing RTTI data. From 77f86bc37ed5c71d979cf0e7f01b38dab3f53225 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Wed, 25 Sep 2024 17:36:13 -0700 Subject: [PATCH 29/62] Debugging commit, revert later. --- src/c/weaver/weave/perfflow_weave_common.cpp | 22 ++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index 21d07fc6..38d6d14d 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -18,19 +18,34 @@ bool WeaveCommon::modifyAnnotatedFunctions(Module &m) { - auto annotations = m.getNamedGlobal("llvm.global.annotations"); + auto annotations = m.getNamedGlobal("llvm.global.annotations"); if (!annotations) { return false; } bool changed = false; - auto a = cast (annotations->getOperand(0)); + + if (annotations.getNumOperands() > 0) + { + outs() << "I have %d operands!" << annotations.getNumOperands() << "\n"; + auto a = cast (annotations->getOperand(0)); + } + else + return changed; + + for (unsigned int i = 0; i < a->getNumOperands(); i++) { auto e = cast (a->getOperand(i)); + if (!e) + { + outs() << "I failed here at obtaining the struct. \n"; + } + if (auto *fn = dyn_cast (e->getOperand(0)->getOperand(0))) { + outs() << "I entered the part where we parse annotations. \n"; auto anno = cast( cast(e->getOperand(1)->getOperand(0)) ->getOperand(0)) @@ -77,11 +92,10 @@ bool WeaveCommon::modifyAnnotatedFunctions(Module &m) } } } - return changed; + return changed; } - /****************************************************************************** * * * Private Methods of WeaveCommon Class * From 4554d054ec422d6d73010c65fd1039def62aa28b Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Wed, 25 Sep 2024 17:40:39 -0700 Subject: [PATCH 30/62] Debugging. --- src/c/weaver/weave/perfflow_weave_common.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index 38d6d14d..c11691db 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -18,7 +18,9 @@ bool WeaveCommon::modifyAnnotatedFunctions(Module &m) { - auto annotations = m.getNamedGlobal("llvm.global.annotations"); + outs() << "I am in modifyAnnotatedFunctions \n"; + + auto annotations = m.getNamedGlobal("llvm.global.annotations"); if (!annotations) { return false; @@ -28,12 +30,14 @@ bool WeaveCommon::modifyAnnotatedFunctions(Module &m) if (annotations.getNumOperands() > 0) { - outs() << "I have %d operands!" << annotations.getNumOperands() << "\n"; + outs() << "I have %d operands!" << annotations.getNumOperands() << "\n"; auto a = cast (annotations->getOperand(0)); } else + { + outs() << "I have failed as there are no operands!\n"; return changed; - + } for (unsigned int i = 0; i < a->getNumOperands(); i++) { From 5274717d42f5eb6431c10a7b4e111f313518bac0 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Wed, 25 Sep 2024 18:21:32 -0700 Subject: [PATCH 31/62] Fix several issues due to uncommitted changes previously. Can identify the problem, but still debugging --- src/c/weaver/weave/CMakeLists.txt | 2 + src/c/weaver/weave/perfflow_weave_common.cpp | 38 ++-- src/c/weaver/weave/perfflow_weave_common.hpp | 178 +----------------- .../weave/perfflow_weave_legacy_pass.cpp | 1 + .../weaver/weave/perfflow_weave_new_pass.cpp | 1 + 5 files changed, 30 insertions(+), 190 deletions(-) diff --git a/src/c/weaver/weave/CMakeLists.txt b/src/c/weaver/weave/CMakeLists.txt index b728e2f3..f1726c5c 100644 --- a/src/c/weaver/weave/CMakeLists.txt +++ b/src/c/weaver/weave/CMakeLists.txt @@ -2,12 +2,14 @@ if (PERFFLOWASPECT_CLANG_14_NEWER) # Add the new pass add_library(WeavePass MODULE # List your source files here. + perfflow_weave_common.cpp perfflow_weave_new_pass.cpp ) else() # Add the legacy pass if we have Clang < 14. add_library(WeavePass MODULE # List your source files here. + perfflow_weave_common.cpp perfflow_weave_legacy_pass.cpp ) endif() diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index c11691db..3fa70751 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -10,15 +10,17 @@ #include "perfflow_weave_common.hpp" +using namespace llvm; + /****************************************************************************** * * * Public Method of WeaveCommon Class * * * ******************************************************************************/ -bool WeaveCommon::modifyAnnotatedFunctions(Module &m) +bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) { - outs() << "I am in modifyAnnotatedFunctions \n"; + outs() << "I am in modifyAnnotatedFunctions \n"; auto annotations = m.getNamedGlobal("llvm.global.annotations"); if (!annotations) @@ -27,29 +29,35 @@ bool WeaveCommon::modifyAnnotatedFunctions(Module &m) } bool changed = false; - - if (annotations.getNumOperands() > 0) + + if (annotations->getNumOperands() <= 0) { - outs() << "I have %d operands!" << annotations.getNumOperands() << "\n"; - auto a = cast (annotations->getOperand(0)); + outs() << "I have failed as there are no operands!\n"; + return changed; } else { - outs() << "I have failed as there are no operands!\n"; - return changed; + outs() << "I have " << annotations->getNumOperands() << " operands.\n"; } + auto a = cast (annotations->getOperand(0)); for (unsigned int i = 0; i < a->getNumOperands(); i++) { auto e = cast (a->getOperand(i)); if (!e) { - outs() << "I failed here at obtaining the struct. \n"; + outs() << "I failed here at obtaining the struct. \n"; + } + else + { + outs() << "e has " << e->getNumOperands() << " operands.\n"; + outs() << "e's first operand has " << e->getOperand(0)->getNumOperands() << + " operands.\n"; } if (auto *fn = dyn_cast (e->getOperand(0)->getOperand(0))) { - outs() << "I entered the part where we parse annotations. \n"; + outs() << "I entered the part where we parse annotations. \n"; auto anno = cast( cast(e->getOperand(1)->getOperand(0)) ->getOperand(0)) @@ -96,7 +104,7 @@ bool WeaveCommon::modifyAnnotatedFunctions(Module &m) } } } - return changed; + return changed; } @@ -106,8 +114,8 @@ bool WeaveCommon::modifyAnnotatedFunctions(Module &m) * * ******************************************************************************/ -bool WeaveCommon::insertAfter(Module &m, Function &f, StringRef &a, - int async, std::string &scope, std::string &flow, std::string pcut) +bool weave_ns::WeaveCommon::insertAfter(Module &m, Function &f, StringRef &a, + int async, std::string &scope, std::string &flow, std::string pcut) { if (m.empty() || f.empty()) { @@ -159,8 +167,8 @@ bool WeaveCommon::insertAfter(Module &m, Function &f, StringRef &a, return true; } -bool WeaveCommon::insertBefore(Module &m, Function &f, StringRef &a, - int async, std::string &scope, std::string &flow, std::string pcut) +bool weave_ns::WeaveCommon::insertBefore(Module &m, Function &f, StringRef &a, + int async, std::string &scope, std::string &flow, std::string pcut) { if (m.empty() || f.empty()) { diff --git a/src/c/weaver/weave/perfflow_weave_common.hpp b/src/c/weaver/weave/perfflow_weave_common.hpp index 4881c560..13c641ea 100644 --- a/src/c/weaver/weave/perfflow_weave_common.hpp +++ b/src/c/weaver/weave/perfflow_weave_common.hpp @@ -28,7 +28,9 @@ #include "../../parser/perfflow_parser.hpp" -namespace { +using namespace llvm; + +namespace weave_ns { class WeaveCommon { @@ -45,180 +47,6 @@ class WeaveCommon }; -/* -Public Member definition. -Need to clean this up so it reads better, and doesn't look like C++ jargon with random casts and is explainable. -*/ - -bool WeaveCommon::modifyAnnotatedFunctions(Module &m) -{ - auto annotations = m.getNamedGlobal("llvm.global.annotations"); - if (!annotations) - { - return false; - } - - bool changed = false; - auto a = cast (annotations->getOperand(0)); - for (unsigned int i = 0; i < a->getNumOperands(); i++) - { - auto e = cast (a->getOperand(i)); - if (auto *fn = dyn_cast (e->getOperand(0)->getOperand(0))) - { - auto anno = cast( - cast(e->getOperand(1)->getOperand(0)) - ->getOperand(0)) - ->getAsCString(); - std::string pcut, scope, flow; - if (perfflow_parser_parse(anno.data(), pcut, scope, flow) == 0) - { - if (pcut == "around" || pcut == "before") - changed = insertBefore(m, *fn, - anno, 0, scope, flow, pcut) || changed; - else if (pcut == "around_async" || pcut == "before_async") - { - changed = insertBefore(m, *fn, - anno, 1, scope, flow, pcut) || changed; - } - if (pcut == "around" || pcut == "after") - { - if (pcut == "around") - { - if (flow == "in" || flow == "out") - { - flow = "NA"; - } - } - changed = insertAfter(m, *fn, - anno, 0, scope, flow, pcut) || changed; - } - else if (pcut == "around_async" || pcut == "after_async") - { - if (pcut == "around") - { - if (flow == "in" || flow == "out") - { - flow = "NA"; - } - } - changed = insertAfter(m, *fn, - anno, 1, scope, flow, pcut) || changed; - } - } - else - { - errs() << "WeavePass[WARN]: Ignoring " << anno << "\n"; - } - } - } - return changed; - -} - -/* -Private Member Function Definitions -*/ - -bool WeaveCommon::insertAfter(Module &m, Function &f, StringRef &a, - int async, std::string &scope, std::string &flow, std::string pcut) -{ - if (m.empty() || f.empty()) - { - return false; - } - - auto &context = m.getContext(); - Type *voidType = Type::getVoidTy(context); - Type *int32Type = Type::getInt32Ty(context); - Type *int8PtrType = Type::getInt8PtrTy(context); - std::vector params; - params.push_back(int32Type); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - - // voidType is return type, params are parameters and no variable length args - FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false); - // Note: Use FunctionCallee after for Clang 9 or higher - FunctionCallee after = m.getOrInsertFunction("perfflow_weave_after", - weaveFuncTy); - // Constant *after = m.getOrInsertFunction("perfflow_weave_after", - // weaveFuncTy); - - // iterate through blocks - for (BasicBlock &bb : f) - { - Instruction *inst = bb.getTerminator(); - if (isa(inst) || isa(inst)) - { - IRBuilder<> builder(inst); - Value *v1 = builder.CreateGlobalStringPtr(m.getName(), "str"); - Value *v2 = builder.CreateGlobalStringPtr(f.getName(), "str"); - Value *v3 = builder.CreateGlobalStringPtr(StringRef(scope), "str"); - Value *v4 = builder.CreateGlobalStringPtr(StringRef(flow), "str"); - Value *v5 = builder.CreateGlobalStringPtr(StringRef(pcut), "str"); - std::vector args; - args.push_back(ConstantInt::get(Type::getInt32Ty(context), async)); - args.push_back(v1); - args.push_back(v2); - args.push_back(v3); - args.push_back(v4); - args.push_back(v5); - builder.CreateCall(after, args); - } - } - return true; -} - -bool WeaveCommon::insertBefore(Module &m, Function &f, StringRef &a, - int async, std::string &scope, std::string &flow, std::string pcut) -{ - if (m.empty() || f.empty()) - { - return false; - } - - auto &context = m.getContext(); - Type *voidType = Type::getVoidTy(context); - Type *int32Type = Type::getInt32Ty(context); - Type *int8PtrType = Type::getInt8PtrTy(context); - std::vector params; - params.push_back(int32Type); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - - // voidType is return type, params are parameters and no variable length args - FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false); - // Note: User FunctionCallee before for Clang >= 9.0 - FunctionCallee before = m.getOrInsertFunction("perfflow_weave_before", - weaveFuncTy); - //Constant *before = m.getOrInsertFunction ("perfflow_weave_before", - // weaveFuncTy); - auto &entry = f.getEntryBlock(); - IRBuilder<> builder(&entry); - Value *v1 = builder.CreateGlobalStringPtr(m.getName(), "str"); - Value *v2 = builder.CreateGlobalStringPtr(f.getName(), "str"); - Value *v3 = builder.CreateGlobalStringPtr(StringRef(scope), "str"); - Value *v4 = builder.CreateGlobalStringPtr(StringRef(flow), "str"); - Value *v5 = builder.CreateGlobalStringPtr(StringRef(pcut), "str"); - builder.SetInsertPoint(&entry, entry.begin()); - std::vector args; - args.push_back(ConstantInt::get(Type::getInt32Ty(context), async)); - args.push_back(v1); - args.push_back(v2); - args.push_back(v3); - args.push_back(v4); - args.push_back(v5); - builder.CreateCall(before, args); - - return true; -} - } // End namespace #endif // PERFFLOW_WEAVE_COMMON_H diff --git a/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp b/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp index 11d317b7..bdbe9256 100644 --- a/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp @@ -16,6 +16,7 @@ #include "perfflow_weave_common.hpp" using namespace llvm; +using namespace weave_ns; /****************************************************************************** * * diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index 0a604fc5..eb406820 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -20,6 +20,7 @@ #include using namespace llvm; +using namespace weave_ns; /****************************************************************************** * * From a473a7aa1c06610662bc4b0172c1e74902b3eba7 Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Tue, 24 Sep 2024 10:09:26 -0700 Subject: [PATCH 32/62] add more lassen host configs for newer clang versions --- ...ssen-4.14.0-ppc64le-clang@12.0.1-gcc@8.3.1.cmake | 13 +++++++++++++ ...ssen-4.14.0-ppc64le-clang@14.0.5-gcc@8.3.1.cmake | 4 ++-- ...sen-4.14.0-ppc64le-clang@16.0.6-gcc@11.2.1.cmake | 13 +++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-clang@12.0.1-gcc@8.3.1.cmake create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@11.2.1.cmake diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@12.0.1-gcc@8.3.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@12.0.1-gcc@8.3.1.cmake new file mode 100644 index 00000000..830affff --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@12.0.1-gcc@8.3.1.cmake @@ -0,0 +1,13 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-12.0.1-gcc-8.3.1/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-12.0.1-gcc-8.3.1/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-12.0.1-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@14.0.5-gcc@8.3.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@14.0.5-gcc@8.3.1.cmake index 34f1ff71..02aad36a 100644 --- a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@14.0.5-gcc@8.3.1.cmake +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@14.0.5-gcc@8.3.1.cmake @@ -16,5 +16,5 @@ set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-14.0.5-gcc-8.3.1/lib/cmake/llvm" # Use the -flegacy-pass-manager if you want to use the legacy pass. # Use -fpass-plugin= to use the new pass # Use both C and CXX flags to support both targets. -# set(CMAKE_C_FLAGS "-flegacy-pass-manager" CACHE STRING "") -# set(CMAKE_CXX_FLAGS "-flegacy-pass-manager" CACHE STRING "") +# set(CMAKE_C_FLAGS "-flegacy-pass-manager" CACHE STRING "") +# set(CMAKE_CXX_FLAGS "-flegacy-pass-manager" CACHE STRING "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@11.2.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@11.2.1.cmake new file mode 100644 index 00000000..92a0a3a8 --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@11.2.1.cmake @@ -0,0 +1,13 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-14.0.5-gcc-8.3.1/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-14.0.5-gcc-8.3.1/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-14.0.5-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") From 18f0e602d8d9e0306e1be413617a9c8dba475938 Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Thu, 26 Sep 2024 12:29:40 -0700 Subject: [PATCH 33/62] print operand names --- ...ssen-4.14.0-ppc64le-clang@16.0.6-gcc@11.2.1.cmake | 7 ++++--- src/c/weaver/weave/perfflow_weave_common.cpp | 12 ++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@11.2.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@11.2.1.cmake index 92a0a3a8..9cbf656d 100644 --- a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@11.2.1.cmake +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@11.2.1.cmake @@ -8,6 +8,7 @@ # SPDX-License-Identifier: LGPL-3.0 ############################################################## -set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-14.0.5-gcc-8.3.1/bin/clang" CACHE PATH "") -set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-14.0.5-gcc-8.3.1/bin/clang++" CACHE PATH "") -set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-14.0.5-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-16.0.6-gcc-11.2.1/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-16.0.6-gcc-11.2.1/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-gcc-11.2.1/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index 3fa70751..c469fe09 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -51,8 +51,16 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) else { outs() << "e has " << e->getNumOperands() << " operands.\n"; - outs() << "e's first operand has " << e->getOperand(0)->getNumOperands() << - " operands.\n"; + outs() << "e's 0 operand has " << e->getOperand(0)->getNumOperands() << "\n"; + outs() << "e's 1 operand has " << e->getOperand(1)->getNumOperands() << "\n"; + outs() << "e's 2 operand has " << e->getOperand(2)->getNumOperands() << "\n"; + outs() << "e's 3 operand has " << e->getOperand(3)->getNumOperands() << "\n"; + outs() << "e's 4 operand has " << e->getOperand(4)->getNumOperands() << "\n"; + outs() << "e's 0 operand name " << e->getOperand(0)->getName() << "\n"; + outs() << "e's 1 operand name " << e->getOperand(1)->getName() << "\n"; + outs() << "e's 2 operand name " << e->getOperand(2)->getName() << "\n"; + outs() << "e's 3 operand name " << e->getOperand(3)->getName() << "\n"; + outs() << "e's 4 operand name " << e->getOperand(4)->getName() << "\n"; } if (auto *fn = dyn_cast (e->getOperand(0)->getOperand(0))) From b422715ad082e5322ca3287174677901194624db Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 26 Sep 2024 12:42:32 -0700 Subject: [PATCH 34/62] Edit print --- src/c/weaver/weave/perfflow_weave_common.cpp | 26 ++++++++++++-------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index c469fe09..94996f08 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -51,16 +51,22 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) else { outs() << "e has " << e->getNumOperands() << " operands.\n"; - outs() << "e's 0 operand has " << e->getOperand(0)->getNumOperands() << "\n"; - outs() << "e's 1 operand has " << e->getOperand(1)->getNumOperands() << "\n"; - outs() << "e's 2 operand has " << e->getOperand(2)->getNumOperands() << "\n"; - outs() << "e's 3 operand has " << e->getOperand(3)->getNumOperands() << "\n"; - outs() << "e's 4 operand has " << e->getOperand(4)->getNumOperands() << "\n"; - outs() << "e's 0 operand name " << e->getOperand(0)->getName() << "\n"; - outs() << "e's 1 operand name " << e->getOperand(1)->getName() << "\n"; - outs() << "e's 2 operand name " << e->getOperand(2)->getName() << "\n"; - outs() << "e's 3 operand name " << e->getOperand(3)->getName() << "\n"; - outs() << "e's 4 operand name " << e->getOperand(4)->getName() << "\n"; + outs() << "Printing e's operands: \n"; + for (unsigned int k=0; k < e->getNumOperands(); k++) + { + outs() << " Operand " << i << " is " << e->getOperand(i)->getName(); + outs() << "Operand " << i << "has " << e->getOperand(i)->getNumOperands() << "operands \n"; + } + // outs() << "e's 0 operand has " << e->getOperand(0)->getNumOperands() << "\n"; + // outs() << "e's 1 operand has " << e->getOperand(1)->getNumOperands() << "\n"; + // outs() << "e's 2 operand has " << e->getOperand(2)->getNumOperands() << "\n"; + // outs() << "e's 3 operand has " << e->getOperand(3)->getNumOperands() << "\n"; + // outs() << "e's 4 operand has " << e->getOperand(4)->getNumOperands() << "\n"; + // outs() << "e's 0 operand name " << e->getOperand(0)->getName() << "\n"; + // outs() << "e's 1 operand name " << e->getOperand(1)->getName() << "\n"; + // outs() << "e's 2 operand name " << e->getOperand(2)->getName() << "\n"; + // outs() << "e's 3 operand name " << e->getOperand(3)->getName() << "\n"; + // outs() << "e's 4 operand name " << e->getOperand(4)->getName() << "\n"; } if (auto *fn = dyn_cast (e->getOperand(0)->getOperand(0))) From 6c5a230c4284b11eece8328dd091a11323484982 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 26 Sep 2024 12:58:02 -0700 Subject: [PATCH 35/62] Fix my stupid bug --- src/c/weaver/weave/perfflow_weave_common.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index 94996f08..f47046aa 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -37,7 +37,8 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) } else { - outs() << "I have " << annotations->getNumOperands() << " operands.\n"; + outs() << "Annotations has " << annotations->getNumOperands() << " operands.\n"; + outs() << "Annotations has " << annotations->getOperand(0)->getName << " name for operand 0.\n"; } auto a = cast (annotations->getOperand(0)); @@ -54,8 +55,8 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) outs() << "Printing e's operands: \n"; for (unsigned int k=0; k < e->getNumOperands(); k++) { - outs() << " Operand " << i << " is " << e->getOperand(i)->getName(); - outs() << "Operand " << i << "has " << e->getOperand(i)->getNumOperands() << "operands \n"; + outs() << " Operand " << k << " is " << e->getOperand(k)->getName(); + outs() << "Operand " << k << "has " << e->getOperand(k)->getNumOperands() << "operands \n"; } // outs() << "e's 0 operand has " << e->getOperand(0)->getNumOperands() << "\n"; // outs() << "e's 1 operand has " << e->getOperand(1)->getNumOperands() << "\n"; From 57e7a821dca360f7290820b4ee1f1c6f6651dacb Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 26 Sep 2024 12:59:00 -0700 Subject: [PATCH 36/62] Fix my stupid bug --- src/c/weaver/weave/perfflow_weave_common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index f47046aa..53c04d23 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -38,7 +38,7 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) else { outs() << "Annotations has " << annotations->getNumOperands() << " operands.\n"; - outs() << "Annotations has " << annotations->getOperand(0)->getName << " name for operand 0.\n"; + outs() << "Annotations has " << annotations->getOperand(0)->getName() << " name for operand 0.\n"; } auto a = cast (annotations->getOperand(0)); From 56897e1d44cd78d65bf9446b21ce436da909cf6e Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 26 Sep 2024 13:01:23 -0700 Subject: [PATCH 37/62] Format prints --- src/c/weaver/weave/perfflow_weave_common.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index 53c04d23..89ec8e2a 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -38,7 +38,7 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) else { outs() << "Annotations has " << annotations->getNumOperands() << " operands.\n"; - outs() << "Annotations has " << annotations->getOperand(0)->getName() << " name for operand 0.\n"; + outs() << "Annotations operand 0 has name " << annotations->getOperand(0)->getName().getAsCString() << "\n"; } auto a = cast (annotations->getOperand(0)); @@ -55,7 +55,7 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) outs() << "Printing e's operands: \n"; for (unsigned int k=0; k < e->getNumOperands(); k++) { - outs() << " Operand " << k << " is " << e->getOperand(k)->getName(); + outs() << " Operand " << k << " name is " << e->getOperand(k)->getName() << "\n"; outs() << "Operand " << k << "has " << e->getOperand(k)->getNumOperands() << "operands \n"; } // outs() << "e's 0 operand has " << e->getOperand(0)->getNumOperands() << "\n"; From cba5b58316204b5c4e66feb5038915044c7c601f Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 26 Sep 2024 13:02:37 -0700 Subject: [PATCH 38/62] CString didn't work. try later --- src/c/weaver/weave/perfflow_weave_common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index 89ec8e2a..c70290cc 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -38,7 +38,7 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) else { outs() << "Annotations has " << annotations->getNumOperands() << " operands.\n"; - outs() << "Annotations operand 0 has name " << annotations->getOperand(0)->getName().getAsCString() << "\n"; + outs() << "Annotations operand 0 has name " << annotations->getOperand(0)->getName() << "\n"; } auto a = cast (annotations->getOperand(0)); From c07d36aabb793089fecff8140347889e522a9e95 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 26 Sep 2024 13:03:59 -0700 Subject: [PATCH 39/62] print formatting --- src/c/weaver/weave/perfflow_weave_common.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index c70290cc..a3b8a95c 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -38,7 +38,7 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) else { outs() << "Annotations has " << annotations->getNumOperands() << " operands.\n"; - outs() << "Annotations operand 0 has name " << annotations->getOperand(0)->getName() << "\n"; + outs() << "Annotations operand 0 has name: " << annotations->getOperand(0)->getName() << "\n"; } auto a = cast (annotations->getOperand(0)); @@ -56,7 +56,7 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) for (unsigned int k=0; k < e->getNumOperands(); k++) { outs() << " Operand " << k << " name is " << e->getOperand(k)->getName() << "\n"; - outs() << "Operand " << k << "has " << e->getOperand(k)->getNumOperands() << "operands \n"; + outs() << "Operand " << k << " has " << e->getOperand(k)->getNumOperands() << " operands \n"; } // outs() << "e's 0 operand has " << e->getOperand(0)->getNumOperands() << "\n"; // outs() << "e's 1 operand has " << e->getOperand(1)->getNumOperands() << "\n"; From e07fdb6c7ae0ea5f9e85347b35daf34c57dfba0c Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 26 Sep 2024 15:15:42 -0700 Subject: [PATCH 40/62] Test one level up with Clang 16. We can switch based on Clang version if that works. --- src/c/weaver/weave/perfflow_weave_common.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index a3b8a95c..60caae65 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -55,7 +55,7 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) outs() << "Printing e's operands: \n"; for (unsigned int k=0; k < e->getNumOperands(); k++) { - outs() << " Operand " << k << " name is " << e->getOperand(k)->getName() << "\n"; + outs() << " Operand " << k << " name is: " << e->getOperand(k)->getName() << "\n"; outs() << "Operand " << k << " has " << e->getOperand(k)->getNumOperands() << " operands \n"; } // outs() << "e's 0 operand has " << e->getOperand(0)->getNumOperands() << "\n"; @@ -70,11 +70,13 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) // outs() << "e's 4 operand name " << e->getOperand(4)->getName() << "\n"; } - if (auto *fn = dyn_cast (e->getOperand(0)->getOperand(0))) + // if (auto *fn = dyn_cast (e->getOperand(0)->getOperand(0))) + if (auto *fn = dyn_cast (e->getOperand(0))) { outs() << "I entered the part where we parse annotations. \n"; auto anno = cast( - cast(e->getOperand(1)->getOperand(0)) + // cast(e->getOperand(1)->getOperand(0)) + cast(e->getOperand(1)) ->getOperand(0)) ->getAsCString(); std::string pcut, scope, flow; From d36ffa7be5dff45f45fa234343f4567b68aa4382 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Thu, 26 Sep 2024 18:02:59 -0700 Subject: [PATCH 41/62] Hostfile for Lassen that works with CUDA. --- ...c64le-clang@16.0.6-cuda-11.8.0-gcc@11.2.1.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda-11.8.0-gcc@11.2.1.cmake diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda-11.8.0-gcc@11.2.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda-11.8.0-gcc@11.2.1.cmake new file mode 100644 index 00000000..5dc4b872 --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda-11.8.0-gcc@11.2.1.cmake @@ -0,0 +1,14 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-11.8.0-gcc-11.2.1/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-11.8.0-gcc-11.2.1/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-11.8.0-gcc-11.2.1/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") From 57375eb41a5b9907c5e25fa285151a6c2b8911a9 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Sat, 28 Sep 2024 14:08:20 -0700 Subject: [PATCH 42/62] Split between >clang15 and =clang14") - add_definitions(-DPERFFLOWASPECT_CLANG_14_NEWER) - elseif ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)) + elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 15) + set(PERFFLOWASPECT_CLANG_15_NEWER TRUE CACHE BOOL "using >=clang15") + add_definitions(-DPERFFLOWASPECT_CLANG_15_NEWER) + elseif ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15)) set(PERFFLOWASPECT_CLANG_11_NEWER TRUE CACHE BOOL "using >=clang11") - set(PERFFLOWASPECT_CLANG_14_NEWER FALSE CACHE BOOL "using < clang14") + set(PERFFLOWASPECT_CLANG_15_NEWER FALSE CACHE BOOL "using < clang15") add_definitions(-DPERFFLOWASPECT_CLANG_11_NEWER) elseif (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11) set(PERFFLOWASPECT_CLANG_11_NEWER FALSE CACHE BOOL "using < clang11") diff --git a/src/c/weaver/CMakeLists.txt b/src/c/weaver/CMakeLists.txt index f04f215f..5959de48 100644 --- a/src/c/weaver/CMakeLists.txt +++ b/src/c/weaver/CMakeLists.txt @@ -1,5 +1,5 @@ # support C++14 features used by LLVM 10.0.0 -set(CMAKE_CXX_STANDARD 14) +# set(CMAKE_CXX_STANDARD 14) if(LLVM_FOUND) add_definitions(${LLVM_DEFINITIONS}) diff --git a/src/c/weaver/weave/CMakeLists.txt b/src/c/weaver/weave/CMakeLists.txt index f1726c5c..da21c22d 100644 --- a/src/c/weaver/weave/CMakeLists.txt +++ b/src/c/weaver/weave/CMakeLists.txt @@ -1,4 +1,4 @@ -if (PERFFLOWASPECT_CLANG_14_NEWER) +if (PERFFLOWASPECT_CLANG_15_NEWER) # Add the new pass add_library(WeavePass MODULE # List your source files here. @@ -6,7 +6,7 @@ if (PERFFLOWASPECT_CLANG_14_NEWER) perfflow_weave_new_pass.cpp ) else() - # Add the legacy pass if we have Clang < 14. + # Add the legacy pass if we have Clang < 15. add_library(WeavePass MODULE # List your source files here. perfflow_weave_common.cpp @@ -14,7 +14,7 @@ else() ) endif() -if (PERFFLOWASPECT_CLANG_14_NEWER) +if (PERFFLOWASPECT_CLANG_15_NEWER) # Use C++17 to compile our pass target_compile_features(WeavePass PRIVATE cxx_std_17 cxx_range_for cxx_auto_type) else() diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index 60caae65..eaaac29b 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -58,27 +58,27 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) outs() << " Operand " << k << " name is: " << e->getOperand(k)->getName() << "\n"; outs() << "Operand " << k << " has " << e->getOperand(k)->getNumOperands() << " operands \n"; } - // outs() << "e's 0 operand has " << e->getOperand(0)->getNumOperands() << "\n"; - // outs() << "e's 1 operand has " << e->getOperand(1)->getNumOperands() << "\n"; - // outs() << "e's 2 operand has " << e->getOperand(2)->getNumOperands() << "\n"; - // outs() << "e's 3 operand has " << e->getOperand(3)->getNumOperands() << "\n"; - // outs() << "e's 4 operand has " << e->getOperand(4)->getNumOperands() << "\n"; - // outs() << "e's 0 operand name " << e->getOperand(0)->getName() << "\n"; - // outs() << "e's 1 operand name " << e->getOperand(1)->getName() << "\n"; - // outs() << "e's 2 operand name " << e->getOperand(2)->getName() << "\n"; - // outs() << "e's 3 operand name " << e->getOperand(3)->getName() << "\n"; - // outs() << "e's 4 operand name " << e->getOperand(4)->getName() << "\n"; } - - // if (auto *fn = dyn_cast (e->getOperand(0)->getOperand(0))) - if (auto *fn = dyn_cast (e->getOperand(0))) +#if defined(PERFFLOWASPECT_CLANG_15_NEWER) + auto *fn = dyn_cast (e->getOperand(0)); +#else + auto *fn = dyn_cast (e->getOperand(0)->getOperand(0)); +#endif + if (fn != NULL) { outs() << "I entered the part where we parse annotations. \n"; +#if defined(PERFFLOWASPECT_CLANG_15_NEWER) auto anno = cast( - // cast(e->getOperand(1)->getOperand(0)) cast(e->getOperand(1)) ->getOperand(0)) ->getAsCString(); +#else + auto anno = cast( + cast(e->getOperand(1)->getOperand(0)) + ->getOperand(0)) + ->getAsCString(); +#endif + std::string pcut, scope, flow; if (perfflow_parser_parse(anno.data(), pcut, scope, flow) == 0) { From 6a3afd74bc4ea83d8cc4592596a3efc9a38f7cae Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Sat, 28 Sep 2024 14:15:48 -0700 Subject: [PATCH 43/62] Formatting pass --- src/c/weaver/weave/perfflow_weave_common.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index eaaac29b..0c8e28ad 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -38,7 +38,8 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) else { outs() << "Annotations has " << annotations->getNumOperands() << " operands.\n"; - outs() << "Annotations operand 0 has name: " << annotations->getOperand(0)->getName() << "\n"; + outs() << "Annotations operand 0 has name: " << annotations->getOperand( + 0)->getName() << "\n"; } auto a = cast (annotations->getOperand(0)); @@ -53,10 +54,12 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) { outs() << "e has " << e->getNumOperands() << " operands.\n"; outs() << "Printing e's operands: \n"; - for (unsigned int k=0; k < e->getNumOperands(); k++) - { - outs() << " Operand " << k << " name is: " << e->getOperand(k)->getName() << "\n"; - outs() << "Operand " << k << " has " << e->getOperand(k)->getNumOperands() << " operands \n"; + for (unsigned int k = 0; k < e->getNumOperands(); k++) + { + outs() << " Operand " << k << " name is: " << e->getOperand( + k)->getName() << "\n"; + outs() << "Operand " << k << " has " << e->getOperand(k)->getNumOperands() << + " operands \n"; } } #if defined(PERFFLOWASPECT_CLANG_15_NEWER) @@ -64,7 +67,7 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) #else auto *fn = dyn_cast (e->getOperand(0)->getOperand(0)); #endif - if (fn != NULL) + if (fn != NULL) { outs() << "I entered the part where we parse annotations. \n"; #if defined(PERFFLOWASPECT_CLANG_15_NEWER) @@ -78,7 +81,7 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) ->getOperand(0)) ->getAsCString(); #endif - + std::string pcut, scope, flow; if (perfflow_parser_parse(anno.data(), pcut, scope, flow) == 0) { From cef5f633785574498a96fbfbeef004636d027ec0 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Sat, 28 Sep 2024 14:23:13 -0700 Subject: [PATCH 44/62] Caught a bug --- src/c/weaver/weave/perfflow_weave_legacy_pass.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp b/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp index 8ce6a41c..4d3711b3 100644 --- a/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp +++ b/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp @@ -25,7 +25,7 @@ class LegacyWeavingPass : public FunctionPass { public: static char ID; - WeavingPass () : FunctionPass (ID) {} + LegacyWeavingPass () : FunctionPass (ID) {} virtual bool doInitialization (Module &m); virtual bool runOnFunction (Function &F); }; From da31b6af8a737ec93a285fd6d4d12ccb068a8212 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Sat, 28 Sep 2024 15:13:16 -0700 Subject: [PATCH 45/62] Several build fixes --- .../lassen-4.14.0-ppc64le-clang@14.0.5-gcc@8.3.1.cmake | 4 ++-- src/c/test/CMakeLists.txt | 8 ++++---- src/c/weaver/weave/CMakeLists.txt | 8 ++++---- src/c/weaver/weave/perfflow_weave_common.hpp | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@14.0.5-gcc@8.3.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@14.0.5-gcc@8.3.1.cmake index 02aad36a..54a8396b 100644 --- a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@14.0.5-gcc@8.3.1.cmake +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@14.0.5-gcc@8.3.1.cmake @@ -16,5 +16,5 @@ set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-14.0.5-gcc-8.3.1/lib/cmake/llvm" # Use the -flegacy-pass-manager if you want to use the legacy pass. # Use -fpass-plugin= to use the new pass # Use both C and CXX flags to support both targets. -# set(CMAKE_C_FLAGS "-flegacy-pass-manager" CACHE STRING "") -# set(CMAKE_CXX_FLAGS "-flegacy-pass-manager" CACHE STRING "") + set(CMAKE_C_FLAGS "-flegacy-pass-manager" CACHE STRING "") + set(CMAKE_CXX_FLAGS "-flegacy-pass-manager" CACHE STRING "") diff --git a/src/c/test/CMakeLists.txt b/src/c/test/CMakeLists.txt index 6dad01a7..e2c43858 100644 --- a/src/c/test/CMakeLists.txt +++ b/src/c/test/CMakeLists.txt @@ -11,7 +11,7 @@ message(STATUS "Adding CXX unit tests") foreach(TEST ${SMOKETESTS}) message(STATUS " [*] Adding test: ${TEST}") add_executable(${TEST} ${TEST}.cpp) - if (PERFFLOWASPECT_CLANG_14_NEWER) + if (PERFFLOWASPECT_CLANG_15_NEWER) set_source_files_properties(${TEST}.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fpass-plugin=../weaver/weave/libWeavePass.so -fPIC") else() set_source_files_properties(${TEST}.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fPIC") @@ -37,7 +37,7 @@ endif() if(PERFFLOWASPECT_WITH_MULTITHREADS) message(STATUS " [*] Adding test: smoketest_MT") add_executable(smoketest_MT smoketest_MT.cpp) - if (PERFFLOWASPECT_CLANG_14_NEWER) + if (PERFFLOWASPECT_CLANG_15_NEWER) set_source_files_properties(smoketest_MT.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fpass-plugin=../weaver/weave/libWeavePass.so -fPIC") else() set_source_files_properties(smoketest_MT.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fPIC") @@ -49,7 +49,7 @@ endif() if(PERFFLOWASPECT_WITH_MPI) message(STATUS " [*] Adding test: smoketest_MPI") add_executable(smoketest_MPI smoketest_MPI.cpp) - if (PERFFLOWASPECT_CLANG_14_NEWER) + if (PERFFLOWASPECT_CLANG_15_NEWER) set_source_files_properties(smoketest_MPI.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fpass-plugin=../weaver/weave/libWeavePass.so -fPIC") else() set_source_files_properties(smoketest_MPI.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fPIC") @@ -60,7 +60,7 @@ endif() if(PERFFLOWASPECT_WITH_CUDA) message(STATUS " [*] Adding test: smoketest_cuda") - if (PERFFLOWASPECT_CLANG_14_NEWER) + if (PERFFLOWASPECT_CLANG_15_NEWER) set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} -Xcompiler=-Xclang -Xcompiler=-load -Xcompiler=-Xclang -Xcompiler=../../../weaver/weave/libWeavePass.so -Xcompiler=-fpass-plugin=../../../weaver/weave/libWeavePass.so") else() set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} -Xcompiler=-Xclang -Xcompiler=-load -Xcompiler=-Xclang -Xcompiler=../../../weaver/weave/libWeavePass.so") diff --git a/src/c/weaver/weave/CMakeLists.txt b/src/c/weaver/weave/CMakeLists.txt index da21c22d..a8e7fbc1 100644 --- a/src/c/weaver/weave/CMakeLists.txt +++ b/src/c/weaver/weave/CMakeLists.txt @@ -19,15 +19,15 @@ if (PERFFLOWASPECT_CLANG_15_NEWER) target_compile_features(WeavePass PRIVATE cxx_std_17 cxx_range_for cxx_auto_type) else() # Use C++11/C++14 to compile our pass (i.e., supply -std=c++11) (pick default) - target_compile_features(WeavePass PRIVATE cxx_range_for cxx_auto_type) + target_compile_features(WeavePass PRIVATE cxx_std_14 cxx_range_for cxx_auto_type) endif() # LLVM is (typically) built with no C++ RTTI. We need to match that; # otherwise, we'll get linker errors about missing RTTI data. -set_target_properties(WeavePass PROPERTIES - COMPILE_FLAGS "-fno-rtti" -) + set_target_properties(WeavePass PROPERTIES + COMPILE_FLAGS "-fno-rtti -stdlib=libstdc++" + ) target_link_libraries(WeavePass perfflow_parser ${JANSSON_LIB}) diff --git a/src/c/weaver/weave/perfflow_weave_common.hpp b/src/c/weaver/weave/perfflow_weave_common.hpp index 13c641ea..62bd2352 100644 --- a/src/c/weaver/weave/perfflow_weave_common.hpp +++ b/src/c/weaver/weave/perfflow_weave_common.hpp @@ -15,7 +15,7 @@ #include "llvm/IR/Attributes.h" #include "llvm/IR/Constants.h" #include "llvm/IR/LegacyPassManager.h" -#if defined(PERFFLOWASPECT_CLANG_11_NEWER) || defined(PERFFLOWASPECT_CLANG_14_NEWER) +#if defined(PERFFLOWASPECT_CLANG_11_NEWER) || defined(PERFFLOWASPECT_CLANG_15_NEWER) #include "llvm/IR/AbstractCallSite.h" #else #include "llvm/IR/CallSite.h" From 17f44834fcb43e54cf68cea55950508d21f9d926 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Sat, 28 Sep 2024 15:24:53 -0700 Subject: [PATCH 46/62] The clang 15 and 17 files DO NOT WORK on Lassen. Need to find the right flags --- .../lassen-4.14.0-ppc64le-clang@15.0.6.cmake | 14 ++++++++++++++ .../lassen-4.14.0-ppc64le-clang@17.0.6.cmake | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-clang@15.0.6.cmake create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-clang@17.0.6.cmake diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@15.0.6.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@15.0.6.cmake new file mode 100644 index 00000000..f0411f7e --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@15.0.6.cmake @@ -0,0 +1,14 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-ibm-15.0.6/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-ibm-15.0.6/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-15.0.6/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@17.0.6.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@17.0.6.cmake new file mode 100644 index 00000000..70bd5b60 --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@17.0.6.cmake @@ -0,0 +1,14 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-ibm-17.0.6/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-ibm-17.0.6/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-17.0.6/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") From 3b968b5d9215bb9420988f80ae1711c8da82d2a1 Mon Sep 17 00:00:00 2001 From: Tapasya Patki Date: Sun, 29 Sep 2024 14:05:49 -0700 Subject: [PATCH 47/62] Add corona hostfile that works correctly --- .../corona-4.18.0-x86_64-clang@14.0.6.cmake | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/c/host-configs/corona-4.18.0-x86_64-clang@14.0.6.cmake diff --git a/src/c/host-configs/corona-4.18.0-x86_64-clang@14.0.6.cmake b/src/c/host-configs/corona-4.18.0-x86_64-clang@14.0.6.cmake new file mode 100644 index 00000000..13b7751c --- /dev/null +++ b/src/c/host-configs/corona-4.18.0-x86_64-clang@14.0.6.cmake @@ -0,0 +1,21 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-14.0.6/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-14.0.6/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-14.0.6/lib/cmake/llvm" CACHE PATH "") + +# Clang 14 supports both legacy and new pass manager. +# Use the -flegacy-pass-manager if you want to use the legacy pass. +# Use -fpass-plugin= to use the new pass +# Use both C and CXX flags to support both targets. + set(CMAKE_C_FLAGS "-flegacy-pass-manager" CACHE STRING "") + set(CMAKE_CXX_FLAGS "-flegacy-pass-manager" CACHE STRING "") + set(PERFFLOWASPECT_WITH_CUDA "OFF" CACHE STRING "") From 6a215ceffde3d184d13ce35c6fd742c121b9b273 Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Tue, 1 Oct 2024 09:48:23 -0700 Subject: [PATCH 48/62] update/add lassen host configs for clang 16.0.6, cuda, gcc modules --- ...64le-clang@16.0.6-cuda@10.1.243-gcc@4.9.3.cmake | 14 ++++++++++++++ ...64le-clang@16.0.6-cuda@10.1.243-gcc@8.3.1.cmake | 14 ++++++++++++++ ...pc64le-clang@16.0.6-cuda@11.2.0-gcc@8.3.1.cmake | 14 ++++++++++++++ ...64le-clang@16.0.6-cuda@11.8.0-gcc@11.2.1.cmake} | 0 ...pc64le-clang@16.0.6-cuda@11.8.0-gcc@8.3.1.cmake | 14 ++++++++++++++ 5 files changed, 56 insertions(+) create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@4.9.3.cmake create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@8.3.1.cmake create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.2.0-gcc@8.3.1.cmake rename src/c/host-configs/{lassen-4.14.0-ppc64le-clang@16.0.6-cuda-11.8.0-gcc@11.2.1.cmake => lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@11.2.1.cmake} (100%) create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@8.3.1.cmake diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@4.9.3.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@4.9.3.cmake new file mode 100644 index 00000000..8685ee5d --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@4.9.3.cmake @@ -0,0 +1,14 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-10.1.243-gcc-4.9.3/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-10.1.243-gcc-4.9.3/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-10.1.243-gcc-4.9.3/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@8.3.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@8.3.1.cmake new file mode 100644 index 00000000..0369f358 --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@8.3.1.cmake @@ -0,0 +1,14 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-10.1.243-gcc-8.3.1/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-10.1.243-gcc-8.3.1/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-10.1.243-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.2.0-gcc@8.3.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.2.0-gcc@8.3.1.cmake new file mode 100644 index 00000000..0ce61ac4 --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.2.0-gcc@8.3.1.cmake @@ -0,0 +1,14 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-11.2.0-gcc-8.3.1/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-11.2.0-gcc-8.3.1/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-11.2.0-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda-11.8.0-gcc@11.2.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@11.2.1.cmake similarity index 100% rename from src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda-11.8.0-gcc@11.2.1.cmake rename to src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@11.2.1.cmake diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@8.3.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@8.3.1.cmake new file mode 100644 index 00000000..2b510274 --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@8.3.1.cmake @@ -0,0 +1,14 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-11.8.0-gcc-8.3.1/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-11.8.0-gcc-8.3.1/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-11.8.0-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") From 6f8296f4d313ee7966010cac10582e323652e89c Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Tue, 1 Oct 2024 10:14:05 -0700 Subject: [PATCH 49/62] add new lassen clang16 gcc8 host file, fix LLVM path --- ...n-4.14.0-ppc64le-clang@16.0.6-gcc@11.2.1.cmake | 3 ++- ...en-4.14.0-ppc64le-clang@16.0.6-gcc@8.3.1.cmake | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@8.3.1.cmake diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@11.2.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@11.2.1.cmake index 9cbf656d..6cd445cd 100644 --- a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@11.2.1.cmake +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@11.2.1.cmake @@ -10,5 +10,6 @@ set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-16.0.6-gcc-11.2.1/bin/clang" CACHE PATH "") set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-16.0.6-gcc-11.2.1/bin/clang++" CACHE PATH "") -set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-gcc-11.2.1/lib/cmake/llvm" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-16.0.6-gcc-11.2.1/lib/cmake/llvm" CACHE PATH "") set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") +set(PERFFLOWASPECT_WITH_CUDA "OFF" CACHE BOOL "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@8.3.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@8.3.1.cmake new file mode 100644 index 00000000..c14bdd9f --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-gcc@8.3.1.cmake @@ -0,0 +1,15 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-16.0.6-gcc-8.3.1/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-16.0.6-gcc-8.3.1/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-16.0.6-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") +set(PERFFLOWASPECT_WITH_CUDA "OFF" CACHE BOOL "") From ceb0ee810947c85373c67d483650033bc9a953f6 Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Tue, 1 Oct 2024 10:19:15 -0700 Subject: [PATCH 50/62] update LLVM dir in same top location for clang compiler --- ...en-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@4.9.3.cmake | 2 +- ...en-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@8.3.1.cmake | 2 +- ...ssen-4.14.0-ppc64le-clang@16.0.6-cuda@11.2.0-gcc@8.3.1.cmake | 2 +- ...sen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@11.2.1.cmake | 2 +- ...ssen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@8.3.1.cmake | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@4.9.3.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@4.9.3.cmake index 8685ee5d..11d3346f 100644 --- a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@4.9.3.cmake +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@4.9.3.cmake @@ -10,5 +10,5 @@ set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-10.1.243-gcc-4.9.3/bin/clang" CACHE PATH "") set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-10.1.243-gcc-4.9.3/bin/clang++" CACHE PATH "") -set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-10.1.243-gcc-4.9.3/lib/cmake/llvm" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-16.0.6-cuda-10.1.243-gcc-4.9.3/lib/cmake/llvm" CACHE PATH "") set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@8.3.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@8.3.1.cmake index 0369f358..9b43caa6 100644 --- a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@8.3.1.cmake +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@10.1.243-gcc@8.3.1.cmake @@ -10,5 +10,5 @@ set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-10.1.243-gcc-8.3.1/bin/clang" CACHE PATH "") set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-10.1.243-gcc-8.3.1/bin/clang++" CACHE PATH "") -set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-10.1.243-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-16.0.6-cuda-10.1.243-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.2.0-gcc@8.3.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.2.0-gcc@8.3.1.cmake index 0ce61ac4..fbc5782d 100644 --- a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.2.0-gcc@8.3.1.cmake +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.2.0-gcc@8.3.1.cmake @@ -10,5 +10,5 @@ set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-11.2.0-gcc-8.3.1/bin/clang" CACHE PATH "") set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-11.2.0-gcc-8.3.1/bin/clang++" CACHE PATH "") -set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-11.2.0-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-16.0.6-cuda-11.2.0-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@11.2.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@11.2.1.cmake index 5dc4b872..3193abf2 100644 --- a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@11.2.1.cmake +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@11.2.1.cmake @@ -10,5 +10,5 @@ set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-11.8.0-gcc-11.2.1/bin/clang" CACHE PATH "") set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-11.8.0-gcc-11.2.1/bin/clang++" CACHE PATH "") -set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-11.8.0-gcc-11.2.1/lib/cmake/llvm" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-16.0.6-cuda-11.8.0-gcc-11.2.1/lib/cmake/llvm" CACHE PATH "") set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@8.3.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@8.3.1.cmake index 2b510274..6a64d63e 100644 --- a/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@8.3.1.cmake +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-clang@16.0.6-cuda@11.8.0-gcc@8.3.1.cmake @@ -10,5 +10,5 @@ set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-11.8.0-gcc-8.3.1/bin/clang" CACHE PATH "") set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-16.0.6-cuda-11.8.0-gcc-8.3.1/bin/clang++" CACHE PATH "") -set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-11.8.0-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-16.0.6-cuda-11.8.0-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") From 1ee82b2c009040585b129285e1067c447d453201 Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Tue, 1 Oct 2024 10:33:20 -0700 Subject: [PATCH 51/62] add lassen host configs for clang/ibm modules --- ...-ibm-clang@16.0.6-cuda@10.1.243-gcc@4.9.3.cmake | 14 ++++++++++++++ ...-ibm-clang@16.0.6-cuda@10.1.243-gcc@8.3.1.cmake | 14 ++++++++++++++ ...-ppc64le-ibm-clang@16.0.6-cuda@11.2.0-gcc@8.3.1 | 14 ++++++++++++++ ...ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@11.2.1 | 14 ++++++++++++++ ...-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@8.3.1 | 14 ++++++++++++++ 5 files changed, 70 insertions(+) create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@10.1.243-gcc@4.9.3.cmake create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@10.1.243-gcc@8.3.1.cmake create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.2.0-gcc@8.3.1 create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@11.2.1 create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@8.3.1 diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@10.1.243-gcc@4.9.3.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@10.1.243-gcc@4.9.3.cmake new file mode 100644 index 00000000..58ecdc3f --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@10.1.243-gcc@4.9.3.cmake @@ -0,0 +1,14 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-10.1.243-gcc-4.9.3/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-10.1.243-gcc-4.9.3/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-10.1.243-gcc-4.9.3/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@10.1.243-gcc@8.3.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@10.1.243-gcc@8.3.1.cmake new file mode 100644 index 00000000..c5d70bcd --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@10.1.243-gcc@8.3.1.cmake @@ -0,0 +1,14 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-10.1.243-gcc-8.3.1/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-10.1.243-gcc-8.3.1/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-10.1.243-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.2.0-gcc@8.3.1 b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.2.0-gcc@8.3.1 new file mode 100644 index 00000000..88d881f5 --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.2.0-gcc@8.3.1 @@ -0,0 +1,14 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-11.2.0-gcc-8.3.1/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-11.2.0-gcc-8.3.1/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-11.2.0-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@11.2.1 b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@11.2.1 new file mode 100644 index 00000000..ab626a5d --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@11.2.1 @@ -0,0 +1,14 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-11.8.0-gcc-8.3.1/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-11.8.0-gcc-8.3.1/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-11.8.0-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@8.3.1 b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@8.3.1 new file mode 100644 index 00000000..14dbaa1a --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@8.3.1 @@ -0,0 +1,14 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-11.8.0-gcc-11.2.1/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-11.8.0-gcc-11.2.1/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-cuda-11.8.0-gcc-11.2.1/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") From 887863975fd24346110dd9e6d5d23ffcf8ee122a Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Tue, 1 Oct 2024 15:22:39 -0700 Subject: [PATCH 52/62] add lassen clang ibm gcc host configs --- ...14.0-ppc64le-ibm-clang@16.0.6-gcc@11.2.1.cmake | 15 +++++++++++++++ ....14.0-ppc64le-ibm-clang@16.0.6-gcc@8.3.1.cmake | 15 +++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-gcc@11.2.1.cmake create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-gcc@8.3.1.cmake diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-gcc@11.2.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-gcc@11.2.1.cmake new file mode 100644 index 00000000..3ba0f365 --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-gcc@11.2.1.cmake @@ -0,0 +1,15 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6-gcc-11.2.1/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6-gcc-11.2.1/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-gcc-11.2.1/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") +set(PERFFLOWASPECT_WITH_CUDA "OFF" CACHE BOOL "") diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-gcc@8.3.1.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-gcc@8.3.1.cmake new file mode 100644 index 00000000..6ca40158 --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-gcc@8.3.1.cmake @@ -0,0 +1,15 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6-gcc-8.3.1/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6-gcc-8.3.1/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6-gcc-8.3.1/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") +set(PERFFLOWASPECT_WITH_CUDA "OFF" CACHE BOOL "") From 63c2a88f312b4dbe95ed9cde17bbf0609e3e9e09 Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Tue, 1 Oct 2024 15:29:41 -0700 Subject: [PATCH 53/62] add lassen clang16 host config --- .../lassen-4.14.0-ppc64le-ibm-clang@16.0.6.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6.cmake diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6.cmake b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6.cmake new file mode 100644 index 00000000..8887c29c --- /dev/null +++ b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6.cmake @@ -0,0 +1,15 @@ +############################################################## +# Copyright 2021 Lawrence Livermore National Security, LLC +# (c.f. AUTHORS, NOTICE.LLNS, COPYING) +# +# This file is part of the Flux resource manager framework. +# For details, see https://github.com/flux-framework. +# +# SPDX-License-Identifier: LGPL-3.0 +############################################################## + +set(CMAKE_C_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6/bin/clang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/usr/tce/packages/clang/clang-ibm-16.0.6/bin/clang++" CACHE PATH "") +set(LLVM_DIR "/usr/tce/packages/clang/clang-ibm-16.0.6/lib/cmake/llvm" CACHE PATH "") +set(FLEX_EXECUTABLE "/usr/tcetmp/packages/flex/flex-2.6.4/bin/flex" CACHE PATH "") +set(PERFFLOWASPECT_WITH_CUDA "OFF" CACHE PATH "") From b71a3a17ac5904f1fd5750b911aaa2d2ef3e7e7d Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Tue, 1 Oct 2024 17:57:32 -0700 Subject: [PATCH 54/62] add missing cmake file extension --- ...n-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.2.0-gcc@8.3.1.cmake} | 0 ...-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@11.2.1.cmake} | 0 ...n-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@8.3.1.cmake} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename src/c/host-configs/{lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.2.0-gcc@8.3.1 => lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.2.0-gcc@8.3.1.cmake} (100%) rename src/c/host-configs/{lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@11.2.1 => lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@11.2.1.cmake} (100%) rename src/c/host-configs/{lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@8.3.1 => lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@8.3.1.cmake} (100%) diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.2.0-gcc@8.3.1 b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.2.0-gcc@8.3.1.cmake similarity index 100% rename from src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.2.0-gcc@8.3.1 rename to src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.2.0-gcc@8.3.1.cmake diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@11.2.1 b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@11.2.1.cmake similarity index 100% rename from src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@11.2.1 rename to src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@11.2.1.cmake diff --git a/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@8.3.1 b/src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@8.3.1.cmake similarity index 100% rename from src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@8.3.1 rename to src/c/host-configs/lassen-4.14.0-ppc64le-ibm-clang@16.0.6-cuda@11.8.0-gcc@8.3.1.cmake From cf9d383e4598b5b2c2917848ad5d8c74251c26d6 Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Tue, 1 Oct 2024 17:53:01 -0700 Subject: [PATCH 55/62] add missing if checks does not include PassManagerBuilder.h header that was removed in clang17 --- src/c/weaver/weave/perfflow_weave_common.hpp | 4 +++- src/c/weaver/weave/perfflow_weave_new_pass.cpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/c/weaver/weave/perfflow_weave_common.hpp b/src/c/weaver/weave/perfflow_weave_common.hpp index 62bd2352..7bac68de 100644 --- a/src/c/weaver/weave/perfflow_weave_common.hpp +++ b/src/c/weaver/weave/perfflow_weave_common.hpp @@ -23,7 +23,9 @@ #include "llvm/IR/Module.h" #include "llvm/IR/Argument.h" #include "llvm/IR/IRBuilder.h" -#include "llvm/Transforms/IPO/PassManagerBuilder.h" +#if !defined(PERFFLOWASPECT_CLANG_15_NEWER) +#include "llvm/Transforms/IPO/PassManagerBuilder.h" // legacy optimization pipeline in this header removed as of Clang17 +#endif #include "llvm/Support/raw_ostream.h" #include "../../parser/perfflow_parser.hpp" diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index eb406820..2c9f173c 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -11,7 +11,9 @@ #include "llvm/IR/PassManager.h" #include "llvm/Passes/PassBuilder.h" #include "llvm/Passes/PassPlugin.h" +#if !defined(PERFFLOWASPECT_CLANG_15_NEWER) #include "llvm/Transforms/IPO/PassManagerBuilder.h" +#endif #include "llvm/Support/raw_ostream.h" #include "perfflow_weave_new_pass.hpp" From ab302aafe635a92d65c571d4942721fb1c4b8853 Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Tue, 1 Oct 2024 17:57:59 -0700 Subject: [PATCH 56/62] add clang17 tioga host config --- .../tioga-4.18.0-x86_64-rocm@6.1.2-amdclang@17.0.0.cmake | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/c/host-configs/tioga-4.18.0-x86_64-rocm@6.1.2-amdclang@17.0.0.cmake diff --git a/src/c/host-configs/tioga-4.18.0-x86_64-rocm@6.1.2-amdclang@17.0.0.cmake b/src/c/host-configs/tioga-4.18.0-x86_64-rocm@6.1.2-amdclang@17.0.0.cmake new file mode 100644 index 00000000..32e4de17 --- /dev/null +++ b/src/c/host-configs/tioga-4.18.0-x86_64-rocm@6.1.2-amdclang@17.0.0.cmake @@ -0,0 +1,2 @@ +set(CMAKE_C_COMPILER "/opt/rocm-6.1.2/bin/amdclang" CACHE PATH "") +set(CMAKE_CXX_COMPILER "/opt/rocm-6.1.2/bin/amdclang++" CACHE PATH "") From 5e50d3a9aaa2883afe55c196fef55a77751af39f Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Thu, 10 Oct 2024 12:30:10 -0700 Subject: [PATCH 57/62] fix for clang18 builds getInt8PtrTy removed in clang18 --- src/c/CMakeLists.txt | 12 ++++++-- src/c/weaver/weave/perfflow_weave_common.cpp | 32 ++++++++++++-------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/c/CMakeLists.txt b/src/c/CMakeLists.txt index 51057456..4a5fd3dd 100644 --- a/src/c/CMakeLists.txt +++ b/src/c/CMakeLists.txt @@ -7,10 +7,16 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # require at least Clang 9.0 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) message(FATAL_ERROR "Clang++ version must be at least 9.0!") - elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 15) - set(PERFFLOWASPECT_CLANG_15_NEWER TRUE CACHE BOOL "using >=clang15") + endif() + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 17) + set(PERFFLOWASPECT_CLANG_18_NEWER TRUE CACHE BOOL "using >clang17") + add_definitions(-DPERFFLOWASPECT_CLANG_18_NEWER) + endif() + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 15) + set(PERFFLOWASPECT_CLANG_15_NEWER TRUE CACHE BOOL "using >clang15") add_definitions(-DPERFFLOWASPECT_CLANG_15_NEWER) - elseif ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15)) + endif() + if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15)) set(PERFFLOWASPECT_CLANG_11_NEWER TRUE CACHE BOOL "using >=clang11") set(PERFFLOWASPECT_CLANG_15_NEWER FALSE CACHE BOOL "using < clang15") add_definitions(-DPERFFLOWASPECT_CLANG_11_NEWER) diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index 0c8e28ad..3c41f103 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -145,14 +145,18 @@ bool weave_ns::WeaveCommon::insertAfter(Module &m, Function &f, StringRef &a, auto &context = m.getContext(); Type *voidType = Type::getVoidTy(context); Type *int32Type = Type::getInt32Ty(context); - Type *int8PtrType = Type::getInt8PtrTy(context); +#ifdef PERFFLOWASPECT_CLANG_18_NEWER + Type *int8Type = Type::getInt8Ty(context); +#else + Type *int8Type = Type::getInt8PtrTy(context); +#endif std::vector params; params.push_back(int32Type); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); + params.push_back(int8Type); + params.push_back(int8Type); + params.push_back(int8Type); + params.push_back(int8Type); + params.push_back(int8Type); // voidType is return type, params are parameters and no variable length args FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false); @@ -198,14 +202,18 @@ bool weave_ns::WeaveCommon::insertBefore(Module &m, Function &f, StringRef &a, auto &context = m.getContext(); Type *voidType = Type::getVoidTy(context); Type *int32Type = Type::getInt32Ty(context); - Type *int8PtrType = Type::getInt8PtrTy(context); +#ifdef PERFFLOWASPECT_CLANG_18_NEWER + Type *int8Type = Type::getInt8Ty(context); +#else + Type *int8Type = Type::getInt8PtrTy(context); +#endif std::vector params; params.push_back(int32Type); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); - params.push_back(int8PtrType); + params.push_back(int8Type); + params.push_back(int8Type); + params.push_back(int8Type); + params.push_back(int8Type); + params.push_back(int8Type); // voidType is return type, params are parameters and no variable length args FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false); From 4084b935ca3806edc902918e97fc4601e203d273 Mon Sep 17 00:00:00 2001 From: loudsun1997 Date: Thu, 6 Feb 2025 21:00:19 -0500 Subject: [PATCH 58/62] updated build checks on clang 15. --- src/c/CMakeLists.txt | 21 ++++---------- src/c/test/CMakeLists.txt | 24 +++------------ src/c/weaver/weave/CMakeLists.txt | 29 +++++-------------- src/c/weaver/weave/perfflow_weave_common.cpp | 21 ++++---------- src/c/weaver/weave/perfflow_weave_common.hpp | 6 ---- .../weaver/weave/perfflow_weave_new_pass.cpp | 2 -- 6 files changed, 21 insertions(+), 82 deletions(-) diff --git a/src/c/CMakeLists.txt b/src/c/CMakeLists.txt index 4a5fd3dd..b63370c6 100644 --- a/src/c/CMakeLists.txt +++ b/src/c/CMakeLists.txt @@ -2,29 +2,18 @@ cmake_minimum_required(VERSION 3.12) project(PerfFlowAspect VERSION "0.1.0") -# Fail if using Clang < 9.0 +# Fail if using Clang < 15.0 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - # require at least Clang 9.0 - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) - message(FATAL_ERROR "Clang++ version must be at least 9.0!") + # require at least Clang 15.0 + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0) + message(FATAL_ERROR "Clang++ version must be at least 15.0!") endif() if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 17) set(PERFFLOWASPECT_CLANG_18_NEWER TRUE CACHE BOOL "using >clang17") add_definitions(-DPERFFLOWASPECT_CLANG_18_NEWER) endif() - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 15) - set(PERFFLOWASPECT_CLANG_15_NEWER TRUE CACHE BOOL "using >clang15") - add_definitions(-DPERFFLOWASPECT_CLANG_15_NEWER) - endif() - if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15)) - set(PERFFLOWASPECT_CLANG_11_NEWER TRUE CACHE BOOL "using >=clang11") - set(PERFFLOWASPECT_CLANG_15_NEWER FALSE CACHE BOOL "using < clang15") - add_definitions(-DPERFFLOWASPECT_CLANG_11_NEWER) - elseif (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11) - set(PERFFLOWASPECT_CLANG_11_NEWER FALSE CACHE BOOL "using < clang11") - endif() else() - message(FATAL_ERROR "Unsupported CXX compiler: please use Clang >= 9.0") + message(FATAL_ERROR "Unsupported CXX compiler: please use Clang >= 15.0") endif() include(cmake/CMakeBasics.cmake) diff --git a/src/c/test/CMakeLists.txt b/src/c/test/CMakeLists.txt index e2c43858..cb1fa0ee 100644 --- a/src/c/test/CMakeLists.txt +++ b/src/c/test/CMakeLists.txt @@ -11,11 +11,7 @@ message(STATUS "Adding CXX unit tests") foreach(TEST ${SMOKETESTS}) message(STATUS " [*] Adding test: ${TEST}") add_executable(${TEST} ${TEST}.cpp) - if (PERFFLOWASPECT_CLANG_15_NEWER) - set_source_files_properties(${TEST}.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fpass-plugin=../weaver/weave/libWeavePass.so -fPIC") - else() - set_source_files_properties(${TEST}.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fPIC") - endif() + set_source_files_properties(${TEST}.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fpass-plugin=../weaver/weave/libWeavePass.so -fPIC") target_link_libraries(${TEST} ${perfflow_deps}) endforeach() @@ -37,11 +33,7 @@ endif() if(PERFFLOWASPECT_WITH_MULTITHREADS) message(STATUS " [*] Adding test: smoketest_MT") add_executable(smoketest_MT smoketest_MT.cpp) - if (PERFFLOWASPECT_CLANG_15_NEWER) - set_source_files_properties(smoketest_MT.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fpass-plugin=../weaver/weave/libWeavePass.so -fPIC") - else() - set_source_files_properties(smoketest_MT.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fPIC") - endif() + set_source_files_properties(smoketest_MT.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fpass-plugin=../weaver/weave/libWeavePass.so -fPIC") set(THREADS_PREFER_PTHREAD_FLAG ON) target_link_libraries(smoketest_MT ${perfflow_deps} pthread) endif() @@ -49,22 +41,14 @@ endif() if(PERFFLOWASPECT_WITH_MPI) message(STATUS " [*] Adding test: smoketest_MPI") add_executable(smoketest_MPI smoketest_MPI.cpp) - if (PERFFLOWASPECT_CLANG_15_NEWER) - set_source_files_properties(smoketest_MPI.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fpass-plugin=../weaver/weave/libWeavePass.so -fPIC") - else() - set_source_files_properties(smoketest_MPI.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fPIC") - endif() + set_source_files_properties(smoketest_MPI.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fpass-plugin=../weaver/weave/libWeavePass.so -fPIC") include_directories(${MPI_INCLUDE_PATH}) target_link_libraries(smoketest_MPI ${perfflow_deps} ${MPI_LIBRARIES}) endif() if(PERFFLOWASPECT_WITH_CUDA) message(STATUS " [*] Adding test: smoketest_cuda") - if (PERFFLOWASPECT_CLANG_15_NEWER) - set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} -Xcompiler=-Xclang -Xcompiler=-load -Xcompiler=-Xclang -Xcompiler=../../../weaver/weave/libWeavePass.so -Xcompiler=-fpass-plugin=../../../weaver/weave/libWeavePass.so") - else() - set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} -Xcompiler=-Xclang -Xcompiler=-load -Xcompiler=-Xclang -Xcompiler=../../../weaver/weave/libWeavePass.so") - endif() + set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} -Xcompiler=-Xclang -Xcompiler=-load -Xcompiler=-Xclang -Xcompiler=../../../weaver/weave/libWeavePass.so -Xcompiler=-fpass-plugin=../../../weaver/weave/libWeavePass.so") cuda_add_executable(smoketest_cuda smoketest_cuda_wrapper.cpp smoketest_cuda_kernel.cu) target_link_libraries(smoketest_cuda ${perfflow_deps} ${CUDA_LIBRARIES}) endif() diff --git a/src/c/weaver/weave/CMakeLists.txt b/src/c/weaver/weave/CMakeLists.txt index a8e7fbc1..fbb1c97e 100644 --- a/src/c/weaver/weave/CMakeLists.txt +++ b/src/c/weaver/weave/CMakeLists.txt @@ -1,26 +1,11 @@ -if (PERFFLOWASPECT_CLANG_15_NEWER) - # Add the new pass - add_library(WeavePass MODULE - # List your source files here. - perfflow_weave_common.cpp - perfflow_weave_new_pass.cpp - ) -else() - # Add the legacy pass if we have Clang < 15. - add_library(WeavePass MODULE - # List your source files here. - perfflow_weave_common.cpp - perfflow_weave_legacy_pass.cpp - ) -endif() +# Add the new pass +add_library(WeavePass MODULE + # List your source files here. + perfflow_weave_common.cpp + perfflow_weave_new_pass.cpp +) -if (PERFFLOWASPECT_CLANG_15_NEWER) - # Use C++17 to compile our pass - target_compile_features(WeavePass PRIVATE cxx_std_17 cxx_range_for cxx_auto_type) -else() - # Use C++11/C++14 to compile our pass (i.e., supply -std=c++11) (pick default) - target_compile_features(WeavePass PRIVATE cxx_std_14 cxx_range_for cxx_auto_type) -endif() +target_compile_features(WeavePass PRIVATE cxx_std_17 cxx_range_for cxx_auto_type) # LLVM is (typically) built with no C++ RTTI. We need to match that; diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index 3c41f103..48c8d91a 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -62,25 +62,14 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) " operands \n"; } } -#if defined(PERFFLOWASPECT_CLANG_15_NEWER) - auto *fn = dyn_cast (e->getOperand(0)); -#else - auto *fn = dyn_cast (e->getOperand(0)->getOperand(0)); -#endif +auto *fn = dyn_cast (e->getOperand(0)); if (fn != NULL) { outs() << "I entered the part where we parse annotations. \n"; -#if defined(PERFFLOWASPECT_CLANG_15_NEWER) - auto anno = cast( - cast(e->getOperand(1)) - ->getOperand(0)) - ->getAsCString(); -#else - auto anno = cast( - cast(e->getOperand(1)->getOperand(0)) - ->getOperand(0)) - ->getAsCString(); -#endif +auto anno = cast( + cast(e->getOperand(1)) + ->getOperand(0)) + ->getAsCString(); std::string pcut, scope, flow; if (perfflow_parser_parse(anno.data(), pcut, scope, flow) == 0) diff --git a/src/c/weaver/weave/perfflow_weave_common.hpp b/src/c/weaver/weave/perfflow_weave_common.hpp index 7bac68de..b0ed66a5 100644 --- a/src/c/weaver/weave/perfflow_weave_common.hpp +++ b/src/c/weaver/weave/perfflow_weave_common.hpp @@ -15,17 +15,11 @@ #include "llvm/IR/Attributes.h" #include "llvm/IR/Constants.h" #include "llvm/IR/LegacyPassManager.h" -#if defined(PERFFLOWASPECT_CLANG_11_NEWER) || defined(PERFFLOWASPECT_CLANG_15_NEWER) #include "llvm/IR/AbstractCallSite.h" -#else -#include "llvm/IR/CallSite.h" -#endif #include "llvm/IR/Module.h" #include "llvm/IR/Argument.h" #include "llvm/IR/IRBuilder.h" -#if !defined(PERFFLOWASPECT_CLANG_15_NEWER) #include "llvm/Transforms/IPO/PassManagerBuilder.h" // legacy optimization pipeline in this header removed as of Clang17 -#endif #include "llvm/Support/raw_ostream.h" #include "../../parser/perfflow_parser.hpp" diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index 2c9f173c..eb406820 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -11,9 +11,7 @@ #include "llvm/IR/PassManager.h" #include "llvm/Passes/PassBuilder.h" #include "llvm/Passes/PassPlugin.h" -#if !defined(PERFFLOWASPECT_CLANG_15_NEWER) #include "llvm/Transforms/IPO/PassManagerBuilder.h" -#endif #include "llvm/Support/raw_ostream.h" #include "perfflow_weave_new_pass.hpp" From e966ba05090c436aee00b7d1ca7b342526cacbe2 Mon Sep 17 00:00:00 2001 From: loudsun1997 Date: Thu, 6 Feb 2025 23:28:34 -0500 Subject: [PATCH 59/62] Remove unused perfflow_weave_legacy_pass --- .../weave/perfflow_weave_legacy_pass.cpp | 60 ------------------- .../weave/perfflow_weave_legacy_pass.hpp | 39 ------------ 2 files changed, 99 deletions(-) delete mode 100644 src/c/weaver/weave/perfflow_weave_legacy_pass.cpp delete mode 100644 src/c/weaver/weave/perfflow_weave_legacy_pass.hpp diff --git a/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp b/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp deleted file mode 100644 index bdbe9256..00000000 --- a/src/c/weaver/weave/perfflow_weave_legacy_pass.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/************************************************************\ - * Copyright 2021 Lawrence Livermore National Security, LLC - * (c.f. AUTHORS, NOTICE.LLNS, COPYING) - * - * This file is part of the Flux resource manager framework. - * For details, see https://github.com/flux-framework. - * - * SPDX-License-Identifier: LGPL-3.0 -\************************************************************/ - -#include "llvm/IR/LegacyPassManager.h" -#include "llvm/Transforms/IPO/PassManagerBuilder.h" -#include "llvm/Support/raw_ostream.h" - -#include "perfflow_weave_legacy_pass.hpp" -#include "perfflow_weave_common.hpp" - -using namespace llvm; -using namespace weave_ns; - -/****************************************************************************** - * * - * Public Methods of LegacyWeavingPass Class * - * * - ******************************************************************************/ - -bool LegacyWeavingPass::doInitialization(Module &m) -{ - outs() << "WeavePass loaded successfully. \n"; - - bool changed = false; - - WeaveCommon weaver; - changed = weaver.modifyAnnotatedFunctions(m); - - return changed; -} - -bool LegacyWeavingPass::runOnFunction(Function &F) -{ - return false; -} - -char LegacyWeavingPass::ID = 0; - -// Automatically enable the pass. -// http://adriansampson.net/blog/clangpass.html -static void registerWeavingPass(const PassManagerBuilder &, - legacy::PassManagerBase &PM) -{ - PM.add(new LegacyWeavingPass()); -} - -static RegisterStandardPasses -RegisterMyPass(PassManagerBuilder::EP_EarlyAsPossible, - registerWeavingPass); - -/* - * vi:tabstop=4 shiftwidth=4 expandtab - */ diff --git a/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp b/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp deleted file mode 100644 index 4d3711b3..00000000 --- a/src/c/weaver/weave/perfflow_weave_legacy_pass.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/************************************************************\ - * Copyright 2021 Lawrence Livermore National Security, LLC - * (c.f. AUTHORS, NOTICE.LLNS, COPYING) - * - * This file is part of the Flux resource manager framework. - * For details, see https://github.com/flux-framework. - * - * SPDX-License-Identifier: LGPL-3.0 -\************************************************************/ - -#ifndef PERFFLOW_WEAVE_LEGACY_PASS_H -#define PERFFLOW_WEAVE_LEGACY_PASS_H - -#include "llvm/IR/Function.h" -#include "llvm/IR/Module.h" -#include "llvm/Pass.h" - -#include - -using namespace llvm; - -namespace { - -class LegacyWeavingPass : public FunctionPass -{ -public: - static char ID; - LegacyWeavingPass () : FunctionPass (ID) {} - virtual bool doInitialization (Module &m); - virtual bool runOnFunction (Function &F); -}; -} - -#endif // PERFFLOW_WEAVE_LEGACY_PASS_H - - -/* - * vi:tabstop=4 shiftwidth=4 expandtab - */ From 5ecabc72506f4edad567b86200d91e6a5dc4344e Mon Sep 17 00:00:00 2001 From: loudsun1997 Date: Tue, 18 Feb 2025 23:18:34 -0500 Subject: [PATCH 60/62] updated to minimum of using clang 18 --- src/c/CMakeLists.txt | 9 ++++----- src/c/host-configs/turing.cmake | 5 +++++ src/c/weaver/weave/perfflow_weave_common.cpp | 4 ---- src/c/weaver/weave/perfflow_weave_common.hpp | 2 +- src/c/weaver/weave/perfflow_weave_new_pass.cpp | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 src/c/host-configs/turing.cmake diff --git a/src/c/CMakeLists.txt b/src/c/CMakeLists.txt index b63370c6..489e7741 100644 --- a/src/c/CMakeLists.txt +++ b/src/c/CMakeLists.txt @@ -2,18 +2,17 @@ cmake_minimum_required(VERSION 3.12) project(PerfFlowAspect VERSION "0.1.0") -# Fail if using Clang < 15.0 +# Fail if using Clang < 18.0 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - # require at least Clang 15.0 - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0) - message(FATAL_ERROR "Clang++ version must be at least 15.0!") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0) + message(FATAL_ERROR "Clang++ version must be at least 18.0!") endif() if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 17) set(PERFFLOWASPECT_CLANG_18_NEWER TRUE CACHE BOOL "using >clang17") add_definitions(-DPERFFLOWASPECT_CLANG_18_NEWER) endif() else() - message(FATAL_ERROR "Unsupported CXX compiler: please use Clang >= 15.0") + message(FATAL_ERROR "Unsupported CXX compiler: please use Clang >= 18.0") endif() include(cmake/CMakeBasics.cmake) diff --git a/src/c/host-configs/turing.cmake b/src/c/host-configs/turing.cmake new file mode 100644 index 00000000..0f2ca8ad --- /dev/null +++ b/src/c/host-configs/turing.cmake @@ -0,0 +1,5 @@ +set(CMAKE_CXX_COMPILER "/cm/shared/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-13.2.0/llvm-18.1.8-bpqadvig7ku5rfx4jckqwuhf6lk5uljq/bin/clang++" CACHE PATH "") +set(CMAKE_C_COMPILER "/cm/shared/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-13.2.0/llvm-18.1.8-bpqadvig7ku5rfx4jckqwuhf6lk5uljq/bin/clang" CACHE PATH "") +set(LLVM_DIR "/cm/shared/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-13.2.0/llvm-18.1.8-bpqadvig7ku5rfx4jckqwuhf6lk5uljq/lib/cmake/llvm" CACHE PATH "") + +set(PERFFLOWASPECT_WITH_CUDA "OFF" CACHE BOOL "") diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index 48c8d91a..9fe17c9c 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -191,11 +191,7 @@ bool weave_ns::WeaveCommon::insertBefore(Module &m, Function &f, StringRef &a, auto &context = m.getContext(); Type *voidType = Type::getVoidTy(context); Type *int32Type = Type::getInt32Ty(context); -#ifdef PERFFLOWASPECT_CLANG_18_NEWER Type *int8Type = Type::getInt8Ty(context); -#else - Type *int8Type = Type::getInt8PtrTy(context); -#endif std::vector params; params.push_back(int32Type); params.push_back(int8Type); diff --git a/src/c/weaver/weave/perfflow_weave_common.hpp b/src/c/weaver/weave/perfflow_weave_common.hpp index b0ed66a5..a4d200ba 100644 --- a/src/c/weaver/weave/perfflow_weave_common.hpp +++ b/src/c/weaver/weave/perfflow_weave_common.hpp @@ -19,7 +19,7 @@ #include "llvm/IR/Module.h" #include "llvm/IR/Argument.h" #include "llvm/IR/IRBuilder.h" -#include "llvm/Transforms/IPO/PassManagerBuilder.h" // legacy optimization pipeline in this header removed as of Clang17 +// #include "llvm/Transforms/IPO/PassManagerBuilder.h" // legacy optimization pipeline in this header removed as of Clang17 #include "llvm/Support/raw_ostream.h" #include "../../parser/perfflow_parser.hpp" diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index eb406820..6aeeb5e6 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -11,7 +11,7 @@ #include "llvm/IR/PassManager.h" #include "llvm/Passes/PassBuilder.h" #include "llvm/Passes/PassPlugin.h" -#include "llvm/Transforms/IPO/PassManagerBuilder.h" +// #include "llvm/Transforms/IPO/PassManagerBuilder.h" #include "llvm/Support/raw_ostream.h" #include "perfflow_weave_new_pass.hpp" From a43d9da6c400a8c2637d638f8bf2f4d21aea3925 Mon Sep 17 00:00:00 2001 From: Zhiwei Yang Date: Sat, 8 Mar 2025 20:40:59 -0500 Subject: [PATCH 61/62] removed PassManagerBuilder --- src/c/weaver/weave/perfflow_weave_new_pass.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index 6aeeb5e6..faa86eb0 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -11,7 +11,6 @@ #include "llvm/IR/PassManager.h" #include "llvm/Passes/PassBuilder.h" #include "llvm/Passes/PassPlugin.h" -// #include "llvm/Transforms/IPO/PassManagerBuilder.h" #include "llvm/Support/raw_ostream.h" #include "perfflow_weave_new_pass.hpp" From 866ba7dbc81a7514635a5ee0be0ea0d7a592a104 Mon Sep 17 00:00:00 2001 From: loudsun1997 Date: Tue, 11 Mar 2025 14:29:39 -0400 Subject: [PATCH 62/62] code formatting --- src/c/weaver/weave/perfflow_weave_common.cpp | 10 +++++----- src/c/weaver/weave/perfflow_weave_new_pass.cpp | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index 9fe17c9c..582357fe 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -62,14 +62,14 @@ bool weave_ns::WeaveCommon::modifyAnnotatedFunctions(Module &m) " operands \n"; } } -auto *fn = dyn_cast (e->getOperand(0)); + auto *fn = dyn_cast (e->getOperand(0)); if (fn != NULL) { outs() << "I entered the part where we parse annotations. \n"; -auto anno = cast( - cast(e->getOperand(1)) - ->getOperand(0)) - ->getAsCString(); + auto anno = cast( + cast(e->getOperand(1)) + ->getOperand(0)) + ->getAsCString(); std::string pcut, scope, flow; if (perfflow_parser_parse(anno.data(), pcut, scope, flow) == 0) diff --git a/src/c/weaver/weave/perfflow_weave_new_pass.cpp b/src/c/weaver/weave/perfflow_weave_new_pass.cpp index 6aeeb5e6..4d4839c3 100644 --- a/src/c/weaver/weave/perfflow_weave_new_pass.cpp +++ b/src/c/weaver/weave/perfflow_weave_new_pass.cpp @@ -11,7 +11,6 @@ #include "llvm/IR/PassManager.h" #include "llvm/Passes/PassBuilder.h" #include "llvm/Passes/PassPlugin.h" -// #include "llvm/Transforms/IPO/PassManagerBuilder.h" #include "llvm/Support/raw_ostream.h" #include "perfflow_weave_new_pass.hpp" @@ -62,12 +61,12 @@ PassPluginLibraryInfo getNewWeavingPassPluginInfo() const auto pass_callback = [](PassBuilder & PB) { PB.registerPipelineEarlySimplificationEPCallback( - [&](ModulePassManager & MPM, auto) + [&](ModulePassManager & MPM, auto) { MPM.addPass(NewWeavingPass()); return true; } - ); + ); }; return {LLVM_PLUGIN_API_VERSION, "new-weaving-pass", LLVM_VERSION_STRING, pass_callback};