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

Upgrade to rust 1.52.1 #13

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0173333
[BPF] Customize README.md
jackcmay Feb 15, 2019
7218519
[BPF] Add warning messages for potentially incorrect behavior
jackcmay Feb 15, 2019
fab26b4
[BPF] Remove blocks for complex types, update debug messages
jackcmay Feb 15, 2019
ff5f4a6
[BPF] Add support for relative relocations
jackcmay Feb 15, 2019
c54ef29
[BPF] Custom expansions without handlers, expand instead or error
jackcmay Feb 15, 2019
8b8ae6d
[BPF] symbols resolved at load time
jackcmay Jun 20, 2019
7ec833c
[BPF] Update warning about more args then BPF currently supports
jackcmay Jun 21, 2019
a8ce209
[BPF] Enable auto-demotion of sret values
jackcmay Jun 4, 2019
733f493
[BPF] Support passing arguments via the stack
jackcmay Jul 11, 2019
6f17700
[BPF] Fix undefined register error
jackcmay Jul 11, 2019
d4bce77
[BPF] Pass stack args in current frame
jackcmay Aug 20, 2019
96b4504
[BPF] Push stack args to the bottom of the stack
jackcmay Aug 29, 2019
2416f85
[BPF] Bump stack frame size
jackcmay Feb 10, 2020
3a40578
[LLD][BPF] Enable BPF shared object creation (#1)
dmakarov Feb 4, 2021
7e5b0ca
Fix Github Actions (#2)
Lichtso Feb 5, 2021
4cc2d54
[BPF] Disable llvm tests incompatible with Solana BPF backend (#3)
dmakarov Feb 8, 2021
a56a018
[BPF] Allow selectively disable compiler builtins for BPF target (#4)
dmakarov Feb 17, 2021
beebea5
[BPF] Map signed division operation to corresponding intrinsic function
dmakarov Feb 26, 2021
d505db5
[SOL][LLD][BPF] Adjust BPF TargetInfo to updated API
dmakarov Feb 26, 2021
9fe92d1
[SOL][BPF] Allow unaligned store operations
dmakarov Mar 22, 2021
4a40a94
[SOL][BPF] Adjust BPF tests (#6)
dmakarov Mar 25, 2021
faf6ee2
[SOL][BPF] Allow misaligned loads (#7)
dmakarov Mar 27, 2021
7e81536
[SOL][BPF] Add BPF compiler-rt builtins (#8)
dmakarov Apr 2, 2021
9943f50
[SOL][BPF] Enable Solana BPF extensions as subtarget feature (#9)
dmakarov Apr 12, 2021
ead79b8
[SOL][BPF] Remove debug printf (#11)
dmakarov Apr 13, 2021
ed0e166
[SOL] Fixes required for Solang (#10)
seanyoung Apr 13, 2021
393dae0
[SOL][BPF] Disable debug info when solana feature flag is set (#12)
dmakarov Apr 22, 2021
d832fd2
[SOL] Fix broken tests unrelated to Solana/BPF backend
dmakarov May 17, 2021
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
4 changes: 2 additions & 2 deletions .github/workflows/clang-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
matrix:
os:
- ubuntu-latest
- windows-latest
# - windows-latest
- macOS-latest
steps:
- name: Setup Windows
Expand All @@ -39,5 +39,5 @@ jobs:
- name: Test clang
uses: llvm/actions/build-test-llvm-project@main
with:
cmake_args: -G Ninja -DLLVM_ENABLE_PROJECTS="clang" -DCMAKE_BUILD_TYPE=Release
cmake_args: -G Ninja -DLLVM_ENABLE_PROJECTS="clang" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD='X86;BPF'
build_target: check-clang
4 changes: 2 additions & 2 deletions .github/workflows/lld-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
matrix:
os:
- ubuntu-latest
- windows-latest
# - windows-latest
- macOS-latest
steps:
- name: Setup Windows
Expand All @@ -39,5 +39,5 @@ jobs:
- name: Test lld
uses: llvm/actions/build-test-llvm-project@main
with:
cmake_args: -G Ninja -DLLVM_ENABLE_PROJECTS="lld" -DCMAKE_BUILD_TYPE=Release
cmake_args: -G Ninja -DLLVM_ENABLE_PROJECTS="lld" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD='X86;BPF'
build_target: check-lld
8 changes: 6 additions & 2 deletions .github/workflows/llvm-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
os:
- ubuntu-latest
- windows-latest
# - windows-latest
- macOS-latest
steps:
- name: Setup Windows
Expand All @@ -37,9 +37,11 @@ jobs:
- name: Test llvm
uses: llvm/actions/build-test-llvm-project@main
with:
cmake_args: -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake_args: -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS='clang;lld' -DLLVM_TARGETS_TO_BUILD='X86;BPF'

# disable ABI compare
abi-dump-setup:
if: false
runs-on: ubuntu-latest
outputs:
BASELINE_REF: ${{ steps.vars.outputs.BASELINE_REF }}
Expand Down Expand Up @@ -70,6 +72,7 @@ jobs:
fi

abi-dump:
if: false
needs: abi-dump-setup
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -140,6 +143,7 @@ jobs:
path: llvm.symbols

abi-compare:
if: false
runs-on: ubuntu-latest
needs:
- abi-dump-setup
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# The LLVM Compiler Infrastructure modified to support Berkley Packet Filter modules written in Rust

This fork of LLVM is used by [this fork of Rust](https://github.com/solana-labs/rust)

---

# The LLVM Compiler Infrastructure

This directory and its sub-directories contain source code for LLVM,
Expand Down
26 changes: 22 additions & 4 deletions clang/lib/Basic/Targets/BPF.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ namespace clang {
namespace targets {

class LLVM_LIBRARY_VISIBILITY BPFTargetInfo : public TargetInfo {
bool HasSolanaFeature = false;
static const Builtin::Info BuiltinInfo[];

public:
BPFTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
BPFTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
: TargetInfo(Triple) {
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
SizeType = UnsignedLong;
Expand All @@ -34,10 +35,24 @@ class LLVM_LIBRARY_VISIBILITY BPFTargetInfo : public TargetInfo {
IntMaxType = SignedLong;
Int64Type = SignedLong;
RegParmMax = 5;
for (auto& it : Opts.FeaturesAsWritten) {
if (it == "+solana") {
HasSolanaFeature = true;
break;
}
}
if (Triple.getArch() == llvm::Triple::bpfeb) {
resetDataLayout("E-m:e-p:64:64-i64:64-i128:128-n32:64-S128");
if (HasSolanaFeature) {
resetDataLayout("E-m:e-p:64:64-i64:64-n32:64-S128");
} else {
resetDataLayout("E-m:e-p:64:64-i64:64-i128:128-n32:64-S128");
}
} else {
resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n32:64-S128");
if (HasSolanaFeature) {
resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128");
} else {
resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n32:64-S128");
}
}
MaxAtomicPromoteWidth = 64;
MaxAtomicInlineWidth = 64;
Expand All @@ -48,7 +63,8 @@ class LLVM_LIBRARY_VISIBILITY BPFTargetInfo : public TargetInfo {
MacroBuilder &Builder) const override;

bool hasFeature(StringRef Feature) const override {
return Feature == "bpf" || Feature == "alu32" || Feature == "dwarfris";
return Feature == "bpf" || Feature == "alu32" || Feature == "dwarfris" ||
Feature == "solana";
}

void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
Expand Down Expand Up @@ -96,6 +112,8 @@ class LLVM_LIBRARY_VISIBILITY BPFTargetInfo : public TargetInfo {
StringRef CPUName(Name);
return isValidCPUName(CPUName);
}

bool hasExtIntType() const override { return HasSolanaFeature; }
};
} // namespace targets
} // namespace clang
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ add_clang_library(clangDriver
ToolChain.cpp
ToolChains/Arch/AArch64.cpp
ToolChains/Arch/ARM.cpp
ToolChains/Arch/BPF.cpp
ToolChains/Arch/Mips.cpp
ToolChains/Arch/PPC.cpp
ToolChains/Arch/RISCV.cpp
Expand Down
53 changes: 53 additions & 0 deletions clang/lib/Driver/ToolChains/Arch/BPF.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//===--- BPF.cpp - Tools Implementations ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "BPF.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/Options.h"
#include "llvm/Option/ArgList.h"

using namespace clang::driver;
using namespace clang::driver::tools;
using namespace clang;
using namespace llvm::opt;

static bool DecodeBPFFeatures(const Driver &D, StringRef text,
std::vector<StringRef> &Features) {
SmallVector<StringRef, 8> Split;
text.split(Split, StringRef("+"), -1, false);

for (StringRef Feature : Split) {
if (Feature == "solana")
Features.push_back("+solana");
else
return false;
}
return true;
}

static bool
getBPFArchFeaturesFromMarch(const Driver &D, StringRef March,
const ArgList &Args,
std::vector<StringRef> &Features) {
std::string MarchLowerCase = March.lower();
std::pair<StringRef, StringRef> Split = StringRef(MarchLowerCase).split("+");

return (Split.first == "bpfel" || Split.first == "bpfeb") &&
(Split.second.size() == 0 || DecodeBPFFeatures(D, Split.second, Features));
}

void bpf::getBPFTargetFeatures(const Driver &D, const ArgList &Args,
std::vector<StringRef> &Features) {
Arg *A;
bool success = true;
if ((A = Args.getLastArg(options::OPT_march_EQ)))
success = getBPFArchFeaturesFromMarch(D, A->getValue(), Args, Features);
if (!success)
D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
}
31 changes: 31 additions & 0 deletions clang/lib/Driver/ToolChains/Arch/BPF.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//===--- BPF.h - BPF-specific Tool Helpers ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ARCH_BPF_H
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ARCH_BPF_H

#include "clang/Driver/Driver.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Option/Option.h"
#include <string>
#include <vector>

namespace clang {
namespace driver {
namespace tools {
namespace bpf {

void getBPFTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args,
std::vector<llvm::StringRef> &Features);

} // end namespace bpf
} // namespace tools
} // end namespace driver
} // end namespace clang

#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ARCH_BPF_H
5 changes: 5 additions & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "AMDGPU.h"
#include "Arch/AArch64.h"
#include "Arch/ARM.h"
#include "Arch/BPF.h"
#include "Arch/Mips.h"
#include "Arch/PPC.h"
#include "Arch/RISCV.h"
Expand Down Expand Up @@ -345,6 +346,10 @@ static void getTargetFeatures(const Driver &D, const llvm::Triple &Triple,
case llvm::Triple::aarch64_be:
aarch64::getAArch64TargetFeatures(D, Triple, Args, Features);
break;
case llvm::Triple::bpfeb:
case llvm::Triple::bpfel:
bpf::getBPFTargetFeatures(D, Args, Features);
break;
case llvm::Triple::x86:
case llvm::Triple::x86_64:
x86::getX86TargetFeatures(D, Triple, Args, Features);
Expand Down
9 changes: 9 additions & 0 deletions clang/test/CodeGen/ext-int-cc.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
// RUN: %clang_cc1 -triple arm64_32-apple-ios -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=AARCH64
// RUN: %clang_cc1 -triple arm64_32-apple-ios -target-abi darwinpcs -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=AARCH64DARWIN
// RUN: %clang_cc1 -triple arm -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=ARM
// RUN: %clang_cc1 -triple bpf -target-feature +solana -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=BPF

// Make sure 128 and 64 bit versions are passed like integers, and that >128
// is passed indirectly.
Expand Down Expand Up @@ -59,6 +60,7 @@ void ParamPassing(_ExtInt(129) a, _ExtInt(128) b, _ExtInt(64) c) {}
// AARCH64: define{{.*}} void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128 %{{.+}}, i64 %{{.+}})
// AARCH64DARWIN: define{{.*}} void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128 %{{.+}}, i64 %{{.+}})
// ARM: define{{.*}} arm_aapcscc void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128* byval(i128) align 8 %{{.+}}, i64 %{{.+}})
// BPF: define{{.*}} void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128 %{{.+}}, i64 %{{.+}})

void ParamPassing2(_ExtInt(129) a, _ExtInt(127) b, _ExtInt(63) c) {}
// LIN64: define{{.*}} void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i64 %{{.+}})
Expand Down Expand Up @@ -88,6 +90,7 @@ void ParamPassing2(_ExtInt(129) a, _ExtInt(127) b, _ExtInt(63) c) {}
// AARCH64: define{{.*}} void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i127 %{{.+}}, i63 %{{.+}})
// AARCH64DARWIN: define{{.*}} void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i127 %{{.+}}, i63 %{{.+}})
// ARM: define{{.*}} arm_aapcscc void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i127* byval(i127) align 8 %{{.+}}, i63 %{{.+}})
// BPF: define{{.*}} void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i127 %{{.+}}, i63 %{{.+}})

// Make sure we follow the signext rules for promotable integer types.
void ParamPassing3(_ExtInt(15) a, _ExtInt(31) b) {}
Expand Down Expand Up @@ -118,6 +121,7 @@ void ParamPassing3(_ExtInt(15) a, _ExtInt(31) b) {}
// AARCH64: define{{.*}} void @ParamPassing3(i15 %{{.+}}, i31 %{{.+}})
// AARCH64DARWIN: define{{.*}} void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}})
// ARM: define{{.*}} arm_aapcscc void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}})
// BPF: define{{.*}} void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}})

_ExtInt(63) ReturnPassing(){}
// LIN64: define{{.*}} i64 @ReturnPassing(
Expand Down Expand Up @@ -147,6 +151,7 @@ _ExtInt(63) ReturnPassing(){}
// AARCH64: define{{.*}} i63 @ReturnPassing(
// AARCH64DARWIN: define{{.*}} i63 @ReturnPassing(
// ARM: define{{.*}} arm_aapcscc i63 @ReturnPassing(
// BPF: define{{.*}} i63 @ReturnPassing(

_ExtInt(64) ReturnPassing2(){}
// LIN64: define{{.*}} i64 @ReturnPassing2(
Expand Down Expand Up @@ -176,6 +181,7 @@ _ExtInt(64) ReturnPassing2(){}
// AARCH64: define{{.*}} i64 @ReturnPassing2(
// AARCH64DARWIN: define{{.*}} i64 @ReturnPassing2(
// ARM: define{{.*}} arm_aapcscc i64 @ReturnPassing2(
// BPF: define{{.*}} i64 @ReturnPassing2(

_ExtInt(127) ReturnPassing3(){}
// LIN64: define{{.*}} { i64, i64 } @ReturnPassing3(
Expand Down Expand Up @@ -207,6 +213,7 @@ _ExtInt(127) ReturnPassing3(){}
// AARCH64: define{{.*}} i127 @ReturnPassing3(
// AARCH64DARWIN: define{{.*}} i127 @ReturnPassing3(
// ARM: define{{.*}} arm_aapcscc void @ReturnPassing3(i127* noalias sret
// BPF: define{{.*}} i127 @ReturnPassing3(

_ExtInt(128) ReturnPassing4(){}
// LIN64: define{{.*}} { i64, i64 } @ReturnPassing4(
Expand Down Expand Up @@ -236,6 +243,7 @@ _ExtInt(128) ReturnPassing4(){}
// AARCH64: define{{.*}} i128 @ReturnPassing4(
// AARCH64DARWIN: define{{.*}} i128 @ReturnPassing4(
// ARM: define{{.*}} arm_aapcscc void @ReturnPassing4(i128* noalias sret
// BPF: define{{.*}} i128 @ReturnPassing4(

_ExtInt(129) ReturnPassing5(){}
// LIN64: define{{.*}} void @ReturnPassing5(i129* noalias sret
Expand Down Expand Up @@ -265,6 +273,7 @@ _ExtInt(129) ReturnPassing5(){}
// AARCH64: define{{.*}} void @ReturnPassing5(i129* noalias sret
// AARCH64DARWIN: define{{.*}} void @ReturnPassing5(i129* noalias sret
// ARM: define{{.*}} arm_aapcscc void @ReturnPassing5(i129* noalias sret
// BPF: define{{.*}} void @ReturnPassing5(i129* noalias sret

// SparcV9 is odd in that it has a return-size limit of 256, not 128 or 64
// like other platforms, so test to make sure this behavior will still work.
Expand Down
8 changes: 8 additions & 0 deletions clang/test/CodeGen/target-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@
// RUN: FileCheck %s -check-prefix=BPFEB
// BPFEB: target datalayout = "E-m:e-p:64:64-i64:64-i128:128-n32:64-S128"

// RUN: %clang_cc1 -triple bpfel -target-feature +solana -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=BPFELSOL
// BPFELSOL: target datalayout = "e-m:e-p:64:64-i64:64-n32:64-S128"

// RUN: %clang_cc1 -triple bpfeb -target-feature +solana -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=BPFEBSOL
// BPFEBSOL: target datalayout = "E-m:e-p:64:64-i64:64-n32:64-S128"

// RUN: %clang_cc1 -triple ve -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=VE
// VE: target datalayout = "e-m:e-i64:64-n32:64-S128-v64:64:64-v128:64:64-v256:64:64-v512:64:64-v1024:64:64-v2048:64:64-v4096:64:64-v8192:64:64-v16384:64:64"
Loading