Skip to content

Commit

Permalink
Migrate to LLVM15 (#308)
Browse files Browse the repository at this point in the history
* Migrate to LLVM15

* Update CI

* Update build script

* Remove vcpkg helper (#314)

* remove vcpkg_helper.cmake

* fix build instruction in README

* fix build script perms

* fix diff ci build

* fix typo, should be VCPKG_TARGET_TRIPLET

* update anghabench CI scripts for llvm 15

* miss comma

Co-authored-by: William Tan <[email protected]>
  • Loading branch information
frabert and Ninja3047 authored Dec 22, 2022
1 parent cca037e commit 87c50e8
Show file tree
Hide file tree
Showing 15 changed files with 254 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/anghabench-after-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
llvm: [ '14' ]
llvm: [ '15' ]
run_size: [ '1k' ]

name: Run AnghaBench CI (AMD64)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/anghabench-cron-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
llvm: [ '14' ]
llvm: [ '15' ]
run_size: [ '1k' ]

name: Run AnghaBench CI (AMD64)
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
image:
- { name: 'ubuntu', tag: '20.04' }
llvm: [
'14'
'15'
]

name: Rellic CI
Expand All @@ -48,8 +48,8 @@ jobs:
run: |
# TODO some of these should probably live in the Docker build image
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main" >> /etc/apt/sources.list
echo "deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main" >> /etc/apt/sources.list
echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-${{ matrix.llvm }} main" >> /etc/apt/sources.list
echo "deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-${{ matrix.llvm }} main" >> /etc/apt/sources.list
apt-get update
apt-get install -y ninja-build pixz xz-utils make rpm python3.8
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 100
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
'macos-11'
]
llvm: [
'14'
'15'
]

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -246,7 +246,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
llvm: ["14"]
llvm: ["15"]
ubuntu: ["20.04"]
steps:
- uses: actions/checkout@v2
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/diff_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
matrix:
image:
- { name: 'ubuntu', tag: '20.04', codename: 'focal' }
llvm: [ '14' ]
llvm: [ '15' ]
common_base: [ 'https://github.com/lifting-bits/cxx-common/releases/latest/download' ]

env:
Expand Down Expand Up @@ -62,21 +62,21 @@ jobs:
- name: Build old rellic
shell: bash
run: |
cmake -G Ninja -S old -B rellic-build-old -DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/vcpkg_${{ matrix.image.name }}-${{ matrix.image.tag }}_llvm-${{ matrix.llvm }}_amd64/scripts/buildsystems/vcpkg.cmake
cmake -G Ninja -S old -B rellic-build-old -DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/vcpkg_${{ matrix.image.name }}-${{ matrix.image.tag }}_llvm-${{ matrix.llvm }}_amd64/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET="x64-linux-rel"
cmake --build rellic-build-old
- name: Build new rellic
shell: bash
run: |
cmake -G Ninja -S . -B rellic-build -DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/vcpkg_${{ matrix.image.name }}-${{ matrix.image.tag }}_llvm-${{ matrix.llvm }}_amd64/scripts/buildsystems/vcpkg.cmake
cmake -G Ninja -S . -B rellic-build -DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/vcpkg_${{ matrix.image.name }}-${{ matrix.image.tag }}_llvm-${{ matrix.llvm }}_amd64/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET="x64-linux-rel"
cmake --build rellic-build
- name: Print job summary
shell: bash
run: |
echo "# Test diffs" >> $GITHUB_STEP_SUMMARY
cd $GITHUB_WORKSPACE/tests/tools/decomp
env CLANG=clang-14 \
env CLANG=clang-${{ matrix.llvm }} \
OLD_RELLIC=$GITHUB_WORKSPACE/rellic-build-old/tools/rellic-decomp \
NEW_RELLIC=$GITHUB_WORKSPACE/rellic-build/tools/rellic-decomp \
make -s -j1 -f diff_outputs.mk >> $GITHUB_STEP_SUMMARY
Expand All @@ -86,7 +86,7 @@ jobs:
id: md
run: |
cd $GITHUB_WORKSPACE/tests/tools/decomp
env CLANG=clang-14 \
env CLANG=clang-${{ matrix.llvm }} \
OLD_RELLIC=$GITHUB_WORKSPACE/rellic-build-old/tools/rellic-decomp \
NEW_RELLIC=$GITHUB_WORKSPACE/rellic-build/tools/rellic-decomp \
make -s -j1 -f diff_outputs.mk >> $GITHUB_WORKSPACE/test-diff.md
Expand Down
12 changes: 8 additions & 4 deletions lib/AST/ASTBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <clang/AST/ASTContext.h>
#include <clang/AST/Decl.h>
#include <clang/Basic/LangOptions.h>
#include <clang/Basic/SourceLocation.h>
#include <clang/Basic/TargetInfo.h>
#include <clang/Sema/Lookup.h>
Expand All @@ -33,11 +34,13 @@ enum CExprPrecedence : unsigned {
namespace {

static unsigned GetOperatorPrecedence(clang::UnaryOperatorKind opc) {
return static_cast<unsigned>(CExprPrecedence::UnaryOp) + static_cast<unsigned>(opc);
return static_cast<unsigned>(CExprPrecedence::UnaryOp) +
static_cast<unsigned>(opc);
}

static unsigned GetOperatorPrecedence(clang::BinaryOperatorKind opc) {
return static_cast<unsigned>(CExprPrecedence::BinaryOp) + static_cast<unsigned>(opc);
return static_cast<unsigned>(CExprPrecedence::BinaryOp) +
static_cast<unsigned>(opc);
}

static unsigned GetOperatorPrecedence(clang::Expr *op) {
Expand Down Expand Up @@ -186,7 +189,7 @@ clang::CharacterLiteral *ASTBuilder::CreateCharLit(unsigned val) {
clang::StringLiteral *ASTBuilder::CreateStrLit(std::string val) {
auto type{ctx.getStringLiteralArrayType(ctx.CharTy, val.size())};
return clang::StringLiteral::Create(
ctx, val, clang::StringLiteral::StringKind::Ascii,
ctx, val, clang::StringLiteral::StringKind::Ordinary,
/*Pascal=*/false, type, clang::SourceLocation());
}

Expand Down Expand Up @@ -459,7 +462,8 @@ clang::CompoundStmt *ASTBuilder::CreateCompoundStmt(
// sema.ActOnFinishOfCompoundStmt();
// CHECK(sr.isUsable());
// return sr.getAs<clang::CompoundStmt>();
return clang::CompoundStmt::Create(ctx, stmts, clang::SourceLocation(),
return clang::CompoundStmt::Create(ctx, stmts, clang::FPOptionsOverride{},
clang::SourceLocation(),
clang::SourceLocation());
}

Expand Down
1 change: 1 addition & 0 deletions lib/AST/DebugInfoCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <gflags/gflags.h>
#include <glog/logging.h>
#include <llvm/BinaryFormat/Dwarf.h>
#include <llvm/IR/DebugInfoMetadata.h>
#include <llvm/IR/DerivedTypes.h>
#include <llvm/Support/Casting.h>
Expand Down
1 change: 1 addition & 0 deletions lib/AST/StructGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <clang/Basic/TargetInfo.h>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <llvm/BinaryFormat/Dwarf.h>

#include <string>
#include <unordered_set>
Expand Down
1 change: 1 addition & 0 deletions lib/BC/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <llvm/IR/BasicBlock.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/InstIterator.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/IntrinsicInst.h>
#include <llvm/IR/LLVMContext.h>
Expand Down
8 changes: 6 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ DOWNLOAD_DIR="$( cd "$( dirname "${SRC_DIR}" )" && pwd )/lifting-bits-downloads"
CURR_DIR=$( pwd )
BUILD_DIR="${CURR_DIR}/rellic-build"
INSTALL_DIR=/usr/local
LLVM_VERSION=llvm-14
CXX_COMMON_VERSION=v0.2.16
LLVM_VERSION=llvm-15
CXX_COMMON_VERSION=v0.2.19
OS_VERSION=unknown
ARCH_VERSION=unknown
BUILD_FLAGS=
Expand Down Expand Up @@ -334,6 +334,10 @@ function GetLLVMVersion
LLVM_VERSION=llvm-14
return 0
;;
15)
LLVM_VERSION=llvm-15
return 0
;;
*)
# unknown option
echo "[x] Unknown or unsupported LLVM version ${1}. You may be able to manually build it with cxx-common."
Expand Down
2 changes: 0 additions & 2 deletions tools/decomp/Decomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ int main(int argc, char* argv[]) {
}

std::unique_ptr<llvm::LLVMContext> llvm_ctx(new llvm::LLVMContext);
llvm_ctx->enableOpaquePointers();

auto module{std::unique_ptr<llvm::Module>(
rellic::LoadModuleFromFile(llvm_ctx.get(), FLAGS_input))};

Expand Down
1 change: 0 additions & 1 deletion tools/repl/Repl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ int main(int argc, char* argv[]) {
SetVersion();
google::ParseCommandLineFlags(&argc, &argv, true);

llvm_ctx.enableOpaquePointers();
auto& pr{*llvm::PassRegistry::getPassRegistry()};
initializeCore(pr);
initializeAnalysis(pr);
Expand Down
17 changes: 15 additions & 2 deletions tools/xref/DeclPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,10 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
if (FT->isVariadic()) {
if (D->getNumParams()) POut << ", ";
POut << "...";
} else if (!D->getNumParams() && !Context.getLangOpts().CPlusPlus) {
// The function has a prototype, so it needs to retain the prototype
// in C.
POut << "<span class=\"clang keyword\">void</span>";
}
} else if (D->doesThisDeclarationHaveABody() && !D->hasPrototype()) {
for (unsigned i = 0, e = D->getNumParams(); i != e; ++i) {
Expand Down Expand Up @@ -845,8 +849,11 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) {
Expr *Init = D->getInit();
if (!Policy.SuppressInitializers && Init) {
bool ImplicitInit = false;
if (CXXConstructExpr *Construct =
dyn_cast<CXXConstructExpr>(Init->IgnoreImplicit())) {
if (D->isCXXForRangeDecl()) {
// FIXME: We should print the range expression instead.
ImplicitInit = true;
} else if (CXXConstructExpr *Construct =
dyn_cast<CXXConstructExpr>(Init->IgnoreImplicit())) {
if (D->getInitStyle() == VarDecl::CallInit &&
!Construct->isListInitialization()) {
ImplicitInit = Construct->getNumArgs() == 0 ||
Expand Down Expand Up @@ -945,6 +952,12 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
}
}

if (D->hasDefinition()) {
if (D->hasAttr<FinalAttr>()) {
Out << " final";
}
}

if (D->isCompleteDefinition()) {
// Print the base classes
if (D->getNumBases()) {
Expand Down
Loading

0 comments on commit 87c50e8

Please sign in to comment.