Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Commit

Permalink
Support LLVM 11 (#729)
Browse files Browse the repository at this point in the history
* Add guards based on LLVM version for 11 compatibility

* Use remill LLVM 11 compat headers

* CI support for LLVM 11
  • Loading branch information
ekilmer committed Feb 13, 2021
1 parent 36f2660 commit aa49fcc
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -25,7 +25,7 @@ jobs:
needs: [VersionFile]
strategy:
matrix:
llvm: ["900", "1000"]
llvm: ["900", "1000", "1100"]
ubuntu: ["20.04", "18.04"]
steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/vcpkg_ci.yml
Expand Up @@ -18,7 +18,8 @@ jobs:
- { name: 'ubuntu', tag: '20.04' }
llvm: [
'9',
'10'
'10',
'11'
]

runs-on: ubuntu-20.04
Expand Down Expand Up @@ -76,7 +77,8 @@ jobs:
]
llvm: [
'9',
'10'
'10',
'11'
]

runs-on: ${{ matrix.os }}
Expand Down
13 changes: 9 additions & 4 deletions mcsema/BC/Function.cpp
Expand Up @@ -25,7 +25,6 @@
#pragma clang diagnostic ignored "-Wswitch-enum"
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <llvm/IR/CallSite.h>
#include <llvm/IR/Constants.h>
#include <llvm/IR/DataLayout.h>
#include <llvm/IR/DebugInfo.h>
Expand All @@ -47,6 +46,8 @@
#include <remill/Arch/Instruction.h>
#include <remill/BC/ABI.h>
#include <remill/BC/Annotate.h>
#include <remill/BC/Compat/CallSite.h>
#include <remill/BC/Compat/Cloning.h>
#include <remill/BC/Compat/Error.h>
#include <remill/BC/Compat/ScalarTransforms.h>
#include <remill/BC/IntrinsicTable.h>
Expand Down Expand Up @@ -211,7 +212,11 @@ static llvm::Function *GetValueTracer(void) {
if (reg->type == gWordType && reg != pc_reg) {
ss << reg->name << format;
args.push_back(
#if LLVM_VERSION_NUMBER < LLVM_VERSION(11, 0)
new llvm::LoadInst(reg->AddressOf(state_ptr, block), "", block));
#else
new llvm::LoadInst(reg->type, reg->AddressOf(state_ptr, block), "", block));
#endif
}
}
ss << '\n';
Expand Down Expand Up @@ -1671,9 +1676,9 @@ static llvm::Function *LiftFunction(const NativeModule *cfg_module,
return lifted_func;
}

using Calls_t = std::vector<llvm::CallSite>;
using Calls_t = std::vector<remill::compat::llvm::CallSite>;

static bool ShouldInline(const llvm::CallSite &cs) {
static bool ShouldInline(const remill::compat::llvm::CallSite &cs) {
if (!cs) {
return false;
}
Expand All @@ -1686,7 +1691,7 @@ static Calls_t InlinableCalls(llvm::Function &func) {
Calls_t out;
for (auto &bb : func) {
for (auto &inst : bb) {
auto cs = llvm::CallSite(&inst);
auto cs = remill::compat::llvm::CallSite(&inst);
if (ShouldInline(cs)) {
out.push_back(std::move(cs));
}
Expand Down
7 changes: 6 additions & 1 deletion mcsema/BC/Optimize.cpp
Expand Up @@ -1539,7 +1539,12 @@ static void GlobalizeStateStructures(void) {
llvm::PointerType::get(itp->getType(), 0));
ptr = TryGetRegAlias(ptr, offset);
itp->replaceAllUsesWith(
new llvm::LoadInst(ptr, load->getName(), load));
#if LLVM_VERSION_NUMBER < LLVM_VERSION(11, 0)
new llvm::LoadInst(ptr, load->getName(), load)
#else
new llvm::LoadInst(ptr->getType(), ptr, load->getName(), load)
#endif
);
to_remove.push_back(itp);
}
}
Expand Down
3 changes: 3 additions & 0 deletions scripts/docker-lifter-entrypoint.sh
Expand Up @@ -56,6 +56,9 @@ case ${LLVM_VERSION} in
llvm100*)
V=10.0
;;
llvm110*)
V=11.0
;;
*)
echo "Unknown LLVM version: ${LLVM_VERSION}"
exit 1
Expand Down
4 changes: 4 additions & 0 deletions tools/mcsema_lift/Lift.cpp
Expand Up @@ -305,7 +305,11 @@ struct ABILibsLoader {

for (auto &alias : abi_lib->aliases()) {
if (auto fn = llvm::dyn_cast<llvm::Function>(alias.getAliasee())) {
#if LLVM_VERSION_NUMBER < LLVM_VERSION(11, 0)
CloneFunction(*fn, alias.getName());
#else
CloneFunction(*fn, alias.getName().str());
#endif
}
}

Expand Down

0 comments on commit aa49fcc

Please sign in to comment.