Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM 14 #106

Merged
merged 1 commit into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 3 additions & 1 deletion doc/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ Ubuntu 20.04:
Configuring the Build
*********************

You can pass ``-DLLVM_MAJOR_VERSION=10`` to CMake to build against LLVM 10.
You can pass ``-DLLVM_MAJOR_VERSION=<MAJOR_VERSION_NUMBER>`` to CMake to build
against a specific version of LLVM. See :ref:`LLVM Library Version <llvmver>`
for supported versions.

Building the Fact Generator
***************************
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
3 changes: 2 additions & 1 deletion doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Pre-built Debian packages are available from the `releases page`_.
You can download Docker images from GHCR or them build yourself; see
:doc:`docker`.

If you need to use LLVM 10, you'll have to build from source. See :doc:`build`.
If you need to use a older version of LLVM, you'll have to build from source.
See :doc:`build`.

.. _releases page: https://github.com/GaloisInc/cclyzerpp/releases
17 changes: 10 additions & 7 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 @@ -101,20 +101,23 @@ Versioning
Since v0.4.0, cclyzer++ has attempted to follow `semantic versioning 2.0.0
<semver>`_.

.. _llvmver:

LLVM Library Version
********************

.. TODO(lb): Policy for supporting different LLVM versions

cclyzer++ currently builds against LLVM 13 by default and can be built with
LLVM 10. There are `plans <llvmver>`_ to support recent versions.
cclyzer++ currently builds against LLVM 14 by default and can be built with
previous versions 13 through 10. There are `plans <llvmver>`_ to support
LLVM 15.

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

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

.. _tutorial: http://yanniss.github.io/points-to-tutorial15.pdf
.. _llvmver: https://github.com/GaloisInc/cclyzerpp/issues/12
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
2 changes: 1 addition & 1 deletion scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
set -eo pipefail

for f in ./src/*.cpp ./FactGenerator/**/*.cpp; do
clang-format-10 -i "${f}"
clang-format-14 -i "${f}"
done
Loading