[PATCH] D128043: [flang][driver] Add support for `-O{0|1|2|3}`

Diana Picus via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 22 05:41:52 PDT 2022


rovka added inline comments.


================
Comment at: flang/include/flang/Frontend/CodeGenOptions.def:12
+// Optionally, the user may also define ENUM_CODEGENOPT (for options
+// that have enumeration type and VALUE_CODEGENOPT is a code
+// generation option that describes a value rather than a flag.
----------------
I'm not sure I understand the difference between CODEGENOPT and VALUE_CODEGENOPT. Is it that CODEGENOPT is actually a kind of BOOL_CODEGENOPT, that should always have just 1 bit? Do we really need both?


================
Comment at: flang/include/flang/Frontend/CodeGenOptions.def:25
+
+#ifndef ENUM_CODEGENOPT
+#  define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
----------------
This isn't used yet, can we skip it?


================
Comment at: flang/include/flang/Frontend/FrontendActions.h:202
   bool beginSourceFileAction() override;
+  /// Sets up LLVM's TargetMachine, configures llvmModule accordingly
   void setUpTargetMachine();
----------------



================
Comment at: flang/lib/Frontend/FrontendActions.cpp:617
 /// \param [in] llvmModule LLVM module to lower to assembly/machine-code
 /// \param [out] os Output stream to emit the generated code to
+
----------------
Shouldn't this comment go away too?


================
Comment at: flang/lib/Frontend/FrontendActions.cpp:711
 
+  // Run LLVM's middle-end (i.e. the optimizer)
+  runOptimizationPipeline(*os);
----------------



================
Comment at: flang/lib/Frontend/FrontendActions.cpp:724
   if (action == BackendActionTy::Backend_EmitBC) {
-    generateLLVMBCImpl(*tm, *llvmModule, *os);
+    // This action has effectively been completed in runOptimizationPipeline
     return;
----------------



================
Comment at: flang/lib/Frontend/FrontendActions.cpp:728
 
+  // Run LLVM's backend and generate either assembly or machine code
   if (action == BackendActionTy::Backend_EmitAssembly ||
----------------



================
Comment at: flang/test/Driver/default-optimization-pipelines.f90:1
+! Verify that`-O{n}` is indeed taken into account when definining the LLVM optimization/middle-end pass pass pipeline.
+
----------------



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128043/new/

https://reviews.llvm.org/D128043



More information about the cfe-commits mailing list