Kaynağa Gözat

Fix compile error of wamrc with llvm-13/llvm-14 (#2261)

Wenyong Huang 2 yıl önce
ebeveyn
işleme
8ef09be604

+ 5 - 1
core/iwasm/compilation/aot_llvm_extra.cpp

@@ -348,12 +348,16 @@ aot_apply_llvm_new_pass_manager(AOTCompContext *comp_ctx, LLVMModuleRef module)
         FPM.addPass(LoadStoreVectorizerPass());
 
         if (comp_ctx->enable_llvm_pgo || comp_ctx->use_prof_file) {
-            LICMOptions licm_opt;
             /* LICM pass: loop invariant code motion, attempting to remove
                as much code from the body of a loop as possible. Experiments
                show it is good to enable it when pgo is enabled. */
+#if LLVM_VERSION_MAJOR >= 15
+            LICMOptions licm_opt;
             FPM.addPass(
                 createFunctionToLoopPassAdaptor(LICMPass(licm_opt), true));
+#else
+            FPM.addPass(createFunctionToLoopPassAdaptor(LICMPass(), true));
+#endif
         }
 
         /*

+ 4 - 0
core/iwasm/compilation/aot_llvm_extra2.cpp

@@ -4,7 +4,11 @@
  */
 
 #include <llvm-c/TargetMachine.h>
+#if LLVM_VERSION_MAJOR >= 14
 #include <llvm/MC/TargetRegistry.h>
+#else
+#include <llvm/Support/TargetRegistry.h>
+#endif
 #include <llvm/Target/TargetMachine.h>
 
 #include "bh_assert.h"