[llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)
[llvm-project.git] / bolt / lib / Rewrite / MetadataManager.cpp
blob059b43f83328a51e541af5b433b11b7a4a2a8eb4
1 //===- bolt/Rewrite/MetadataManager.cpp -----------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "bolt/Rewrite/MetadataManager.h"
10 #include "llvm/Support/Debug.h"
12 #undef DEBUG_TYPE
13 #define DEBUG_TYPE "bolt-metadata"
15 using namespace llvm;
16 using namespace bolt;
18 void MetadataManager::registerRewriter(
19 std::unique_ptr<MetadataRewriter> Rewriter) {
20 Rewriters.emplace_back(std::move(Rewriter));
23 void MetadataManager::runInitializersPreCFG() {
24 for (auto &Rewriter : Rewriters) {
25 LLVM_DEBUG(dbgs() << "BOLT-DEBUG: invoking " << Rewriter->getName()
26 << " before CFG construction\n");
27 if (Error E = Rewriter->preCFGInitializer()) {
28 errs() << "BOLT-ERROR: while running " << Rewriter->getName()
29 << " in pre-CFG state: " << toString(std::move(E)) << '\n';
30 exit(1);
35 void MetadataManager::runInitializersPostCFG() {
36 for (auto &Rewriter : Rewriters) {
37 LLVM_DEBUG(dbgs() << "BOLT-DEBUG: invoking " << Rewriter->getName()
38 << " after CFG construction\n");
39 if (Error E = Rewriter->postCFGInitializer()) {
40 errs() << "BOLT-ERROR: while running " << Rewriter->getName()
41 << " in CFG state: " << toString(std::move(E)) << '\n';
42 exit(1);
47 void MetadataManager::runFinalizersAfterEmit() {
48 for (auto &Rewriter : Rewriters) {
49 LLVM_DEBUG(dbgs() << "BOLT-DEBUG: invoking " << Rewriter->getName()
50 << " after emit\n");
51 if (Error E = Rewriter->postEmitFinalizer()) {
52 errs() << "BOLT-ERROR: while running " << Rewriter->getName()
53 << " after emit: " << toString(std::move(E)) << '\n';
54 exit(1);