Skip to content

Commit ad714ac

Browse files
committed
[SOL] Adjustments after LLVM 19 upgrade
1 parent 318a295 commit ad714ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+477
-248
lines changed

.github/workflows/llvm-project-tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ jobs:
122122
variant: ${{ matrix.compile_cache }}
123123
- name: Build and Test
124124
if: "!startsWith(matrix.os, 'windows')"
125-
uses: llvm/actions/build-test-llvm-project@main
126125
env:
127126
# Workaround for https://github.com/actions/virtual-environments/issues/5900.
128127
# This should be a no-op for non-mac OSes

clang/lib/Basic/Targets/BPF.h

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ namespace clang {
2222
namespace targets {
2323

2424
class LLVM_LIBRARY_VISIBILITY BPFTargetInfo : public TargetInfo {
25+
bool HasSolanaFeature = false;
2526
bool HasAlu32 = false;
2627

2728
public:
28-
BPFTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
29+
BPFTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
2930
: TargetInfo(Triple) {
3031
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
3132
SizeType = UnsignedLong;
@@ -34,10 +35,28 @@ class LLVM_LIBRARY_VISIBILITY BPFTargetInfo : public TargetInfo {
3435
IntMaxType = SignedLong;
3536
Int64Type = SignedLong;
3637
RegParmMax = 5;
38+
if (Triple.getArch() == llvm::Triple::sbf) {
39+
HasSolanaFeature = true;
40+
} else {
41+
for (auto& it : Opts.FeaturesAsWritten) {
42+
if (it == "+solana") {
43+
HasSolanaFeature = true;
44+
break;
45+
}
46+
}
47+
}
3748
if (Triple.getArch() == llvm::Triple::bpfeb) {
38-
resetDataLayout("E-m:e-p:64:64-i64:64-i128:128-n32:64-S128");
49+
if (HasSolanaFeature) {
50+
resetDataLayout("E-m:e-p:64:64-i64:64-n32:64-S128");
51+
} else {
52+
resetDataLayout("E-m:e-p:64:64-i64:64-i128:128-n32:64-S128");
53+
}
3954
} else {
40-
resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n32:64-S128");
55+
if (HasSolanaFeature) {
56+
resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128");
57+
} else {
58+
resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n32:64-S128");
59+
}
4160
}
4261
MaxAtomicPromoteWidth = 64;
4362
MaxAtomicInlineWidth = 64;
@@ -115,6 +134,8 @@ class LLVM_LIBRARY_VISIBILITY BPFTargetInfo : public TargetInfo {
115134
std::pair<unsigned, unsigned> hardwareInterferenceSizes() const override {
116135
return std::make_pair(32, 32);
117136
}
137+
138+
bool hasBitIntType() const override { return HasSolanaFeature; }
118139
};
119140
} // namespace targets
120141
} // namespace clang

lld/ELF/Arch/BPF.cpp

Lines changed: 0 additions & 147 deletions
This file was deleted.

lld/tools/lld/lld.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "llvm/Support/Path.h"
3838
#include "llvm/Support/PluginLoader.h"
3939
#include "llvm/Support/Process.h"
40+
#include "llvm/Support/TargetSelect.h"
4041
#include "llvm/TargetParser/Host.h"
4142
#include "llvm/TargetParser/Triple.h"
4243
#include <cstdlib>
@@ -72,6 +73,17 @@ LLD_HAS_DRIVER(mingw)
7273
LLD_HAS_DRIVER(macho)
7374
LLD_HAS_DRIVER(wasm)
7475

76+
// This function is called on startup. We need this for LTO since
77+
// LTO calls LLVM functions to compile bitcode files to native code.
78+
// Technically this can be delayed until we read bitcode files, but
79+
// we don't bother to do lazily because the initialization is fast.
80+
static void initLLVM() {
81+
InitializeAllTargets();
82+
InitializeAllTargetMCs();
83+
InitializeAllAsmPrinters();
84+
InitializeAllAsmParsers();
85+
}
86+
7587
int lld_main(int argc, char **argv, const llvm::ToolContext &) {
7688
initLLVM();
7789
sys::Process::UseANSIEscapeCodes(true);

llvm/include/llvm/TargetParser/Triple.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class Triple {
104104
wasm64, // WebAssembly with 64-bit pointers
105105
renderscript32, // 32-bit RenderScript
106106
renderscript64, // 64-bit RenderScript
107+
sbf,
107108
ve, // NEC SX-Aurora Vector Engine
108109
LastArchType = ve
109110
};
@@ -244,6 +245,7 @@ class Triple {
244245
ShaderModel, // DirectX ShaderModel
245246
LiteOS,
246247
Serenity,
248+
SolanaOS,
247249
Vulkan, // Vulkan SPIR-V
248250
LastOSType = Vulkan
249251
};

llvm/lib/Analysis/TargetLibraryInfo.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -908,13 +908,6 @@ static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T,
908908
if (T.isOSAIX())
909909
TLI.setUnavailable(LibFunc_memrchr);
910910

911-
912-
if (T.isBPF() || T.isSBF()) {
913-
TLI.setUnavailable(LibFunc_rust_alloc);
914-
TLI.setUnavailable(LibFunc_rust_dealloc);
915-
TLI.setUnavailable(LibFunc_rust_realloc);
916-
}
917-
918911
TLI.addVectorizableFunctionsFromVecLib(ClVectorLibrary, T);
919912
}
920913

llvm/lib/MC/MCObjectFileInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T, bool Large) {
362362
break;
363363
case Triple::bpfel:
364364
case Triple::bpfeb:
365+
case Triple::sbf:
365366
FDECFIEncoding = dwarf::DW_EH_PE_sdata8;
366367
break;
367368
case Triple::hexagon:

llvm/lib/Target/BPF/BPFISelLowering.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ BPFTargetLowering::BPFTargetLowering(const TargetMachine &TM,
9898

9999
setOperationAction(ISD::SDIVREM, VT, Expand);
100100
setOperationAction(ISD::UDIVREM, VT, Expand);
101-
if (!STI.hasSdivSmod() && !Subtarget->isSolana()) {
101+
if (!STI.hasSdivSmod()) {
102102
setOperationAction(ISD::SDIV, VT, Custom);
103103
setOperationAction(ISD::SREM, VT, Custom);
104104
}
@@ -279,6 +279,10 @@ void BPFTargetLowering::ReplaceNodeResults(
279279
switch (Opcode) {
280280
default:
281281
report_fatal_error("unhandled custom legalization: " + Twine(Opcode));
282+
case ISD::ATOMIC_LOAD_ADD:
283+
case ISD::ATOMIC_LOAD_AND:
284+
case ISD::ATOMIC_LOAD_OR:
285+
case ISD::ATOMIC_LOAD_XOR:
282286
case ISD::ATOMIC_SWAP:
283287
case ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS:
284288
if (HasAlu32 || Opcode == ISD::ATOMIC_LOAD_ADD)

llvm/lib/Target/BPF/BPFRegisterInfo.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ static cl::opt<int>
3131
cl::desc("Specify the BPF stack size limit"),
3232
cl::init(512));
3333

34-
unsigned BPFRegisterInfo::FrameLength = 512;
35-
3634
BPFRegisterInfo::BPFRegisterInfo()
3735
: BPFGenRegisterInfo(BPF::R0) {}
3836

llvm/lib/Target/BPF/BPFSubtarget.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ BPFSubtarget &BPFSubtarget::initializeSubtargetDependencies(StringRef CPU,
5151
return *this;
5252
}
5353

54-
void BPFSubtarget::initializeEnvironment(const Triple &TT) {
55-
// TODO: jle: remove, sbf is now provided by the SBF backend.
56-
IsSolana = false;
54+
void BPFSubtarget::initializeEnvironment() {
5755
HasJmpExt = false;
5856
HasJmp32 = false;
5957
HasAlu32 = false;
@@ -103,10 +101,6 @@ BPFSubtarget::BPFSubtarget(const Triple &TT, const std::string &CPU,
103101
FrameLowering(initializeSubtargetDependencies(CPU, FS)),
104102
TLInfo(TM, *this) {
105103
IsLittleEndian = TT.isLittleEndian();
106-
<<<<<<< HEAD
107-
=======
108-
TSInfo.setSolanaFlag(false);
109-
>>>>>>> 3d16ab60503b ([SOL] Initial squash commit for new SBF LLVM back-end and related.)
110104

111105
CallLoweringInfo.reset(new BPFCallLowering(*getTargetLowering()));
112106
Legalizer.reset(new BPFLegalizerInfo(*this));

0 commit comments

Comments
 (0)