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 17 fixes #395

Merged
merged 7 commits into from
Oct 13, 2023
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
17 changes: 8 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ jobs:
matrix:
image:
- { name: "ubuntu", tag: "22.04" }
llvm: ["16"]
cxxcommon_version: ["v0.3.2"]
llvm: ["17"]
cxxcommon_version: ["v0.6.0"]
2over12 marked this conversation as resolved.
Show resolved Hide resolved

runs-on:
labels: gha-ubuntu-32
Expand Down Expand Up @@ -154,7 +154,6 @@ jobs:
- name: Clone Ghidra Spec Generation
uses: actions/checkout@v3
with:
ref: ekilmer/uid-codeblocks
path: ${{ steps.build_paths.outputs.REL_SOURCE }}/irene3
repository: "trailofbits/irene3"
fetch-depth: 0
Expand Down Expand Up @@ -411,11 +410,11 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ["macos-12"]
llvm: ["16"]
cxxcommon_version: ["v0.3.2"]
os: ["macos-13"]
llvm: ["17"]
cxxcommon_version: ["v0.6.0"]
2over12 marked this conversation as resolved.
Show resolved Hide resolved

runs-on: macos-12
runs-on: macos-13

steps:
- name: Setup the build paths
Expand Down Expand Up @@ -490,7 +489,7 @@ jobs:
id: cxxcommon_installer
working-directory: ${{ steps.build_paths.outputs.DOWNLOADS }}
run: |
folder_name="vcpkg_${{ matrix.os }}_llvm-${{ matrix.llvm }}_xcode-14.2_amd64"
folder_name="vcpkg_${{ matrix.os }}_llvm-${{ matrix.llvm }}_xcode-15.0_amd64"
archive_name="${folder_name}.tar.xz"

url="https://github.com/lifting-bits/cxx-common/releases/download/${{ matrix.cxxcommon_version}}/${archive_name}"
Expand Down Expand Up @@ -753,7 +752,7 @@ jobs:

strategy:
matrix:
llvm: ["16"]
llvm: ["17"]
ubuntu: ["22.04"]
steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG LLVM_VERSION=16
ARG LLVM_VERSION=17
ARG ARCH=amd64
ARG UBUNTU_VERSION=22.04
ARG CXX_COMMON_VERSION=0.3.2
ARG CXX_COMMON_VERSION=0.6.0
ARG DISTRO_BASE=ubuntu${UBUNTU_VERSION}
2over12 marked this conversation as resolved.
Show resolved Hide resolved
ARG BUILD_BASE=ubuntu:${UBUNTU_VERSION}
ARG LIBRARIES=/opt/trailofbits
Expand Down
2 changes: 1 addition & 1 deletion lib/CrossReferenceFolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ CrossReferenceFolderImpl::ResolveConstant(llvm::Constant *const_val) {
xr.is_valid = false;

if (val.isNegative()) {
if (val.getMinSignedBits() <= 64) {
if (val.getSignificantBits() <= 64) {
xr.u.address = static_cast<uint64_t>(val.getSExtValue());
xr.is_valid = true;
}
Expand Down
53 changes: 39 additions & 14 deletions lib/Lifters/CodeLifter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/IR/Verifier.h>
#include <llvm/Pass.h>
#include <llvm/Passes/PassBuilder.h>
#include <llvm/Transforms/InstCombine/InstCombine.h>
#include <llvm/Transforms/Scalar.h>
#include <llvm/Transforms/Scalar/DCE.h>
#include <llvm/Transforms/Scalar/DeadStoreElimination.h>
#include <llvm/Transforms/Scalar/Reassociate.h>
#include <llvm/Transforms/Scalar/SROA.h>
#include <llvm/Transforms/Scalar/SimplifyCFG.h>
#include <llvm/Transforms/Utils.h>
#include <llvm/Transforms/Utils/Cloning.h>
#include <llvm/Transforms/Utils/Mem2Reg.h>
#include <remill/Arch/Arch.h>
#include <remill/Arch/Context.h>
#include <remill/Arch/Instruction.h>
Expand Down Expand Up @@ -195,7 +202,7 @@ llvm::MDNode *CodeLifter::GetAddrAnnotation(uint64_t addr,
}

llvm::MDNode *CodeLifter::GetUidAnnotation(Uid uid,
llvm::LLVMContext &context) const {
llvm::LLVMContext &context) const {
auto uid_val = llvm::ConstantInt::get(
remill::RecontextualizeType(uid_type, context), uid.value);
auto uid_md = llvm::ValueAsMetadata::get(uid_val);
Expand Down Expand Up @@ -310,19 +317,37 @@ void CodeLifter::RecursivelyInlineFunctionCallees(llvm::Function *inf) {

DCHECK(!llvm::verifyFunction(*inf, &llvm::errs()));

llvm::legacy::FunctionPassManager fpm(inf->getParent());
fpm.add(llvm::createCFGSimplificationPass());
fpm.add(llvm::createPromoteMemoryToRegisterPass());
fpm.add(llvm::createReassociatePass());
fpm.add(llvm::createDeadStoreEliminationPass());
fpm.add(llvm::createDeadCodeEliminationPass());
fpm.add(llvm::createSROAPass());
fpm.add(llvm::createDeadCodeEliminationPass());
fpm.add(llvm::createInstructionCombiningPass());
fpm.doInitialization();
fpm.run(*inf);
fpm.doFinalization();

llvm::ModuleAnalysisManager mam;
llvm::FunctionAnalysisManager fam;
llvm::LoopAnalysisManager lam;
llvm::CGSCCAnalysisManager cam;

llvm::ModulePassManager mpm;
llvm::FunctionPassManager fpm;


llvm::PassBuilder pb;
pb.registerModuleAnalyses(mam);
pb.registerFunctionAnalyses(fam);
pb.registerLoopAnalyses(lam);
pb.registerCGSCCAnalyses(cam);
pb.crossRegisterProxies(lam, fam, cam, mam);

fpm.addPass(llvm::SimplifyCFGPass());
fpm.addPass(llvm::PromotePass());
fpm.addPass(llvm::ReassociatePass());
fpm.addPass(llvm::DSEPass());
fpm.addPass(llvm::DCEPass());
fpm.addPass(llvm::SROAPass(llvm::SROAOptions::ModifyCFG));
fpm.addPass(llvm::DCEPass());
fpm.addPass(llvm::InstCombinePass());

fpm.run(*inf, fam);

mam.clear();
fam.clear();
lam.clear();
cam.clear();
ClearVariableNames(inf);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Passes/TransformRemillJumpIntrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <anvill/Transforms.h>
#include <anvill/Utils.h>
#include <glog/logging.h>
#include <llvm/ADT/Triple.h>
#include <llvm/Analysis/TargetLibraryInfo.h>
#include <llvm/IR/Dominators.h>
#include <llvm/IR/Function.h>
Expand All @@ -23,6 +22,7 @@
#include <llvm/IR/Module.h>
#include <llvm/IR/Type.h>
#include <llvm/Pass.h>
#include <llvm/TargetParser/Triple.h>
#include <llvm/Transforms/IPO.h>
#include <llvm/Transforms/InstCombine/InstCombine.h>
#include <llvm/Transforms/Scalar/DCE.h>
Expand Down
2 changes: 1 addition & 1 deletion lib/Passes/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
#include <anvill/ABI.h>
#include <glog/logging.h>
#include <llvm/ADT/ArrayRef.h>
#include <llvm/ADT/Triple.h>
#include <llvm/IR/Constant.h>
#include <llvm/IR/Constants.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/InstIterator.h>
#include <llvm/IR/Instruction.h>
#include <llvm/IR/Instructions.h>
#include <llvm/TargetParser/Triple.h>
#include <remill/BC/Util.h>

namespace anvill {
Expand Down
16 changes: 8 additions & 8 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ CURR_DIR=$( pwd )
BUILD_DIR="${CURR_DIR}/anvill-build"
REMILL_BUILD_DIR="${CURR_DIR}/remill-build"
INSTALL_DIR=/usr/local
LLVM_VERSION=llvm-16
CXX_COMMON_VERSION="0.3.2"
LLVM_VERSION=llvm-17
CXX_COMMON_VERSION="0.6.0"
2over12 marked this conversation as resolved.
Show resolved Hide resolved
OS_VERSION=unknown
ARCH_VERSION=unknown
BUILD_FLAGS=
Expand Down Expand Up @@ -175,11 +175,11 @@ function DownloadLibraries

#BUILD_FLAGS="${BUILD_FLAGS} -DCMAKE_OSX_SYSROOT=${sdk_root}"
# Min version supported
OS_VERSION="macos-12"
XCODE_VERSION="14.2"
OS_VERSION="macos-13"
XCODE_VERSION="15.0"
if [[ "${SYSTEM_VERSION}" == "13.*" ]]; then
echo "Found MacOS Ventura"
OS_VERSION="macos-12"
OS_VERSION="macos-13"
elif [[ "${SYSTEM_VERSION}" == "12.*" ]]; then
echo "Found MacOS Monterey"
OS_VERSION="macos-12"
Expand Down Expand Up @@ -341,8 +341,8 @@ function Package
function GetLLVMVersion
{
case ${1} in
16)
LLVM_VERSION=llvm-16
17)
LLVM_VERSION=llvm-17
return 0
;;
*)
Expand All @@ -360,7 +360,7 @@ function Help
echo ""
echo "Options:"
echo " --prefix Change the default (${INSTALL_DIR}) installation prefix."
echo " --llvm-version Change the default (16) LLVM version."
echo " --llvm-version Change the default (17) LLVM version."
echo " --build-dir Change the default (${BUILD_DIR}) build directory."
echo " --debug Build with Debug symbols."
echo " --extra-cmake-args Extra CMake arguments to build with."
Expand Down
Loading