Skip to content

Commit c30cb5f

Browse files
authored
Add more CallSite.h Cloning.h compatibility for LLVM 11 used in McSema (#482)
1 parent 641e9b2 commit c30cb5f

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

include/remill/BC/Compat/CallSite.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ namespace remill::compat::llvm {
4848
using parent::getCalledValue;
4949
using parent::getCalledFunction;
5050
using parent::setCalledFunction;
51+
using parent::getInstruction;
5152
};
5253

5354
} // namespace remill::compat::llvm
5455

5556
#else
5657

5758
#include <llvm/IR/AbstractCallSite.h>
59+
#include <llvm/Analysis/InlineCost.h>
60+
#include <llvm/Transforms/Utils/Cloning.h>
5861
namespace remill::compat::llvm {
5962

6063
struct CallSite {
@@ -83,7 +86,7 @@ namespace remill::compat::llvm {
8386
return cb->getCalledOperand();
8487
}
8588

86-
::llvm::Function *getCalledFunction() {
89+
::llvm::Function *getCalledFunction() const {
8790
if ( !*this) {
8891
return nullptr;
8992
}
@@ -97,6 +100,10 @@ namespace remill::compat::llvm {
97100
operator bool() const {
98101
return cb;
99102
}
103+
104+
::llvm::CallBase *getInstruction() {
105+
return cb;
106+
}
100107
};
101108

102109
} // namespace remill::compat::llvm

include/remill/BC/Compat/Cloning.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2021 Trail of Bits, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#pragma once
17+
18+
#include "remill/BC/Version.h"
19+
20+
/* This compatibility relates to the changes made in CallSite.h.
21+
*/
22+
23+
#if LLVM_VERSION_NUMBER >= LLVM_VERSION(11, 0)
24+
25+
#include <llvm/IR/AbstractCallSite.h>
26+
#include <llvm/Analysis/InlineCost.h>
27+
#include <llvm/Transforms/Utils/Cloning.h>
28+
29+
namespace llvm {
30+
31+
inline static InlineResult InlineFunction(CallBase *CB, InlineFunctionInfo &IFI,
32+
AAResults *CalleeAAR = nullptr,
33+
bool InsertLifetime = true,
34+
Function *ForwardVarArgsTo = nullptr) {
35+
return InlineFunction(*CB, IFI, CalleeAAR, InsertLifetime, ForwardVarArgsTo);
36+
}
37+
38+
} // namespace llvm
39+
40+
#endif

0 commit comments

Comments
 (0)