Commit d1fbcb11 authored by Alastair Robertson's avatar Alastair Robertson

Upgrade to use LLVM 5

parent c9366aed
......@@ -27,7 +27,7 @@ To use some BPFtrace features, minimum kernel versions are required:
- CMake
- Flex
- Bison
- LLVM 3.9 development packages
- LLVM 5.0 development packages
- LibElf
### Compilation
......
......@@ -5,9 +5,9 @@ RUN apt-get update && apt-get install -y \
flex \
g++ \
git \
libclang-3.9-dev \
libclang-5.0-dev \
libelf-dev \
llvm-3.9-dev \
llvm-5.0-dev \
zlib1g-dev
COPY build.sh /build.sh
......
......@@ -382,11 +382,11 @@ void CodegenLLVM::visit(Probe &probe)
{b_.getInt8PtrTy()}, // struct pt_regs *ctx
false);
Function *func = Function::Create(func_type, Function::ExternalLinkage, probe.name(), module_.get());
func->setSection(probe.name());
func->setSection("s_" + probe.name());
BasicBlock *entry = BasicBlock::Create(module_->getContext(), "entry", func);
b_.SetInsertPoint(entry);
ctx_ = &func->getArgumentList().front();
ctx_ = func->arg_begin();
if (probe.pred) {
probe.pred->accept(*this);
......@@ -590,7 +590,7 @@ void CodegenLLVM::createLog2Function()
BasicBlock *entry = BasicBlock::Create(module_->getContext(), "entry", log2_func);
b_.SetInsertPoint(entry);
Value *arg = &log2_func->getArgumentList().front();
Value *arg = log2_func->arg_begin();
Value *n_alloc = b_.CreateAllocaBPF(SizedType(Type::integer, 8));
b_.CreateStore(arg, n_alloc);
......@@ -628,8 +628,8 @@ void CodegenLLVM::createStrcmpFunction()
BasicBlock *not_equal_block = BasicBlock::Create(module_->getContext(), "strcmp.not_equal", strcmp_func);
b_.SetInsertPoint(entry);
Value *s1 = &strcmp_func->getArgumentList().front();
Value *s2 = &strcmp_func->getArgumentList().back();
Value *s1 = strcmp_func->arg_begin();
Value *s2 = strcmp_func->arg_begin()+1;
for (int i=0; i<STRING_SIZE; i++)
{
......
......@@ -49,11 +49,15 @@ AllocaInst *IRBuilderBPF::CreateAllocaBPF(llvm::Type *ty, const std::string &nam
{
Function *parent = GetInsertBlock()->getParent();
BasicBlock &entry_block = parent->getEntryBlock();
AllocaInst *alloca;
auto ip = saveIP();
if (entry_block.empty())
alloca = new AllocaInst(ty, name, &entry_block);
SetInsertPoint(&entry_block);
else
alloca = new AllocaInst(ty, name, &entry_block.front());
SetInsertPoint(&entry_block.front());
AllocaInst *alloca = CreateAlloca(ty, nullptr, name); // TODO dodgy
restoreIP(ip);
CreateLifetimeStart(alloca);
return alloca;
}
......
......@@ -189,7 +189,7 @@ void perf_event_lost(void *cb_cookie, uint64_t lost)
std::unique_ptr<AttachedProbe> BPFtrace::attach_probe(Probe &probe)
{
auto func = sections_.find(probe.prog_name);
auto func = sections_.find("s_" + probe.prog_name);
if (func == sections_.end())
{
std::cerr << "Code not generated for probe: " << probe.name << std::endl;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment