@@ -48,10 +48,9 @@ using namespace llvm;
4848typedef void (*LLVMFunc)(int *, int *, int *, int );
4949
5050// Helper function to parse command line args and find the optimization level
51- static CodeGenOpt::Level
52- getOptLevel (const std::vector<const char *> &ExtraArgs) {
51+ static CodeGenOptLevel getOptLevel (const std::vector<const char *> &ExtraArgs) {
5352 // Find the optimization level from the command line args
54- CodeGenOpt::Level OLvl = CodeGenOpt ::Default;
53+ CodeGenOptLevel OLvl = CodeGenOptLevel ::Default;
5554 for (auto &A : ExtraArgs) {
5655 if (A[0 ] == ' -' && A[1 ] == ' O' ) {
5756 if (auto Level = CodeGenOpt::parseLevel (A[2 ])) {
@@ -73,19 +72,19 @@ static void ErrorAndExit(std::string message) {
7372// Helper function to add optimization passes to the TargetMachine at the
7473// specified optimization level, OptLevel
7574static void RunOptimizationPasses (raw_ostream &OS, Module &M,
76- CodeGenOpt::Level OptLevel) {
75+ CodeGenOptLevel OptLevel) {
7776 llvm::OptimizationLevel OL;
7877 switch (OptLevel) {
79- case CodeGenOpt ::None:
78+ case CodeGenOptLevel ::None:
8079 OL = OptimizationLevel::O0;
8180 break ;
82- case CodeGenOpt ::Less:
81+ case CodeGenOptLevel ::Less:
8382 OL = OptimizationLevel::O1;
8483 break ;
85- case CodeGenOpt ::Default:
84+ case CodeGenOptLevel ::Default:
8685 OL = OptimizationLevel::O2;
8786 break ;
88- case CodeGenOpt ::Aggressive:
87+ case CodeGenOptLevel ::Aggressive:
8988 OL = OptimizationLevel::O3;
9089 break ;
9190 }
@@ -110,7 +109,7 @@ static void RunOptimizationPasses(raw_ostream &OS, Module &M,
110109}
111110
112111// Mimics the opt tool to run an optimization pass over the provided IR
113- static std::string OptLLVM (const std::string &IR, CodeGenOpt::Level OLvl) {
112+ static std::string OptLLVM (const std::string &IR, CodeGenOptLevel OLvl) {
114113 // Create a module that will run the optimization passes
115114 SMDiagnostic Err;
116115 LLVMContext Context;
@@ -154,7 +153,7 @@ static void RunFuncOnInputs(LLVMFunc f, int Arr[kNumArrays][kArraySize]) {
154153}
155154
156155// Takes a string of IR and compiles it using LLVM's JIT Engine
157- static void CreateAndRunJITFunc (const std::string &IR, CodeGenOpt::Level OLvl) {
156+ static void CreateAndRunJITFunc (const std::string &IR, CodeGenOptLevel OLvl) {
158157 SMDiagnostic Err;
159158 LLVMContext Context;
160159 std::unique_ptr<Module> M = parseIR (MemoryBufferRef (IR, " IR" ), Err, Context);
@@ -205,7 +204,7 @@ static void CreateAndRunJITFunc(const std::string &IR, CodeGenOpt::Level OLvl) {
205204#endif
206205
207206 // Figure out if we are running the optimized func or the unoptimized func
208- RunFuncOnInputs (f, (OLvl == CodeGenOpt ::None) ? UnoptArrays : OptArrays);
207+ RunFuncOnInputs (f, (OLvl == CodeGenOptLevel ::None) ? UnoptArrays : OptArrays);
209208
210209 EE->runStaticConstructorsDestructors (true );
211210}
@@ -219,13 +218,13 @@ void clang_fuzzer::HandleLLVM(const std::string &IR,
219218 memcpy (UnoptArrays, InputArrays, kTotalSize );
220219
221220 // Parse ExtraArgs to set the optimization level
222- CodeGenOpt::Level OLvl = getOptLevel (ExtraArgs);
221+ CodeGenOptLevel OLvl = getOptLevel (ExtraArgs);
223222
224223 // First we optimize the IR by running a loop vectorizer pass
225224 std::string OptIR = OptLLVM (IR, OLvl);
226225
227226 CreateAndRunJITFunc (OptIR, OLvl);
228- CreateAndRunJITFunc (IR, CodeGenOpt ::None);
227+ CreateAndRunJITFunc (IR, CodeGenOptLevel ::None);
229228
230229 if (memcmp (OptArrays, UnoptArrays, kTotalSize ))
231230 ErrorAndExit (" !!!BUG!!!" );
0 commit comments