Skip to content

Commit e64680a

Browse files
committed
Address comments
1 parent 2a0483f commit e64680a

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,18 @@ static void handleLLVMFatalError(void *, const char *Message, bool) {
115115
extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize(int *argc,
116116
char ***argv) {
117117
EnableDebugBuffering = true;
118+
StringRef ExecName = *argv[0];
118119

119120
InitializeAllTargets();
120121
InitializeAllTargetMCs();
121122
InitializeAllAsmPrinters();
122123
InitializeAllAsmParsers();
123124

124-
handleExecNameEncodedBEOpts(*argv[0]);
125+
handleExecNameEncodedBEOpts(ExecName);
125126
parseFuzzerCLOpts(*argc, *argv);
126127

127-
std::string execName = *argv[0];
128-
129128
if (TargetTriple.empty()) {
130-
errs() << execName << ": -mtriple must be specified\n";
129+
errs() << ExecName << ": -mtriple must be specified\n";
131130
exit(1);
132131
}
133132

@@ -137,10 +136,10 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize(int *argc,
137136
if (auto Level = CodeGenOpt::parseLevel(OptLevel)) {
138137
OLvl = *Level;
139138
} else {
140-
errs() << execName << ": invalid optimization level.\n";
139+
errs() << ExecName << ": invalid optimization level.\n";
141140
return 1;
142141
}
143-
ExitOnError ExitOnErr(std::string(execName) + ": error:");
142+
ExitOnError ExitOnErr(std::string(ExecName) + ": error:");
144143
TM = ExitOnErr(codegen::createTargetMachineForTriple(
145144
Triple::normalize(TargetTriple), OLvl));
146145
assert(TM && "Could not allocate target machine!");

llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ static void handleLLVMFatalError(void *, const char *Message, bool) {
175175
extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize(int *argc,
176176
char ***argv) {
177177
EnableDebugBuffering = true;
178+
StringRef ExecName = *argv[0];
178179

179180
// Make sure we print the summary and the current unit when LLVM errors out.
180181
install_fatal_error_handler(handleLLVMFatalError, nullptr);
@@ -188,32 +189,31 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize(int *argc,
188189
// Parse input options
189190
//
190191

191-
handleExecNameEncodedOptimizerOpts(*argv[0]);
192+
handleExecNameEncodedOptimizerOpts(ExecName);
192193
parseFuzzerCLOpts(*argc, *argv);
193194

194195
// Create TargetMachine
195196
//
196-
std::string execName = *argv[0];
197197
if (TargetTripleStr.empty()) {
198-
errs() << execName << ": -mtriple must be specified\n";
198+
errs() << ExecName << ": -mtriple must be specified\n";
199199
exit(1);
200200
}
201-
ExitOnError ExitOnErr(std::string(execName) + ": error:");
201+
ExitOnError ExitOnErr(std::string(ExecName) + ": error:");
202202
TM = ExitOnErr(codegen::createTargetMachineForTriple(
203203
Triple::normalize(TargetTripleStr)));
204204

205205
// Check that pass pipeline is specified and correct
206206
//
207207

208208
if (PassPipeline.empty()) {
209-
errs() << execName << ": at least one pass should be specified\n";
209+
errs() << ExecName << ": at least one pass should be specified\n";
210210
exit(1);
211211
}
212212

213213
PassBuilder PB(TM.get());
214214
ModulePassManager MPM;
215215
if (auto Err = PB.parsePassPipeline(MPM, PassPipeline)) {
216-
errs() << execName << ": " << toString(std::move(Err)) << "\n";
216+
errs() << ExecName << ": " << toString(std::move(Err)) << "\n";
217217
exit(1);
218218
}
219219

0 commit comments

Comments
 (0)