Skip to content

Commit

Permalink
LLVM 18 update (#167)
Browse files Browse the repository at this point in the history
Update to support LLVM 18
  • Loading branch information
tokatoka authored Apr 12, 2024
1 parent 3f98002 commit fc437b5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
llvm_version: [16, 17]
llvm_version: [16, 17, 18]
steps:
- uses: actions/checkout@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake from ${LLVM_DIR}")

if (${LLVM_VERSION_MAJOR} LESS 8 OR ${LLVM_VERSION_MAJOR} GREATER 17)
message(WARNING "The software has been developed for LLVM 8 through 17; \
if (${LLVM_VERSION_MAJOR} LESS 8 OR ${LLVM_VERSION_MAJOR} GREATER 18)
message(WARNING "The software has been developed for LLVM 8 through 18; \
it is unlikely to work with other versions!")
endif()

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ program. The actual computation happens through calls to the support library at
run time.

To build the pass and the support library, install LLVM (any version between 8
and 17) and Z3 (version 4.5 or later), as well as a C++ compiler with support
and 18) and Z3 (version 4.5 or later), as well as a C++ compiler with support
for C++17. LLVM lit is only needed to run the tests; if it's not packaged with
your LLVM, you can get it with `pip install lit`.

Expand Down
2 changes: 1 addition & 1 deletion compiler/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SymFnT import(llvm::Module &M, llvm::StringRef name, llvm::Type *ret,
Runtime::Runtime(Module &M) {
IRBuilder<> IRB(M.getContext());
auto *intPtrType = M.getDataLayout().getIntPtrType(M.getContext());
auto *ptrT = IRB.getInt8PtrTy();
auto *ptrT = IRB.getInt8Ty()->getPointerTo();
auto *int8T = IRB.getInt8Ty();
auto *int1T = IRB.getInt1Ty();
auto *voidT = IRB.getVoidTy();
Expand Down
21 changes: 12 additions & 9 deletions compiler/Symbolizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ void Symbolizer::shortCircuitExpressionUses() {

// Build the check whether any input expression is non-null (i.e., there
// is a symbolic input).
auto *nullExpression = ConstantPointerNull::get(IRB.getInt8PtrTy());
auto *nullExpression =
ConstantPointerNull::get(IRB.getInt8Ty()->getPointerTo());
std::vector<Value *> nullChecks;
for (const auto &input : symbolicComputation.inputs) {
nullChecks.push_back(
Expand Down Expand Up @@ -149,7 +150,7 @@ void Symbolizer::shortCircuitExpressionUses() {
Value *finalArgExpression;
if (needRuntimeCheck) {
IRB.SetInsertPoint(symbolicComputation.firstInstruction);
auto *argPHI = IRB.CreatePHI(IRB.getInt8PtrTy(), 2);
auto *argPHI = IRB.CreatePHI(IRB.getInt8Ty()->getPointerTo(), 2);
argPHI->addIncoming(originalArgExpression, argCheckBlock);
argPHI->addIncoming(newArgExpression, newArgExpression->getParent());
finalArgExpression = argPHI;
Expand All @@ -165,10 +166,10 @@ void Symbolizer::shortCircuitExpressionUses() {
// if short-circuiting wasn't possible.
if (!symbolicComputation.lastInstruction->use_empty()) {
IRB.SetInsertPoint(&tail->front());
auto *finalExpression = IRB.CreatePHI(IRB.getInt8PtrTy(), 2);
auto *finalExpression = IRB.CreatePHI(IRB.getInt8Ty()->getPointerTo(), 2);
symbolicComputation.lastInstruction->replaceAllUsesWith(finalExpression);
finalExpression->addIncoming(ConstantPointerNull::get(IRB.getInt8PtrTy()),
head);
finalExpression->addIncoming(
ConstantPointerNull::get(IRB.getInt8Ty()->getPointerTo()), head);
finalExpression->addIncoming(
symbolicComputation.lastInstruction,
symbolicComputation.lastInstruction->getParent());
Expand Down Expand Up @@ -384,7 +385,7 @@ void Symbolizer::handleFunctionCall(CallBase &I, Instruction *returnPoint) {
// previous function call. (If the function is instrumented, it will just
// override our null with the real expression.)
IRB.CreateCall(runtime.setReturnExpression,
ConstantPointerNull::get(IRB.getInt8PtrTy()));
ConstantPointerNull::get(IRB.getInt8Ty()->getPointerTo()));
IRB.SetInsertPoint(returnPoint);
symbolicExpressions[&I] = IRB.CreateCall(runtime.getReturnExpression);
}
Expand Down Expand Up @@ -826,11 +827,13 @@ void Symbolizer::visitPHINode(PHINode &I) {

IRBuilder<> IRB(&I);
unsigned numIncomingValues = I.getNumIncomingValues();
auto *exprPHI = IRB.CreatePHI(IRB.getInt8PtrTy(), numIncomingValues);
auto *exprPHI =
IRB.CreatePHI(IRB.getInt8Ty()->getPointerTo(), numIncomingValues);
for (unsigned incoming = 0; incoming < numIncomingValues; incoming++) {
exprPHI->addIncoming(
// The null pointer will be replaced in finalizePHINodes.
ConstantPointerNull::get(cast<PointerType>(IRB.getInt8PtrTy())),
ConstantPointerNull::get(
cast<PointerType>(IRB.getInt8Ty()->getPointerTo())),
I.getIncomingBlock(incoming));
}

Expand Down Expand Up @@ -909,7 +912,7 @@ void Symbolizer::visitSwitchInst(SwitchInst &I) {

// Build a check whether we have a symbolic condition, to be used later.
auto *haveSymbolicCondition = IRB.CreateICmpNE(
conditionExpr, ConstantPointerNull::get(IRB.getInt8PtrTy()));
conditionExpr, ConstantPointerNull::get(IRB.getInt8Ty()->getPointerTo()));
auto *constraintBlock = SplitBlockAndInsertIfThen(haveSymbolicCondition, &I,
/* unreachable */ false);

Expand Down
4 changes: 2 additions & 2 deletions compiler/Symbolizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class Symbolizer : public llvm::InstVisitor<Symbolizer> {
Input(llvm::Value *concrete, unsigned idx, llvm::Instruction *user)
: concreteValue(concrete), operandIndex(idx), user(user) {
assert(getSymbolicOperand()->getType() ==
llvm::Type::getInt8PtrTy(user->getContext()));
llvm::Type::getInt8Ty(user->getContext())->getPointerTo());
}

llvm::Value *getSymbolicOperand() const {
Expand Down Expand Up @@ -215,7 +215,7 @@ class Symbolizer : public llvm::InstVisitor<Symbolizer> {
auto *expr = getSymbolicExpression(V);
if (expr == nullptr)
return llvm::ConstantPointerNull::get(
llvm::IntegerType::getInt8PtrTy(V->getContext()));
llvm::IntegerType::getInt8Ty(V->getContext())->getPointerTo());
return expr;
}

Expand Down

0 comments on commit fc437b5

Please sign in to comment.