Skip to content

Commit

Permalink
LLVM 15
Browse files Browse the repository at this point in the history
  • Loading branch information
langston-barrett committed Nov 1, 2022
1 parent d18d63f commit 8126604
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 22 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ env:
SPHINXOPTS: "-W --keep-going"
# This will be empty on events that aren't pull requests.
ACTUAL_GITHUB_SHA_ON_PULL_REQUEST: "${{ github.event.pull_request.head.sha }}"
# TODO(#12): Upgrade to Ubuntu 22.04 (jammy), Clang 15, LLVM 15
# TODO(#12, #113): Upgrade to Clang 15, LLVM 15.
#
# See also the matrix of the build job.
#
# NOTE[Clang+LLVM]: If the Clang version outstrips the LLVM version, the tests
Expand Down Expand Up @@ -59,14 +60,18 @@ jobs:
llvm_version: "12"
ubuntu_version: "20.04"
ubuntu_name: "focal"
- clang_version: "14"
- clang_version: "15"
llvm_version: "13"
ubuntu_version: "22.04"
ubuntu_name: "jammy"
- clang_version: "14"
llvm_version: "14"
ubuntu_version: "22.04"
ubuntu_name: "jammy"
- clang_version: "15"
llvm_version: "15"
ubuntu_version: "22.04"
ubuntu_name: "jammy"
env:
LLVM_MAJOR_VERSION: ${{ matrix.llvm_version }}
CLANG_VERSION: ${{ matrix.llvm_version }}
Expand Down
2 changes: 1 addition & 1 deletion FactGenerator/include/Factgen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void factgen(
const boost::filesystem::path &outputDir,
const llvm::Optional<boost::filesystem::path> &signatures,
const ContextSensitivity &context_sensitivity,
std::string delim);
const std::string &delim);
} // namespace cclyzer

#endif /* FACT_GENERATOR_HPP__ */
6 changes: 6 additions & 0 deletions FactGenerator/include/TypeAccumulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ class cclyzer::llvm_utils::TypeAccumulator {
if (elementType->isArrayTy()) {
visitType(elementType->getArrayElementType());
} else if (elementType->isPointerTy()) {
#if LLVM_VERSION_MAJOR > 14
if (!llvm::cast<llvm::PointerType>(elementType)->isOpaque()) {
visitType(elementType->getPointerElementType());
}
#else
visitType(elementType->getPointerElementType());
#endif
} else if (elementType->isStructTy()) {
visitStructType(elementType);
} else if (elementType->isVectorTy()) {
Expand Down
2 changes: 1 addition & 1 deletion FactGenerator/src/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void FactGenerator::writeGlobalVar(
// Serialize global variable properties
refmode_t visibility = refmode(gv.getVisibility());
refmode_t linkage = refmode(gv.getLinkage());
refmode_t varType = recordType(gv.getType()->getElementType());
refmode_t varType = recordType(gv.getType());
refmode_t thrLocMode = refmode(gv.getThreadLocalMode());

// Record demangled variable name
Expand Down
12 changes: 12 additions & 0 deletions FactGenerator/src/InstructionVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,12 @@ void InstructionVisitor::visitAllocaInst(const llvm::AllocaInst &AI) {
if (AI.isArrayAllocation())
writeInstrOperand(pred::alloca::size, iref, AI.getArraySize());

#if LLVM_VERSION_MAJOR > 14
gen.writeFact(pred::alloca::alignment, iref, llvm::Log2(AI.getAlign()));
#else
if (AI.getAlignment())
gen.writeFact(pred::alloca::alignment, iref, AI.getAlignment());
#endif
}

void InstructionVisitor::visitLoadInst(const llvm::LoadInst &LI) {
Expand All @@ -331,8 +335,12 @@ void InstructionVisitor::visitLoadInst(const llvm::LoadInst &LI) {

if (LI.isAtomic()) writeAtomicInfo<pred::load>(iref, LI);

#if LLVM_VERSION_MAJOR > 14
gen.writeFact(pred::load::alignment, iref, llvm::Log2(LI.getAlign()));
#else
if (LI.getAlignment())
gen.writeFact(pred::load::alignment, iref, LI.getAlignment());
#endif

if (LI.isVolatile()) gen.writeFact(pred::load::is_volatile, iref);
}
Expand Down Expand Up @@ -370,8 +378,12 @@ void InstructionVisitor::visitStoreInst(const llvm::StoreInst &SI) {

if (SI.isAtomic()) writeAtomicInfo<pred::store>(iref, SI);

#if LLVM_VERSION_MAJOR > 14
gen.writeFact(pred::store::alignment, iref, llvm::Log2(SI.getAlign()));
#else
if (SI.getAlignment())
gen.writeFact(pred::store::alignment, iref, SI.getAlignment());
#endif

if (SI.isVolatile()) gen.writeFact(pred::store::is_volatile, iref);
}
Expand Down
10 changes: 6 additions & 4 deletions FactGenerator/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void cclyzer::factgen(
const fs::path &outputDir,
const llvm::Optional<fs::path> &signatures,
const ContextSensitivity &context_sensitivity,
std::string delim) {
const std::string &delim) {
using cclyzer::FactGenerator;
using cclyzer::FactWriter;

Expand All @@ -42,7 +42,7 @@ void cclyzer::factgen(
llvm::SMDiagnostic err;

// Create fact writer
FactWriter writer(outputDir, std::move(delim));
FactWriter writer(outputDir, delim);

// Create CSV generator
FactGenerator &gen = FactGenerator::getInstance(writer);
Expand Down Expand Up @@ -96,12 +96,14 @@ auto main(int argc, char *argv[]) -> int {
// Alternate version that doesn't use templates so that the python bindings work

void factgen2(
std::vector<fs::path> files, const fs::path &outputDir, std::string delim) {
std::vector<fs::path> files,
const fs::path &outputDir,
const std::string &delim) {
cclyzer::factgen(
files.begin(),
files.end(),
outputDir,
llvm::Optional<boost::filesystem::path>(),
INSENSITIVE,
std::move(delim));
delim);
}
22 changes: 16 additions & 6 deletions FactGenerator/src/TypeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,35 @@ void TypeVisitor::visitType(const llvm::Type *type) {
#if LLVM_VERSION_MAJOR > 11
case llvm::Type::X86_AMXTyID: // TODO: handle this type
break;
#endif
#if LLVM_VERSION_MAJOR > 14
case llvm::Type::DXILPointerTyID: // TODO: handle this type
break;
#endif
}
}

void TypeVisitor::visitPointerType(const PointerType *ptrType) {
const llvm::Type *elemType = ptrType->getPointerElementType();

refmode_t typeId = gen.refmode<llvm::Type>(*ptrType);
refmode_t elemTypeId = gen.refmode<llvm::Type>(*elemType);

// Record pointer type entity
gen.writeFact(pred::ptr_type::id, typeId);

// Record pointer element type
gen.writeFact(pred::ptr_type::component_type, typeId, elemTypeId);

// Record pointer address space
if (unsigned addressSpace = ptrType->getPointerAddressSpace())
gen.writeFact(pred::ptr_type::addr_space, typeId, addressSpace);

// Record pointer element type
#if LLVM_VERSION_MAJOR > 14
auto cond = !ptrType->isOpaque();
#else
auto cond = true;
#endif
if (cond) {
const llvm::Type *elemType = ptrType->getPointerElementType();
refmode_t elemTypeId = gen.refmode<llvm::Type>(*elemType);
gen.writeFact(pred::ptr_type::component_type, typeId, elemTypeId);
}
}

void TypeVisitor::visitArrayType(const ArrayType *arrayType) {
Expand Down
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ is highly parallel. cclyzer++ was derived from `cclyzer`_.

Documentation is also available `online`_.

cclyzer++ is not currently actively developed or maintained by Galois, Inc.
cclyzer++ is actively developed and maintained by Galois, Inc.

.. note::
You may also want to peruse the `Release Announcement
Expand Down
8 changes: 5 additions & 3 deletions doc/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ Comparison to cclyzer
As mentioned above, cclyzer++ is based on cclyzer. The major differences are that
cclyzer++

* supports LLVM 10 through 14
* :ref:`supports LLVM 10 through 14 <llvmlib>`, with limited support for
LLVM 15.
* 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 @@ -109,8 +110,8 @@ LLVM Library Version
.. TODO(lb): Policy for supporting different LLVM 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.
previous versions 13 through 10. cclyzer++ can be built with LLVM 15, but
the analysis `does not yet support opaque pointers <opaque_>`_.

Development Tools
*****************
Expand All @@ -121,4 +122,5 @@ build with Clang 15.

.. _tutorial: http://yanniss.github.io/points-to-tutorial15.pdf
.. _llvmver: https://github.com/GaloisInc/cclyzerpp/issues/12
.. _opaque: https://github.com/GaloisInc/cclyzerpp/issues/113
.. _semver: https://semver.org/spec/v2.0.0.html
9 changes: 6 additions & 3 deletions docker/dev.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
# Image with all cclyzer++ development tools, i.e., everything needed by
# cclyzer++ developers to build and test cclyzer++.

# 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
# See the documentation for supported versions.
#
# See NOTE[Clang+LLVM] in ci.yml.
#
# TODO(#12): Upgrade to Clang 15, LLVM 15
ARG CLANG_VERSION=14
ARG LLVM_MAJOR_VERSION=14
# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
Expand Down Expand Up @@ -47,7 +50,7 @@ RUN apt-get update && \
apt-get update && \
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 \
if [[ ${LLVM_MAJOR_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; \
Expand Down
2 changes: 1 addition & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ContextSensitivity(Enum):


PARENT: Path = Path(realpath(__file__)).parent
BUILD: Path = PARENT.parent / "build"
BUILD: Path = Path(getenv("CCLYZER_BUILD_DIR", str(PARENT.parent / "build")))
PROGRAMS_PATH: Path = PARENT.parent / "test" / "c"

# NOTE(ww): We don't use -Wall or -Werror here, since not all of our test
Expand Down

0 comments on commit 8126604

Please sign in to comment.