Skip to content

Commit

Permalink
LLVM 13, Ubuntu 22.04
Browse files Browse the repository at this point in the history
Ubuntu 20.04 doesn't appear to have apt packages for LLVM 13, so might as well
upgrade now.
  • Loading branch information
langston-barrett committed Oct 26, 2022
1 parent e332911 commit 6fde100
Show file tree
Hide file tree
Showing 250 changed files with 18,946 additions and 28,936 deletions.
36 changes: 24 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ 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: "12"
CLANG_VERSION: "12"
UBUNTU_VERSION: "20.04"
UBUNTU_NAME: "focal"
LLVM_MAJOR_VERSION: "13"
CLANG_VERSION: "13"
UBUNTU_VERSION: "22.04"
UBUNTU_NAME: "jammy"

jobs:
doc:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

Expand All @@ -42,15 +42,27 @@ jobs:
publish_dir: doc/_build/html

build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
llvm_version:
- "10"
- "11"
- "12"
include:
- llvm_version: "10"
ubuntu_version: "20.04"
ubuntu_name: "focal"
- llvm_version: "11"
ubuntu_version: "20.04"
ubuntu_name: "focal"
- llvm_version: "12"
ubuntu_version: "20.04"
ubuntu_name: "focal"
- llvm_version: "13"
ubuntu_version: "22.04"
ubuntu_name: "jammy"
env:
LLVM_MAJOR_VERSION: ${{ matrix.llvm_version }}
CLANG_VERSION: ${{ matrix.llvm_version }}
UBUNTU_VERSION: ${{ matrix.ubuntu_version }}
UBUNTU_NAME: ${{ matrix.ubuntu_name }}
steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -136,7 +148,7 @@ jobs:
./scripts/gha-docker-build "dist" "cclyzerpp-dist"
lint:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -175,7 +187,7 @@ jobs:
bash scripts/lint.sh
release:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
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 12)
set(LLVM_MAJOR_VERSION 13)
endif()

find_package(LLVM ${LLVM_MAJOR_VERSION}.0 REQUIRED CONFIG)
Expand Down
9 changes: 8 additions & 1 deletion FactGenerator/src/InstructionVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,14 @@ void InstructionVisitor::visitGetElementPtrInst(
if (const auto *c = dyn_cast<llvm::Constant>(GepOperand)) {
if (c->getUniqueInteger().isIntN(16)) {
// Compute integer string representation
string int_value = c->getUniqueInteger().toString(10, true);
// TODO(lb): Compute both signed and unsigned representations
#if LLVM_VERSION_MAJOR > 12
llvm::SmallString<16> s;
c->getUniqueInteger().toStringUnsigned(s, 10);
std::string int_value = std::string(s);
#else
std::string int_value = c->getUniqueInteger().toString(10, true);
#endif

// Write constant to integer fact
gen.writeFact(pred::constant::to_integer, opref, int_value);
Expand Down
4 changes: 2 additions & 2 deletions FactGenerator/src/Signatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ auto extract_from_array(const llvm::json::Array &json_array, size_t index)
-> llvm::Optional<std::string> {
auto val = json_array[index].getAsString();
if (val.hasValue()) {
return llvm::Optional("@" + val.getValue().str());
return {"@" + val.getValue().str()};
}
return llvm::Optional<std::string>();
return {};
}

template <typename T, typename... Ts>
Expand Down
8 changes: 7 additions & 1 deletion FactGenerator/src/constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ auto FactGenerator::writeConstant(const llvm::Constant &c)
writeFact(pred::integer_constant::id, id);
if (c.getUniqueInteger().isIntN(16)) {
// Compute integer string representation
// TODO(lb): Compute both signed and unsigned representations
#if LLVM_VERSION_MAJOR > 12
llvm::SmallString<16> s;
c.getUniqueInteger().toStringUnsigned(s, 10);
std::string int_value = std::string(s);
#else
std::string int_value = c.getUniqueInteger().toString(10, true);

#endif
// Write constant to integer fact
writeFact(pred::constant::to_integer, id, int_value);
}
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 12. See :doc:`build` for how
- cclyzer++ now builds against (and requires) LLVM 13. 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 12
cclyzer++ has primarily been tested on LLVM code produced by Clang 10 through 13
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 12
* supports LLVM 10 through 13
* 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 12 by default and can be built with
cclyzer++ currently builds against LLVM 13 by default and can be built with
LLVM 10. There are `plans <llvmver>`_ to support recent versions.

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

cclyzer++ currently builds with Clang 12 (including other Clang tools such as
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.

Expand Down
20 changes: 12 additions & 8 deletions docker/dev.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# Image with all cclyzer++ development tools, i.e., everything needed by
# cclyzer++ developers to build and test cclyzer++.

# TODO(#12): Upgrade to Ubuntu 22.04 (jammy), Clang 15, LLVM 15
ARG UBUNTU_NAME=focal
ARG UBUNTU_VERSION=20.04
# TODO(#12): Upgrade to Clang 15, LLVM 15
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=12
ARG LLVM_MAJOR_VERSION=12
ARG CLANG_VERSION=13
ARG LLVM_MAJOR_VERSION=13
# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG UBUNTU_NAME
ARG UBUNTU_VERSION
Expand Down Expand Up @@ -45,9 +45,13 @@ RUN apt-get update && \
wget --no-verbose https://souffle-lang.github.io/ppa/souffle-key.public -O /usr/share/keyrings/souffle-archive-keyring.gpg && \
echo "deb [signed-by=/usr/share/keyrings/souffle-archive-keyring.gpg] https://souffle-lang.github.io/ppa/ubuntu/ stable main" | tee /etc/apt/sources.list.d/souffle.list && \
apt-get update && \
apt-get --yes install --no-install-recommends souffle && \
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
echo "deb http://apt.llvm.org/${UBUNTU_NAME}/ llvm-toolchain-${UBUNTU_NAME} main" | tee /etc/apt/sources.list.d/llvm.list && \
apt-get --yes install --no-install-recommends souffle
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
if [[ ${LLVM_VERSION} -lt 13 ]]; then \
echo "deb http://apt.llvm.org/${UBUNTU_NAME}/ llvm-toolchain-${UBUNTU_NAME} main" | tee /etc/apt/sources.list.d/llvm.list; \
else \
echo "deb http://apt.llvm.org/${UBUNTU_NAME}/ llvm-toolchain-${UBUNTU_NAME}-${LLVM_MAJOR_VERSION} main" | tee /etc/apt/sources.list.d/llvm.list; \
fi && \
apt-get update && \
apt-get --yes install --no-install-recommends \
clang-${CLANG_VERSION} \
Expand Down
8 changes: 8 additions & 0 deletions src/PointerAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ auto PointerAnalysisAAResult::alias(
const llvm::MemoryLocation &other_location,
llvm::AAQueryInfo &AAQI) -> llvm::AliasResult {
if (location.Ptr == other_location.Ptr) {
#if LLVM_VERSION_MAJOR > 12
return llvm::AliasResult::MustAlias;
#else
return llvm::MustAlias;
#endif
}

std::unordered_set<boost::flyweight<std::string>> points_to_set;
Expand All @@ -110,7 +114,11 @@ auto PointerAnalysisAAResult::alias(
}
}

#if LLVM_VERSION_MAJOR > 12
return llvm::AliasResult::NoAlias;
#else
return llvm::NoAlias;
#endif
}

static auto get_interface(Analysis which) -> std::unique_ptr<PAInterface> {
Expand Down
2 changes: 2 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def _run(
"-load",
BUILD / "libPAPass.so",
"-disable-output",
# TODO(lb): Use new pass manager
"-enable-new-pm=0",
"-cclyzer",
"-signatures",
signatures_path,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<allocation-sizes.c>:main:20 *heap_alloc@main[i8* %call3]
<allocation-sizes.c>:main:23 *heap_alloc@main[i8* %call4]
<allocation-sizes.c>:main:26 *heap_alloc@main[i8* %call7]
<allocation-sizes.c>:main:7 *heap_alloc@main[i8* %call2]
<allocation-sizes.c>:main:22 *heap_alloc@main[i8* %call3]
<allocation-sizes.c>:main:25 *heap_alloc@main[i8* %call4]
<allocation-sizes.c>:main:28 *heap_alloc@main[i8* %call7]
<allocation-sizes.c>:main:9 *heap_alloc@main[i8* %call2]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
i32 <allocation-sizes.c>:main:20 *typed_heap_alloc@main[i32* %call3]
i32 <allocation-sizes.c>:main:23 *typed_heap_alloc@main[i32* %call4]
i32 <allocation-sizes.c>:main:26 *typed_heap_alloc@main[i32* %call7]
i8 <allocation-sizes.c>:main:20 *typed_heap_alloc@main[i8* %call3]
i8 <allocation-sizes.c>:main:23 *typed_heap_alloc@main[i8* %call4]
i8 <allocation-sizes.c>:main:26 *typed_heap_alloc@main[i8* %call7]
i8 <allocation-sizes.c>:main:7 *typed_heap_alloc@main[i8* %call2]
i32 <allocation-sizes.c>:main:22 *typed_heap_alloc@main[i32* %call3]
i32 <allocation-sizes.c>:main:25 *typed_heap_alloc@main[i32* %call4]
i32 <allocation-sizes.c>:main:28 *typed_heap_alloc@main[i32* %call7]
i8 <allocation-sizes.c>:main:22 *typed_heap_alloc@main[i8* %call3]
i8 <allocation-sizes.c>:main:25 *typed_heap_alloc@main[i8* %call4]
i8 <allocation-sizes.c>:main:28 *typed_heap_alloc@main[i8* %call7]
i8 <allocation-sizes.c>:main:9 *typed_heap_alloc@main[i8* %call2]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<allocation-sizes.c>:main:0 *stack_alloc@main[[8 x i32]* %small_const_size_stack]
<allocation-sizes.c>:main:1 *stack_alloc@main[[128 x i32]* %large_const_size_stack]
<allocation-sizes.c>:main:17 *stack_alloc@main[i32* %vla]
<allocation-sizes.c>:main:19 *stack_alloc@main[i32* %vla]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
i8 <allocation-sizes.c>:main:17 *typed_stack_alloc@main[i8* %vla]
i8 <allocation-sizes.c>:main:19 *typed_stack_alloc@main[i8* %vla]
Loading

0 comments on commit 6fde100

Please sign in to comment.