Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 1 | //===-- llvm-mca.cpp - Machine Code Analyzer -------------------*- C++ -* -===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This utility is a simple driver that allows static performance analysis on |
| 10 | // machine code similarly to how IACA (Intel Architecture Code Analyzer) works. |
| 11 | // |
| 12 | // llvm-mca [options] <file-name> |
| 13 | // -march <type> |
| 14 | // -mcpu <cpu> |
| 15 | // -o <file> |
| 16 | // |
| 17 | // The target defaults to the host target. |
Andrea Di Biagio | 93c49d5 | 2018-04-25 10:18:25 +0000 | [diff] [blame] | 18 | // The cpu defaults to the 'native' host cpu. |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 19 | // The output defaults to standard output. |
| 20 | // |
| 21 | //===----------------------------------------------------------------------===// |
| 22 | |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 23 | #include "CodeRegion.h" |
Matt Davis | 23f7106 | 2018-11-07 19:20:04 +0000 | [diff] [blame] | 24 | #include "CodeRegionGenerator.h" |
Matt Davis | dea343d | 2018-06-25 16:53:00 +0000 | [diff] [blame] | 25 | #include "PipelinePrinter.h" |
Matt Davis | 10aa09f | 2018-08-24 20:24:53 +0000 | [diff] [blame] | 26 | #include "Views/DispatchStatistics.h" |
| 27 | #include "Views/InstructionInfoView.h" |
| 28 | #include "Views/RegisterFileStatistics.h" |
| 29 | #include "Views/ResourcePressureView.h" |
| 30 | #include "Views/RetireControlUnitStatistics.h" |
| 31 | #include "Views/SchedulerStatistics.h" |
| 32 | #include "Views/SummaryView.h" |
| 33 | #include "Views/TimelineView.h" |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 34 | #include "llvm/MC/MCAsmInfo.h" |
| 35 | #include "llvm/MC/MCContext.h" |
| 36 | #include "llvm/MC/MCObjectFileInfo.h" |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 37 | #include "llvm/MC/MCRegisterInfo.h" |
Clement Courbet | cc5e6a7 | 2018-12-17 08:08:31 +0000 | [diff] [blame] | 38 | #include "llvm/MCA/Context.h" |
| 39 | #include "llvm/MCA/Pipeline.h" |
| 40 | #include "llvm/MCA/Stages/EntryStage.h" |
| 41 | #include "llvm/MCA/Stages/InstructionTables.h" |
| 42 | #include "llvm/MCA/Support.h" |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 43 | #include "llvm/Support/CommandLine.h" |
Matt Davis | 4bcf369 | 2018-08-13 18:11:48 +0000 | [diff] [blame] | 44 | #include "llvm/Support/ErrorHandling.h" |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 45 | #include "llvm/Support/ErrorOr.h" |
| 46 | #include "llvm/Support/FileSystem.h" |
Andrea Di Biagio | 641cca3 | 2018-04-25 10:27:30 +0000 | [diff] [blame] | 47 | #include "llvm/Support/Host.h" |
Rui Ueyama | 197194b | 2018-04-13 18:26:06 +0000 | [diff] [blame] | 48 | #include "llvm/Support/InitLLVM.h" |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 49 | #include "llvm/Support/MemoryBuffer.h" |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 50 | #include "llvm/Support/SourceMgr.h" |
| 51 | #include "llvm/Support/TargetRegistry.h" |
| 52 | #include "llvm/Support/TargetSelect.h" |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 53 | #include "llvm/Support/ToolOutputFile.h" |
Jonas Devlieghere | 6adef09 | 2018-04-18 15:26:51 +0000 | [diff] [blame] | 54 | #include "llvm/Support/WithColor.h" |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 55 | |
| 56 | using namespace llvm; |
| 57 | |
Andrea Di Biagio | 55e9e0f | 2018-05-17 15:35:14 +0000 | [diff] [blame] | 58 | static cl::OptionCategory ToolOptions("Tool Options"); |
| 59 | static cl::OptionCategory ViewOptions("View Options"); |
Andrea Di Biagio | 534e1da | 2018-04-25 11:33:14 +0000 | [diff] [blame] | 60 | |
Andrea Di Biagio | 55e9e0f | 2018-05-17 15:35:14 +0000 | [diff] [blame] | 61 | static cl::opt<std::string> InputFilename(cl::Positional, |
| 62 | cl::desc("<input file>"), |
| 63 | cl::cat(ToolOptions), cl::init("-")); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 64 | |
| 65 | static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"), |
Andrea Di Biagio | 55e9e0f | 2018-05-17 15:35:14 +0000 | [diff] [blame] | 66 | cl::init("-"), cl::cat(ToolOptions), |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 67 | cl::value_desc("filename")); |
| 68 | |
| 69 | static cl::opt<std::string> |
Matt Davis | 9e64a4c | 2018-10-31 17:47:25 +0000 | [diff] [blame] | 70 | ArchName("march", cl::desc("Target architecture. " |
| 71 | "See -version for available targets"), |
Andrea Di Biagio | 55e9e0f | 2018-05-17 15:35:14 +0000 | [diff] [blame] | 72 | cl::cat(ToolOptions)); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 73 | |
| 74 | static cl::opt<std::string> |
Andrea Di Biagio | 01b9fd6 | 2018-10-22 15:36:15 +0000 | [diff] [blame] | 75 | TripleName("mtriple", |
Matt Davis | 9e64a4c | 2018-10-31 17:47:25 +0000 | [diff] [blame] | 76 | cl::desc("Target triple. See -version for available targets"), |
Andrea Di Biagio | 55e9e0f | 2018-05-17 15:35:14 +0000 | [diff] [blame] | 77 | cl::cat(ToolOptions)); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 78 | |
| 79 | static cl::opt<std::string> |
| 80 | MCPU("mcpu", |
| 81 | cl::desc("Target a specific cpu type (-mcpu=help for details)"), |
Andrea Di Biagio | 55e9e0f | 2018-05-17 15:35:14 +0000 | [diff] [blame] | 82 | cl::value_desc("cpu-name"), cl::cat(ToolOptions), cl::init("native")); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 83 | |
Andrea Di Biagio | 0626864 | 2018-04-24 16:19:08 +0000 | [diff] [blame] | 84 | static cl::opt<int> |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 85 | OutputAsmVariant("output-asm-variant", |
Andrea Di Biagio | 0626864 | 2018-04-24 16:19:08 +0000 | [diff] [blame] | 86 | cl::desc("Syntax variant to use for output printing"), |
Andrea Di Biagio | 55e9e0f | 2018-05-17 15:35:14 +0000 | [diff] [blame] | 87 | cl::cat(ToolOptions), cl::init(-1)); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 88 | |
| 89 | static cl::opt<unsigned> Iterations("iterations", |
| 90 | cl::desc("Number of iterations to run"), |
Andrea Di Biagio | 55e9e0f | 2018-05-17 15:35:14 +0000 | [diff] [blame] | 91 | cl::cat(ToolOptions), cl::init(0)); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 92 | |
Andrea Di Biagio | 55e9e0f | 2018-05-17 15:35:14 +0000 | [diff] [blame] | 93 | static cl::opt<unsigned> |
| 94 | DispatchWidth("dispatch", cl::desc("Override the processor dispatch width"), |
| 95 | cl::cat(ToolOptions), cl::init(0)); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 96 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 97 | static cl::opt<unsigned> |
| 98 | RegisterFileSize("register-file-size", |
Matt Davis | 5ceaa98 | 2018-07-31 20:05:08 +0000 | [diff] [blame] | 99 | cl::desc("Maximum number of physical registers which can " |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 100 | "be used for register mappings"), |
Andrea Di Biagio | 55e9e0f | 2018-05-17 15:35:14 +0000 | [diff] [blame] | 101 | cl::cat(ToolOptions), cl::init(0)); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 102 | |
Andrea Di Biagio | e074ac6 | 2019-03-29 12:15:37 +0000 | [diff] [blame] | 103 | static cl::opt<unsigned> |
| 104 | MicroOpQueue("micro-op-queue-size", cl::Hidden, |
| 105 | cl::desc("Number of entries in the micro-op queue"), |
| 106 | cl::cat(ToolOptions), cl::init(0)); |
| 107 | |
| 108 | static cl::opt<unsigned> |
| 109 | DecoderThroughput("decoder-throughput", cl::Hidden, |
| 110 | cl::desc("Maximum throughput from the decoders " |
| 111 | "(instructions per cycle)"), |
| 112 | cl::cat(ToolOptions), cl::init(0)); |
| 113 | |
Andrea Di Biagio | 29538c6 | 2018-03-23 11:33:09 +0000 | [diff] [blame] | 114 | static cl::opt<bool> |
Andrea Di Biagio | 8dabf4f | 2018-04-03 16:46:23 +0000 | [diff] [blame] | 115 | PrintRegisterFileStats("register-file-stats", |
| 116 | cl::desc("Print register file statistics"), |
Andrea Di Biagio | 450ea7a | 2018-05-05 15:36:47 +0000 | [diff] [blame] | 117 | cl::cat(ViewOptions), cl::init(false)); |
Andrea Di Biagio | 8dabf4f | 2018-04-03 16:46:23 +0000 | [diff] [blame] | 118 | |
Andrea Di Biagio | 641cca3 | 2018-04-25 10:27:30 +0000 | [diff] [blame] | 119 | static cl::opt<bool> PrintDispatchStats("dispatch-stats", |
| 120 | cl::desc("Print dispatch statistics"), |
Andrea Di Biagio | 450ea7a | 2018-05-05 15:36:47 +0000 | [diff] [blame] | 121 | cl::cat(ViewOptions), cl::init(false)); |
Andrea Di Biagio | 821f650 | 2018-04-10 14:55:14 +0000 | [diff] [blame] | 122 | |
Roman Lebedev | 9ddf128 | 2018-06-15 14:01:43 +0000 | [diff] [blame] | 123 | static cl::opt<bool> |
| 124 | PrintSummaryView("summary-view", cl::Hidden, |
| 125 | cl::desc("Print summary view (enabled by default)"), |
| 126 | cl::cat(ViewOptions), cl::init(true)); |
| 127 | |
Andrea Di Biagio | 641cca3 | 2018-04-25 10:27:30 +0000 | [diff] [blame] | 128 | static cl::opt<bool> PrintSchedulerStats("scheduler-stats", |
| 129 | cl::desc("Print scheduler statistics"), |
Andrea Di Biagio | 450ea7a | 2018-05-05 15:36:47 +0000 | [diff] [blame] | 130 | cl::cat(ViewOptions), cl::init(false)); |
Andrea Di Biagio | 1cc29c0 | 2018-04-11 11:37:46 +0000 | [diff] [blame] | 131 | |
| 132 | static cl::opt<bool> |
Andrea Di Biagio | f41ad5c | 2018-04-11 12:12:53 +0000 | [diff] [blame] | 133 | PrintRetireStats("retire-stats", |
Andrea Di Biagio | 641cca3 | 2018-04-25 10:27:30 +0000 | [diff] [blame] | 134 | cl::desc("Print retire control unit statistics"), |
Andrea Di Biagio | 450ea7a | 2018-05-05 15:36:47 +0000 | [diff] [blame] | 135 | cl::cat(ViewOptions), cl::init(false)); |
Andrea Di Biagio | f41ad5c | 2018-04-11 12:12:53 +0000 | [diff] [blame] | 136 | |
Andrea Di Biagio | 450ea7a | 2018-05-05 15:36:47 +0000 | [diff] [blame] | 137 | static cl::opt<bool> PrintResourcePressureView( |
| 138 | "resource-pressure", |
| 139 | cl::desc("Print the resource pressure view (enabled by default)"), |
| 140 | cl::cat(ViewOptions), cl::init(true)); |
Andrea Di Biagio | 29538c6 | 2018-03-23 11:33:09 +0000 | [diff] [blame] | 141 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 142 | static cl::opt<bool> PrintTimelineView("timeline", |
| 143 | cl::desc("Print the timeline view"), |
Andrea Di Biagio | 450ea7a | 2018-05-05 15:36:47 +0000 | [diff] [blame] | 144 | cl::cat(ViewOptions), cl::init(false)); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 145 | |
| 146 | static cl::opt<unsigned> TimelineMaxIterations( |
| 147 | "timeline-max-iterations", |
| 148 | cl::desc("Maximum number of iterations to print in timeline view"), |
Andrea Di Biagio | 450ea7a | 2018-05-05 15:36:47 +0000 | [diff] [blame] | 149 | cl::cat(ViewOptions), cl::init(0)); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 150 | |
| 151 | static cl::opt<unsigned> TimelineMaxCycles( |
| 152 | "timeline-max-cycles", |
| 153 | cl::desc( |
| 154 | "Maximum number of cycles in the timeline view. Defaults to 80 cycles"), |
Andrea Di Biagio | 450ea7a | 2018-05-05 15:36:47 +0000 | [diff] [blame] | 155 | cl::cat(ViewOptions), cl::init(80)); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 156 | |
Andrea Di Biagio | 55e9e0f | 2018-05-17 15:35:14 +0000 | [diff] [blame] | 157 | static cl::opt<bool> |
| 158 | AssumeNoAlias("noalias", |
| 159 | cl::desc("If set, assume that loads and stores do not alias"), |
| 160 | cl::cat(ToolOptions), cl::init(true)); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 161 | |
Matt Davis | 4b7396e | 2018-12-19 18:27:05 +0000 | [diff] [blame] | 162 | static cl::opt<unsigned> LoadQueueSize("lqueue", |
| 163 | cl::desc("Size of the load queue"), |
| 164 | cl::cat(ToolOptions), cl::init(0)); |
Andrea Di Biagio | d156929 | 2018-03-26 12:04:53 +0000 | [diff] [blame] | 165 | |
Matt Davis | 4b7396e | 2018-12-19 18:27:05 +0000 | [diff] [blame] | 166 | static cl::opt<unsigned> StoreQueueSize("squeue", |
| 167 | cl::desc("Size of the store queue"), |
| 168 | cl::cat(ToolOptions), cl::init(0)); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 169 | |
Andrea Di Biagio | d156929 | 2018-03-26 12:04:53 +0000 | [diff] [blame] | 170 | static cl::opt<bool> |
| 171 | PrintInstructionTables("instruction-tables", |
| 172 | cl::desc("Print instruction tables"), |
Andrea Di Biagio | 55e9e0f | 2018-05-17 15:35:14 +0000 | [diff] [blame] | 173 | cl::cat(ToolOptions), cl::init(false)); |
Andrea Di Biagio | d156929 | 2018-03-26 12:04:53 +0000 | [diff] [blame] | 174 | |
Andrea Di Biagio | 450ea7a | 2018-05-05 15:36:47 +0000 | [diff] [blame] | 175 | static cl::opt<bool> PrintInstructionInfoView( |
| 176 | "instruction-info", |
| 177 | cl::desc("Print the instruction info view (enabled by default)"), |
| 178 | cl::cat(ViewOptions), cl::init(true)); |
Andrea Di Biagio | ff9c109 | 2018-03-26 13:44:54 +0000 | [diff] [blame] | 179 | |
Andrea Di Biagio | 650b5fc | 2018-05-17 12:27:03 +0000 | [diff] [blame] | 180 | static cl::opt<bool> EnableAllStats("all-stats", |
| 181 | cl::desc("Print all hardware statistics"), |
| 182 | cl::cat(ViewOptions), cl::init(false)); |
| 183 | |
| 184 | static cl::opt<bool> |
| 185 | EnableAllViews("all-views", |
| 186 | cl::desc("Print all views including hardware statistics"), |
| 187 | cl::cat(ViewOptions), cl::init(false)); |
| 188 | |
Andrea Di Biagio | be3281a | 2019-03-04 11:52:34 +0000 | [diff] [blame] | 189 | static cl::opt<bool> EnableBottleneckAnalysis( |
| 190 | "bottleneck-analysis", |
| 191 | cl::desc("Enable bottleneck analysis (disabled by default)"), |
| 192 | cl::cat(ViewOptions), cl::init(false)); |
| 193 | |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 194 | namespace { |
| 195 | |
| 196 | const Target *getTarget(const char *ProgName) { |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 197 | if (TripleName.empty()) |
| 198 | TripleName = Triple::normalize(sys::getDefaultTargetTriple()); |
| 199 | Triple TheTriple(TripleName); |
| 200 | |
| 201 | // Get the target specific parser. |
| 202 | std::string Error; |
| 203 | const Target *TheTarget = |
| 204 | TargetRegistry::lookupTarget(ArchName, TheTriple, Error); |
| 205 | if (!TheTarget) { |
| 206 | errs() << ProgName << ": " << Error; |
| 207 | return nullptr; |
| 208 | } |
| 209 | |
| 210 | // Return the found target. |
| 211 | return TheTarget; |
| 212 | } |
| 213 | |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 214 | ErrorOr<std::unique_ptr<ToolOutputFile>> getOutputStream() { |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 215 | if (OutputFilename == "") |
| 216 | OutputFilename = "-"; |
| 217 | std::error_code EC; |
Matt Davis | 9e71970 | 2018-11-08 18:08:43 +0000 | [diff] [blame] | 218 | auto Out = |
| 219 | llvm::make_unique<ToolOutputFile>(OutputFilename, EC, sys::fs::F_None); |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 220 | if (!EC) |
| 221 | return std::move(Out); |
| 222 | return EC; |
| 223 | } |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 224 | } // end of anonymous namespace |
| 225 | |
Andrea Di Biagio | 650b5fc | 2018-05-17 12:27:03 +0000 | [diff] [blame] | 226 | static void processOptionImpl(cl::opt<bool> &O, const cl::opt<bool> &Default) { |
| 227 | if (!O.getNumOccurrences() || O.getPosition() < Default.getPosition()) |
| 228 | O = Default.getValue(); |
| 229 | } |
| 230 | |
| 231 | static void processViewOptions() { |
| 232 | if (!EnableAllViews.getNumOccurrences() && |
| 233 | !EnableAllStats.getNumOccurrences()) |
| 234 | return; |
| 235 | |
| 236 | if (EnableAllViews.getNumOccurrences()) { |
Roman Lebedev | 9ddf128 | 2018-06-15 14:01:43 +0000 | [diff] [blame] | 237 | processOptionImpl(PrintSummaryView, EnableAllViews); |
Andrea Di Biagio | 650b5fc | 2018-05-17 12:27:03 +0000 | [diff] [blame] | 238 | processOptionImpl(PrintResourcePressureView, EnableAllViews); |
| 239 | processOptionImpl(PrintTimelineView, EnableAllViews); |
| 240 | processOptionImpl(PrintInstructionInfoView, EnableAllViews); |
| 241 | } |
| 242 | |
| 243 | const cl::opt<bool> &Default = |
| 244 | EnableAllViews.getPosition() < EnableAllStats.getPosition() |
| 245 | ? EnableAllStats |
| 246 | : EnableAllViews; |
| 247 | processOptionImpl(PrintRegisterFileStats, Default); |
| 248 | processOptionImpl(PrintDispatchStats, Default); |
| 249 | processOptionImpl(PrintSchedulerStats, Default); |
| 250 | processOptionImpl(PrintRetireStats, Default); |
| 251 | } |
| 252 | |
Andrea Di Biagio | 083addf | 2018-10-24 10:56:47 +0000 | [diff] [blame] | 253 | // Returns true on success. |
Andrea Di Biagio | df4d65d | 2018-10-29 13:29:22 +0000 | [diff] [blame] | 254 | static bool runPipeline(mca::Pipeline &P) { |
Andrea Di Biagio | 083addf | 2018-10-24 10:56:47 +0000 | [diff] [blame] | 255 | // Handle pipeline errors here. |
Andrea Di Biagio | d10ed7c | 2018-11-28 19:31:19 +0000 | [diff] [blame] | 256 | Expected<unsigned> Cycles = P.run(); |
| 257 | if (!Cycles) { |
| 258 | WithColor::error() << toString(Cycles.takeError()); |
Andrea Di Biagio | 083addf | 2018-10-24 10:56:47 +0000 | [diff] [blame] | 259 | return false; |
| 260 | } |
Andrea Di Biagio | 083addf | 2018-10-24 10:56:47 +0000 | [diff] [blame] | 261 | return true; |
| 262 | } |
| 263 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 264 | int main(int argc, char **argv) { |
Rui Ueyama | 197194b | 2018-04-13 18:26:06 +0000 | [diff] [blame] | 265 | InitLLVM X(argc, argv); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 266 | |
| 267 | // Initialize targets and assembly parsers. |
Matt Davis | 08b64d6 | 2018-11-08 17:32:45 +0000 | [diff] [blame] | 268 | InitializeAllTargetInfos(); |
| 269 | InitializeAllTargetMCs(); |
| 270 | InitializeAllAsmParsers(); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 271 | |
| 272 | // Enable printing of available targets when flag --version is specified. |
| 273 | cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion); |
| 274 | |
Andrea Di Biagio | 55e9e0f | 2018-05-17 15:35:14 +0000 | [diff] [blame] | 275 | cl::HideUnrelatedOptions({&ToolOptions, &ViewOptions}); |
| 276 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 277 | // Parse flags and initialize target options. |
| 278 | cl::ParseCommandLineOptions(argc, argv, |
| 279 | "llvm machine code performance analyzer.\n"); |
Andrea Di Biagio | 55e9e0f | 2018-05-17 15:35:14 +0000 | [diff] [blame] | 280 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 281 | // Get the target from the triple. If a triple is not specified, then select |
| 282 | // the default triple for the host. If the triple doesn't correspond to any |
| 283 | // registered target, then exit with an error message. |
| 284 | const char *ProgName = argv[0]; |
| 285 | const Target *TheTarget = getTarget(ProgName); |
| 286 | if (!TheTarget) |
| 287 | return 1; |
| 288 | |
| 289 | // GetTarget() may replaced TripleName with a default triple. |
| 290 | // For safety, reconstruct the Triple object. |
| 291 | Triple TheTriple(TripleName); |
| 292 | |
| 293 | ErrorOr<std::unique_ptr<MemoryBuffer>> BufferPtr = |
| 294 | MemoryBuffer::getFileOrSTDIN(InputFilename); |
| 295 | if (std::error_code EC = BufferPtr.getError()) { |
Jonas Devlieghere | 6adef09 | 2018-04-18 15:26:51 +0000 | [diff] [blame] | 296 | WithColor::error() << InputFilename << ": " << EC.message() << '\n'; |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 297 | return 1; |
| 298 | } |
| 299 | |
Andrea Di Biagio | 650b5fc | 2018-05-17 12:27:03 +0000 | [diff] [blame] | 300 | // Apply overrides to llvm-mca specific options. |
| 301 | processViewOptions(); |
| 302 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 303 | SourceMgr SrcMgr; |
| 304 | |
| 305 | // Tell SrcMgr about this buffer, which is what the parser will pick up. |
| 306 | SrcMgr.AddNewSourceBuffer(std::move(*BufferPtr), SMLoc()); |
| 307 | |
| 308 | std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName)); |
| 309 | assert(MRI && "Unable to create target register info!"); |
| 310 | |
| 311 | std::unique_ptr<MCAsmInfo> MAI(TheTarget->createMCAsmInfo(*MRI, TripleName)); |
| 312 | assert(MAI && "Unable to create target asm info!"); |
| 313 | |
| 314 | MCObjectFileInfo MOFI; |
| 315 | MCContext Ctx(MAI.get(), MRI.get(), &MOFI, &SrcMgr); |
| 316 | MOFI.InitMCObjectFileInfo(TheTriple, /* PIC= */ false, Ctx); |
| 317 | |
| 318 | std::unique_ptr<buffer_ostream> BOS; |
Andrea Di Biagio | d156929 | 2018-03-26 12:04:53 +0000 | [diff] [blame] | 319 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 320 | std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo()); |
Andrea Di Biagio | 93c49d5 | 2018-04-25 10:18:25 +0000 | [diff] [blame] | 321 | |
Andrea Di Biagio | 2145b13 | 2018-06-20 10:08:11 +0000 | [diff] [blame] | 322 | std::unique_ptr<MCInstrAnalysis> MCIA( |
| 323 | TheTarget->createMCInstrAnalysis(MCII.get())); |
| 324 | |
Andrea Di Biagio | 93c49d5 | 2018-04-25 10:18:25 +0000 | [diff] [blame] | 325 | if (!MCPU.compare("native")) |
Matt Davis | 9e71970 | 2018-11-08 18:08:43 +0000 | [diff] [blame] | 326 | MCPU = llvm::sys::getHostCPUName(); |
Andrea Di Biagio | 93c49d5 | 2018-04-25 10:18:25 +0000 | [diff] [blame] | 327 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 328 | std::unique_ptr<MCSubtargetInfo> STI( |
| 329 | TheTarget->createMCSubtargetInfo(TripleName, MCPU, /* FeaturesStr */ "")); |
| 330 | if (!STI->isCPUStringValid(MCPU)) |
| 331 | return 1; |
| 332 | |
Andrea Di Biagio | e9384eb | 2018-04-30 12:05:34 +0000 | [diff] [blame] | 333 | if (!PrintInstructionTables && !STI->getSchedModel().isOutOfOrder()) { |
Jonas Devlieghere | 6adef09 | 2018-04-18 15:26:51 +0000 | [diff] [blame] | 334 | WithColor::error() << "please specify an out-of-order cpu. '" << MCPU |
| 335 | << "' is an in-order cpu.\n"; |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 336 | return 1; |
| 337 | } |
| 338 | |
| 339 | if (!STI->getSchedModel().hasInstrSchedModel()) { |
Jonas Devlieghere | 6adef09 | 2018-04-18 15:26:51 +0000 | [diff] [blame] | 340 | WithColor::error() |
| 341 | << "unable to find instruction-level scheduling information for" |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 342 | << " target triple '" << TheTriple.normalize() << "' and cpu '" << MCPU |
| 343 | << "'.\n"; |
| 344 | |
| 345 | if (STI->getSchedModel().InstrItineraries) |
Jonas Devlieghere | 6adef09 | 2018-04-18 15:26:51 +0000 | [diff] [blame] | 346 | WithColor::note() |
| 347 | << "cpu '" << MCPU << "' provides itineraries. However, " |
| 348 | << "instruction itineraries are currently unsupported.\n"; |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 349 | return 1; |
| 350 | } |
| 351 | |
Matt Davis | 23f7106 | 2018-11-07 19:20:04 +0000 | [diff] [blame] | 352 | // Parse the input and create CodeRegions that llvm-mca can analyze. |
| 353 | mca::AsmCodeRegionGenerator CRG(*TheTarget, SrcMgr, Ctx, *MAI, *STI, *MCII); |
| 354 | Expected<const mca::CodeRegions &> RegionsOrErr = CRG.parseCodeRegions(); |
Matt Davis | 4b7396e | 2018-12-19 18:27:05 +0000 | [diff] [blame] | 355 | if (!RegionsOrErr) { |
| 356 | if (auto Err = |
Matt Davis | 3364be7 | 2018-12-19 18:57:43 +0000 | [diff] [blame] | 357 | handleErrors(RegionsOrErr.takeError(), [](const StringError &E) { |
| 358 | WithColor::error() << E.getMessage() << '\n'; |
Matt Davis | 4b7396e | 2018-12-19 18:27:05 +0000 | [diff] [blame] | 359 | })) { |
| 360 | // Default case. |
| 361 | WithColor::error() << toString(std::move(Err)) << '\n'; |
| 362 | } |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 363 | return 1; |
Matt Davis | 23f7106 | 2018-11-07 19:20:04 +0000 | [diff] [blame] | 364 | } |
| 365 | const mca::CodeRegions &Regions = *RegionsOrErr; |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 366 | if (Regions.empty()) { |
Jonas Devlieghere | 6adef09 | 2018-04-18 15:26:51 +0000 | [diff] [blame] | 367 | WithColor::error() << "no assembly instructions found.\n"; |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 368 | return 1; |
| 369 | } |
| 370 | |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 371 | // Now initialize the output file. |
| 372 | auto OF = getOutputStream(); |
| 373 | if (std::error_code EC = OF.getError()) { |
Jonas Devlieghere | 6adef09 | 2018-04-18 15:26:51 +0000 | [diff] [blame] | 374 | WithColor::error() << EC.message() << '\n'; |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 375 | return 1; |
| 376 | } |
| 377 | |
Matt Davis | 23f7106 | 2018-11-07 19:20:04 +0000 | [diff] [blame] | 378 | unsigned AssemblerDialect = CRG.getAssemblerDialect(); |
Andrea Di Biagio | 0626864 | 2018-04-24 16:19:08 +0000 | [diff] [blame] | 379 | if (OutputAsmVariant >= 0) |
| 380 | AssemblerDialect = static_cast<unsigned>(OutputAsmVariant); |
| 381 | std::unique_ptr<MCInstPrinter> IP(TheTarget->createMCInstPrinter( |
| 382 | Triple(TripleName), AssemblerDialect, *MAI, *MCII, *MRI)); |
| 383 | if (!IP) { |
| 384 | WithColor::error() |
| 385 | << "unable to create instruction printer for target triple '" |
| 386 | << TheTriple.normalize() << "' with assembly variant " |
| 387 | << AssemblerDialect << ".\n"; |
| 388 | return 1; |
| 389 | } |
| 390 | |
Matt Davis | 08b64d6 | 2018-11-08 17:32:45 +0000 | [diff] [blame] | 391 | std::unique_ptr<ToolOutputFile> TOF = std::move(*OF); |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 392 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 393 | const MCSchedModel &SM = STI->getSchedModel(); |
| 394 | |
Andrea Di Biagio | b5088da | 2018-03-23 11:50:43 +0000 | [diff] [blame] | 395 | // Create an instruction builder. |
Andrea Di Biagio | 4506067 | 2018-12-17 14:00:37 +0000 | [diff] [blame] | 396 | mca::InstrBuilder IB(*STI, *MCII, *MRI, MCIA.get()); |
Andrea Di Biagio | b5088da | 2018-03-23 11:50:43 +0000 | [diff] [blame] | 397 | |
Matt Davis | 362ea5f | 2018-07-06 18:03:14 +0000 | [diff] [blame] | 398 | // Create a context to control ownership of the pipeline hardware. |
| 399 | mca::Context MCA(*MRI, *STI); |
| 400 | |
Andrea Di Biagio | e074ac6 | 2019-03-29 12:15:37 +0000 | [diff] [blame] | 401 | mca::PipelineOptions PO(MicroOpQueue, DecoderThroughput, DispatchWidth, |
| 402 | RegisterFileSize, LoadQueueSize, StoreQueueSize, |
| 403 | AssumeNoAlias, EnableBottleneckAnalysis); |
Matt Davis | 362ea5f | 2018-07-06 18:03:14 +0000 | [diff] [blame] | 404 | |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 405 | // Number each region in the sequence. |
| 406 | unsigned RegionIdx = 0; |
Andrea Di Biagio | 84d0051 | 2018-10-26 10:48:04 +0000 | [diff] [blame] | 407 | |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 408 | for (const std::unique_ptr<mca::CodeRegion> &Region : Regions) { |
| 409 | // Skip empty code regions. |
| 410 | if (Region->empty()) |
| 411 | continue; |
Andrea Di Biagio | ff9c109 | 2018-03-26 13:44:54 +0000 | [diff] [blame] | 412 | |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 413 | // Don't print the header of this region if it is the default region, and |
| 414 | // it doesn't have an end location. |
| 415 | if (Region->startLoc().isValid() || Region->endLoc().isValid()) { |
| 416 | TOF->os() << "\n[" << RegionIdx++ << "] Code Region"; |
| 417 | StringRef Desc = Region->getDescription(); |
| 418 | if (!Desc.empty()) |
| 419 | TOF->os() << " - " << Desc; |
| 420 | TOF->os() << "\n\n"; |
Andrea Di Biagio | ff9c109 | 2018-03-26 13:44:54 +0000 | [diff] [blame] | 421 | } |
| 422 | |
Andrea Di Biagio | df4d65d | 2018-10-29 13:29:22 +0000 | [diff] [blame] | 423 | // Lower the MCInst sequence into an mca::Instruction sequence. |
Andrea Di Biagio | 84d0051 | 2018-10-26 10:48:04 +0000 | [diff] [blame] | 424 | ArrayRef<MCInst> Insts = Region->getInstructions(); |
Andrea Di Biagio | df4d65d | 2018-10-29 13:29:22 +0000 | [diff] [blame] | 425 | std::vector<std::unique_ptr<mca::Instruction>> LoweredSequence; |
| 426 | for (const MCInst &MCI : Insts) { |
Matt Davis | 08b64d6 | 2018-11-08 17:32:45 +0000 | [diff] [blame] | 427 | Expected<std::unique_ptr<mca::Instruction>> Inst = |
Matt Davis | 9e64a4c | 2018-10-31 17:47:25 +0000 | [diff] [blame] | 428 | IB.createInstruction(MCI); |
Andrea Di Biagio | df4d65d | 2018-10-29 13:29:22 +0000 | [diff] [blame] | 429 | if (!Inst) { |
Matt Davis | 9e64a4c | 2018-10-31 17:47:25 +0000 | [diff] [blame] | 430 | if (auto NewE = handleErrors( |
| 431 | Inst.takeError(), |
| 432 | [&IP, &STI](const mca::InstructionError<MCInst> &IE) { |
| 433 | std::string InstructionStr; |
| 434 | raw_string_ostream SS(InstructionStr); |
| 435 | WithColor::error() << IE.Message << '\n'; |
| 436 | IP->printInst(&IE.Inst, SS, "", *STI); |
| 437 | SS.flush(); |
| 438 | WithColor::note() << "instruction: " << InstructionStr |
| 439 | << '\n'; |
| 440 | })) { |
Andrea Di Biagio | df4d65d | 2018-10-29 13:29:22 +0000 | [diff] [blame] | 441 | // Default case. |
| 442 | WithColor::error() << toString(std::move(NewE)); |
| 443 | } |
| 444 | return 1; |
| 445 | } |
| 446 | |
| 447 | LoweredSequence.emplace_back(std::move(Inst.get())); |
| 448 | } |
| 449 | |
Matt Davis | 9e64a4c | 2018-10-31 17:47:25 +0000 | [diff] [blame] | 450 | mca::SourceMgr S(LoweredSequence, PrintInstructionTables ? 1 : Iterations); |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 451 | |
| 452 | if (PrintInstructionTables) { |
Matt Davis | 0e8402e | 2018-07-14 23:52:50 +0000 | [diff] [blame] | 453 | // Create a pipeline, stages, and a printer. |
Matt Davis | 9e71970 | 2018-11-08 18:08:43 +0000 | [diff] [blame] | 454 | auto P = llvm::make_unique<mca::Pipeline>(); |
| 455 | P->appendStage(llvm::make_unique<mca::EntryStage>(S)); |
| 456 | P->appendStage(llvm::make_unique<mca::InstructionTables>(SM)); |
Matt Davis | 0e8402e | 2018-07-14 23:52:50 +0000 | [diff] [blame] | 457 | mca::PipelinePrinter Printer(*P); |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 458 | |
Matt Davis | 0e8402e | 2018-07-14 23:52:50 +0000 | [diff] [blame] | 459 | // Create the views for this pipeline, execute, and emit a report. |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 460 | if (PrintInstructionInfoView) { |
Matt Davis | 9e71970 | 2018-11-08 18:08:43 +0000 | [diff] [blame] | 461 | Printer.addView(llvm::make_unique<mca::InstructionInfoView>( |
| 462 | *STI, *MCII, Insts, *IP)); |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 463 | } |
Matt Davis | 9e71970 | 2018-11-08 18:08:43 +0000 | [diff] [blame] | 464 | Printer.addView( |
| 465 | llvm::make_unique<mca::ResourcePressureView>(*STI, *IP, Insts)); |
Andrea Di Biagio | 083addf | 2018-10-24 10:56:47 +0000 | [diff] [blame] | 466 | |
Andrea Di Biagio | df4d65d | 2018-10-29 13:29:22 +0000 | [diff] [blame] | 467 | if (!runPipeline(*P)) |
Andrea Di Biagio | 083addf | 2018-10-24 10:56:47 +0000 | [diff] [blame] | 468 | return 1; |
| 469 | |
Matt Davis | 0e8402e | 2018-07-14 23:52:50 +0000 | [diff] [blame] | 470 | Printer.printReport(TOF->os()); |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 471 | continue; |
| 472 | } |
| 473 | |
Matt Davis | 362ea5f | 2018-07-06 18:03:14 +0000 | [diff] [blame] | 474 | // Create a basic pipeline simulating an out-of-order backend. |
| 475 | auto P = MCA.createDefaultPipeline(PO, IB, S); |
Matt Davis | dea343d | 2018-06-25 16:53:00 +0000 | [diff] [blame] | 476 | mca::PipelinePrinter Printer(*P); |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 477 | |
Roman Lebedev | 9ddf128 | 2018-06-15 14:01:43 +0000 | [diff] [blame] | 478 | if (PrintSummaryView) |
Matt Davis | 6c5a49c | 2019-03-07 19:34:44 +0000 | [diff] [blame] | 479 | Printer.addView(llvm::make_unique<mca::SummaryView>( |
Andrea Di Biagio | ddce32e | 2019-03-26 15:38:37 +0000 | [diff] [blame] | 480 | SM, Insts, DispatchWidth, EnableBottleneckAnalysis)); |
Roman Lebedev | 9ddf128 | 2018-06-15 14:01:43 +0000 | [diff] [blame] | 481 | |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 482 | if (PrintInstructionInfoView) |
| 483 | Printer.addView( |
Matt Davis | 9e71970 | 2018-11-08 18:08:43 +0000 | [diff] [blame] | 484 | llvm::make_unique<mca::InstructionInfoView>(*STI, *MCII, Insts, *IP)); |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 485 | |
Andrea Di Biagio | 821f650 | 2018-04-10 14:55:14 +0000 | [diff] [blame] | 486 | if (PrintDispatchStats) |
Matt Davis | 9e71970 | 2018-11-08 18:08:43 +0000 | [diff] [blame] | 487 | Printer.addView(llvm::make_unique<mca::DispatchStatistics>()); |
Andrea Di Biagio | 821f650 | 2018-04-10 14:55:14 +0000 | [diff] [blame] | 488 | |
Andrea Di Biagio | f41ad5c | 2018-04-11 12:12:53 +0000 | [diff] [blame] | 489 | if (PrintSchedulerStats) |
Matt Davis | 9e71970 | 2018-11-08 18:08:43 +0000 | [diff] [blame] | 490 | Printer.addView(llvm::make_unique<mca::SchedulerStatistics>(*STI)); |
Andrea Di Biagio | 1cc29c0 | 2018-04-11 11:37:46 +0000 | [diff] [blame] | 491 | |
Andrea Di Biagio | f41ad5c | 2018-04-11 12:12:53 +0000 | [diff] [blame] | 492 | if (PrintRetireStats) |
Andrea Di Biagio | 07a8255 | 2018-11-23 12:12:57 +0000 | [diff] [blame] | 493 | Printer.addView(llvm::make_unique<mca::RetireControlUnitStatistics>(SM)); |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 494 | |
| 495 | if (PrintRegisterFileStats) |
Matt Davis | 9e71970 | 2018-11-08 18:08:43 +0000 | [diff] [blame] | 496 | Printer.addView(llvm::make_unique<mca::RegisterFileStatistics>(*STI)); |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 497 | |
| 498 | if (PrintResourcePressureView) |
Matt Davis | 9e71970 | 2018-11-08 18:08:43 +0000 | [diff] [blame] | 499 | Printer.addView( |
| 500 | llvm::make_unique<mca::ResourcePressureView>(*STI, *IP, Insts)); |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 501 | |
| 502 | if (PrintTimelineView) { |
Andrea Di Biagio | 84d0051 | 2018-10-26 10:48:04 +0000 | [diff] [blame] | 503 | unsigned TimelineIterations = |
| 504 | TimelineMaxIterations ? TimelineMaxIterations : 10; |
Matt Davis | 9e71970 | 2018-11-08 18:08:43 +0000 | [diff] [blame] | 505 | Printer.addView(llvm::make_unique<mca::TimelineView>( |
Andrea Di Biagio | 84d0051 | 2018-10-26 10:48:04 +0000 | [diff] [blame] | 506 | *STI, *IP, Insts, std::min(TimelineIterations, S.getNumIterations()), |
| 507 | TimelineMaxCycles)); |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 508 | } |
| 509 | |
Andrea Di Biagio | df4d65d | 2018-10-29 13:29:22 +0000 | [diff] [blame] | 510 | if (!runPipeline(*P)) |
Andrea Di Biagio | 083addf | 2018-10-24 10:56:47 +0000 | [diff] [blame] | 511 | return 1; |
| 512 | |
Andrea Di Biagio | c659012 | 2018-04-09 16:39:52 +0000 | [diff] [blame] | 513 | Printer.printReport(TOF->os()); |
Andrea Di Biagio | 9b3cb08 | 2018-07-02 20:39:57 +0000 | [diff] [blame] | 514 | |
| 515 | // Clear the InstrBuilder internal state in preparation for another round. |
| 516 | IB.clear(); |
Andrea Di Biagio | d156929 | 2018-03-26 12:04:53 +0000 | [diff] [blame] | 517 | } |
| 518 | |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 519 | TOF->keep(); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 520 | return 0; |
| 521 | } |