Skip to content

Commit

Permalink
LLVM 14
Browse files Browse the repository at this point in the history
  • Loading branch information
langston-barrett committed Oct 27, 2022
1 parent cbae615 commit 7d03d8b
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 17 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ env:
# will error - we use Clang to compile test programs, and cclyzer++ must be
# able to read the bitcode it outputs. We currently only run tests with the
# most recent (matching) Clang/LLVM combination.
LLVM_MAJOR_VERSION: "13"
CLANG_VERSION: "13"
LLVM_MAJOR_VERSION: "14"
CLANG_VERSION: "14"
UBUNTU_VERSION: "22.04"
UBUNTU_NAME: "jammy"

Expand Down Expand Up @@ -58,7 +58,12 @@ jobs:
llvm_version: "12"
ubuntu_version: "20.04"
ubuntu_name: "focal"
- llvm_version: "13"
- clang_version: "14"
llvm_version: "13"
ubuntu_version: "22.04"
ubuntu_name: "jammy"
- clang_version: "14"
llvm_version: "14"
ubuntu_version: "22.04"
ubuntu_name: "jammy"
env:
Expand Down Expand Up @@ -115,7 +120,7 @@ jobs:

- name: Run tests
# See NOTE[Clang+LLVM]
if: ${{ env.LLVM_MAJOR_VERSION == 13 }}
if: ${{ env.LLVM_MAJOR_VERSION == 14 }}
run: |
# See previous comment
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ project(cclyzer++ LANGUAGES C CXX VERSION 0.5.0)
# -----------------------------------------------------------------------------

if(NOT (DEFINED LLVM_MAJOR_VERSION))
set(LLVM_MAJOR_VERSION 13)
set(LLVM_MAJOR_VERSION 14)
endif()

find_package(LLVM ${LLVM_MAJOR_VERSION}.0 REQUIRED CONFIG)
Expand Down
9 changes: 5 additions & 4 deletions FactGenerator/src/ContextManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <llvm/IR/Module.h>
#include <llvm/IR/Value.h>

#include <map>
#include <sstream>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -43,7 +44,7 @@ class ContextManager {
using const_reverse_iterator = std::vector<context>::const_reverse_iterator;

ContextManager(const llvm::Module& module, const std::string& path)
: iFunctionCtx(-1), mod(module), instrIndex(0), constantIndex(0) {
: mod(module) {
// Compute global prefix for this module
std::stringstream prefix;
prefix << '<' << path << '>' << std::flush;
Expand Down Expand Up @@ -123,14 +124,14 @@ class ContextManager {
std::vector<Context> contexts;

// The vector index containing a function context
int iFunctionCtx;
int iFunctionCtx{-1};

// Current module and path
const llvm::Module& mod;

// Instruction and constant indices
unsigned instrIndex;
unsigned constantIndex;
unsigned instrIndex{0};
unsigned constantIndex{0};
};
} // end of namespace cclyzer

Expand Down
8 changes: 8 additions & 0 deletions FactGenerator/src/InstructionVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,11 @@ void InstructionVisitor::visitInvokeInst(const llvm::InvokeInst &II) {
writeInstrOperand(pred::invoke::func_operand, iref, invokeOp);

// actual args
#if LLVM_VERSION_MAJOR > 13
for (unsigned op = 0; op < II.arg_size(); ++op)
#else
for (unsigned op = 0; op < II.getNumArgOperands(); ++op)
#endif
writeInstrOperand(pred::invoke::arg, iref, II.getArgOperand(op), op);

writeInstrOperand(pred::invoke::normal_label, iref, II.getNormalDest());
Expand Down Expand Up @@ -544,7 +548,11 @@ void InstructionVisitor::visitCallInst(const llvm::CallInst &CI) {
// call instruction function (also records type)
writeInstrOperand(pred::call::func_operand, iref, callOp);

#if LLVM_VERSION_MAJOR > 13
for (unsigned op = 0; op < CI.arg_size(); ++op)
#else
for (unsigned op = 0; op < CI.getNumArgOperands(); ++op)
#endif
writeInstrOperand(pred::call::arg, iref, CI.getArgOperand(op), op);

if (CI.isTailCall()) gen.writeFact(pred::call::tail_opt, iref);
Expand Down
5 changes: 5 additions & 0 deletions FactGenerator/src/constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ void FactGenerator::writeConstantExpr(
pred::ptrtoint_constant_expr::from_ptr_constant, refmode, opref);
break;
}

#if LLVM_VERSION_MAJOR > 13
} else if (expr.getOpcode() == llvm::Instruction::GetElementPtr) {
#else
} else if (expr.isGEPWithNoNotionalOverIndexing()) {
#endif
unsigned nOperands = expr.getNumOperands();

for (unsigned i = 0; i < nOperands; i++) {
Expand Down
2 changes: 1 addition & 1 deletion FactGenerator/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void cclyzer::factgen(

// Loop over each input file
for (FileIt it = firstFile; it != endFile; ++it) {
fs::path inputFile = *it;
const fs::path &inputFile = *it;

// Parse input file
std::unique_ptr<llvm::Module> module =
Expand Down
2 changes: 1 addition & 1 deletion doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ next
Changed
~~~~~~~

- cclyzer++ now builds against (and requires) LLVM 13. See :doc:`build` for how
- cclyzer++ now builds against (and requires) LLVM 14. See :doc:`build` for how
to build against other versions of LLVM.

`v0.5.0`_ - 2022-10-21
Expand Down
8 changes: 4 additions & 4 deletions doc/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ other external libraries. Such models are crucial for soundness. See
Language Support
----------------

cclyzer++ has primarily been tested on LLVM code produced by Clang 10 through 13
cclyzer++ has primarily been tested on LLVM code produced by Clang 10 through 14
when compiling from C and C++ for x86_64. Your mileage may vary with other
languages, compilers, and targets.

Expand All @@ -66,7 +66,7 @@ Comparison to cclyzer
As mentioned above, cclyzer++ is based on cclyzer. The major differences are that
cclyzer++

* supports LLVM 10 through 13
* supports LLVM 10 through 14
* is implemented in Soufflé rather than LogicBlox
* has :ref:`a C++ interface <cpp>`, rather than a Python one
* has runtime-configurable context-sensitivity and heap-cloning
Expand Down Expand Up @@ -106,13 +106,13 @@ LLVM Library Version

.. TODO(lb): Policy for supporting different LLVM versions
cclyzer++ currently builds against LLVM 13 by default and can be built with
cclyzer++ currently builds against LLVM 14 by default and can be built with
LLVM 10. There are `plans <llvmver>`_ to support recent versions.

Development Tools
*****************

cclyzer++ currently builds with Clang 13 (including other Clang tools such as
cclyzer++ currently builds with Clang 14 (including other Clang tools such as
clang-format and clang-tidy). There are `plans <llvmver>`_ to build with more
recent versions of Clang.

Expand Down
4 changes: 2 additions & 2 deletions docker/dev.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ARG UBUNTU_NAME=jammy
ARG UBUNTU_VERSION=22.04
FROM ubuntu:$UBUNTU_VERSION as dev
# See NOTE[Clang+LLVM] in ci.yml
ARG CLANG_VERSION=13
ARG LLVM_MAJOR_VERSION=13
ARG CLANG_VERSION=14
ARG LLVM_MAJOR_VERSION=14
# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG UBUNTU_NAME
ARG UBUNTU_VERSION
Expand Down

0 comments on commit 7d03d8b

Please sign in to comment.