Skip to content

Commit

Permalink
Merge pull request iovisor#668 from iovisor/ast_dev
Browse files Browse the repository at this point in the history
fix build with 4.0 llvm trunk
  • Loading branch information
drzaeus77 committed Aug 19, 2016
2 parents 545008a + 959e403 commit f9ada2c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ add_library(bcc-static STATIC bpf_common.cc bpf_module.cc shared_table.cc export
set_target_properties(bcc-static PROPERTIES OUTPUT_NAME bcc)

set(llvm_raw_libs bitwriter bpfcodegen irreader linker
mcjit objcarcopts option passes nativecodegen)
mcjit objcarcopts option passes nativecodegen lto)
list(FIND LLVM_AVAILABLE_LIBS "LLVMCoverage" _llvm_coverage)
if (${_llvm_coverage} GREATER -1)
list(APPEND llvm_raw_libs coverage)
Expand Down
10 changes: 9 additions & 1 deletion src/cc/bpf_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <llvm/Support/TargetSelect.h>
#include <llvm/Transforms/IPO.h>
#include <llvm/Transforms/IPO/PassManagerBuilder.h>
#include <llvm-c/Transforms/IPO.h>

#include "exception.h"
#include "frontends/b/loader.h"
Expand Down Expand Up @@ -396,7 +397,14 @@ int BPFModule::run_pass_manager(Module &mod) {
PassManagerBuilder PMB;
PMB.OptLevel = 3;
PM.add(createFunctionInliningPass());
PM.add(createAlwaysInlinerPass());
/*
* llvm < 4.0 needs
* PM.add(createAlwaysInlinerPass());
* llvm >= 4.0 needs
* PM.add(createAlwaysInlinerLegacyPass());
* use below 'stable' workaround
*/
LLVMAddAlwaysInlinerPass(reinterpret_cast<LLVMPassManagerRef>(&PM));
PMB.populateModulePassManager(PM);
if (flags_ & 1)
PM.add(createPrintModulePass(outs()));
Expand Down

0 comments on commit f9ada2c

Please sign in to comment.