Skip to content

Commit

Permalink
Add more CallSite.h Cloning.h compatibility for LLVM 11 used in McSema (
Browse files Browse the repository at this point in the history
  • Loading branch information
ekilmer authored Feb 12, 2021
1 parent 641e9b2 commit c30cb5f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
9 changes: 8 additions & 1 deletion include/remill/BC/Compat/CallSite.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ namespace remill::compat::llvm {
using parent::getCalledValue;
using parent::getCalledFunction;
using parent::setCalledFunction;
using parent::getInstruction;
};

} // namespace remill::compat::llvm

#else

#include <llvm/IR/AbstractCallSite.h>
#include <llvm/Analysis/InlineCost.h>
#include <llvm/Transforms/Utils/Cloning.h>
namespace remill::compat::llvm {

struct CallSite {
Expand Down Expand Up @@ -83,7 +86,7 @@ namespace remill::compat::llvm {
return cb->getCalledOperand();
}

::llvm::Function *getCalledFunction() {
::llvm::Function *getCalledFunction() const {
if ( !*this) {
return nullptr;
}
Expand All @@ -97,6 +100,10 @@ namespace remill::compat::llvm {
operator bool() const {
return cb;
}

::llvm::CallBase *getInstruction() {
return cb;
}
};

} // namespace remill::compat::llvm
Expand Down
40 changes: 40 additions & 0 deletions include/remill/BC/Compat/Cloning.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2021 Trail of Bits, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once

#include "remill/BC/Version.h"

/* This compatibility relates to the changes made in CallSite.h.
*/

#if LLVM_VERSION_NUMBER >= LLVM_VERSION(11, 0)

#include <llvm/IR/AbstractCallSite.h>
#include <llvm/Analysis/InlineCost.h>
#include <llvm/Transforms/Utils/Cloning.h>

namespace llvm {

inline static InlineResult InlineFunction(CallBase *CB, InlineFunctionInfo &IFI,
AAResults *CalleeAAR = nullptr,
bool InsertLifetime = true,
Function *ForwardVarArgsTo = nullptr) {
return InlineFunction(*CB, IFI, CalleeAAR, InsertLifetime, ForwardVarArgsTo);
}

} // namespace llvm

#endif

0 comments on commit c30cb5f

Please sign in to comment.