From 84e2f7641457d605ccd1a26fde8826102c5c43a1 Mon Sep 17 00:00:00 2001 From: Toka Date: Fri, 12 Apr 2024 19:52:26 +0200 Subject: [PATCH 1/2] llvm 18 --- .github/workflows/run_tests.yml | 2 +- CMakeLists.txt | 4 ++-- README.md | 2 +- compiler/Runtime.cpp | 2 +- compiler/Symbolizer.cpp | 16 ++++++++-------- compiler/Symbolizer.h | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 8eb6533b..aedc742b 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -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: diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d98a9cb..3db2ba8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/README.md b/README.md index 5a6afede..7fd36cd4 100644 --- a/README.md +++ b/README.md @@ -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`. diff --git a/compiler/Runtime.cpp b/compiler/Runtime.cpp index a97b30f6..454819c7 100644 --- a/compiler/Runtime.cpp +++ b/compiler/Runtime.cpp @@ -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(); diff --git a/compiler/Symbolizer.cpp b/compiler/Symbolizer.cpp index d111c52d..1a01e1bb 100644 --- a/compiler/Symbolizer.cpp +++ b/compiler/Symbolizer.cpp @@ -89,7 +89,7 @@ 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 nullChecks; for (const auto &input : symbolicComputation.inputs) { nullChecks.push_back( @@ -149,7 +149,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; @@ -165,9 +165,9 @@ 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()), + finalExpression->addIncoming(ConstantPointerNull::get(IRB.getInt8Ty()->getPointerTo()), head); finalExpression->addIncoming( symbolicComputation.lastInstruction, @@ -384,7 +384,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); } @@ -826,11 +826,11 @@ 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(IRB.getInt8PtrTy())), + ConstantPointerNull::get(cast(IRB.getInt8Ty()->getPointerTo())), I.getIncomingBlock(incoming)); } @@ -909,7 +909,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); diff --git a/compiler/Symbolizer.h b/compiler/Symbolizer.h index 808712ee..11a7b1a8 100644 --- a/compiler/Symbolizer.h +++ b/compiler/Symbolizer.h @@ -148,7 +148,7 @@ class Symbolizer : public llvm::InstVisitor { 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 { @@ -215,7 +215,7 @@ class Symbolizer : public llvm::InstVisitor { auto *expr = getSymbolicExpression(V); if (expr == nullptr) return llvm::ConstantPointerNull::get( - llvm::IntegerType::getInt8PtrTy(V->getContext())); + llvm::IntegerType::getInt8Ty(V->getContext())->getPointerTo()); return expr; } From a0cc81bf8e7e31b31ae9bd45859815a6a9f1a6da Mon Sep 17 00:00:00 2001 From: Toka Date: Fri, 12 Apr 2024 19:58:47 +0200 Subject: [PATCH 2/2] FMT --- compiler/Symbolizer.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/compiler/Symbolizer.cpp b/compiler/Symbolizer.cpp index 1a01e1bb..41ad7ba8 100644 --- a/compiler/Symbolizer.cpp +++ b/compiler/Symbolizer.cpp @@ -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.getInt8Ty()->getPointerTo()); + auto *nullExpression = + ConstantPointerNull::get(IRB.getInt8Ty()->getPointerTo()); std::vector nullChecks; for (const auto &input : symbolicComputation.inputs) { nullChecks.push_back( @@ -167,8 +168,8 @@ void Symbolizer::shortCircuitExpressionUses() { IRB.SetInsertPoint(&tail->front()); auto *finalExpression = IRB.CreatePHI(IRB.getInt8Ty()->getPointerTo(), 2); symbolicComputation.lastInstruction->replaceAllUsesWith(finalExpression); - finalExpression->addIncoming(ConstantPointerNull::get(IRB.getInt8Ty()->getPointerTo()), - head); + finalExpression->addIncoming( + ConstantPointerNull::get(IRB.getInt8Ty()->getPointerTo()), head); finalExpression->addIncoming( symbolicComputation.lastInstruction, symbolicComputation.lastInstruction->getParent()); @@ -826,11 +827,13 @@ void Symbolizer::visitPHINode(PHINode &I) { IRBuilder<> IRB(&I); unsigned numIncomingValues = I.getNumIncomingValues(); - auto *exprPHI = IRB.CreatePHI(IRB.getInt8Ty()->getPointerTo(), 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(IRB.getInt8Ty()->getPointerTo())), + ConstantPointerNull::get( + cast(IRB.getInt8Ty()->getPointerTo())), I.getIncomingBlock(incoming)); }