Skip to content

Commit d9b9208

Browse files
committed
s/iu/rex/g
Signed-off-by: Jinghao Jia <[email protected]>
1 parent 5fd73a5 commit d9b9208

File tree

9 files changed

+50
-49
lines changed

9 files changed

+50
-49
lines changed

llvm/include/llvm/Transforms/InnerUnikernels/IUProgType.def

Lines changed: 0 additions & 5 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- IUInsertEntry.h - IUEntryInsertion pass ------------------*- C++ -*-===//
1+
//===- RexInsertEntry.h - RexEntryInsertion pass ----------------*- C++ -*-===//
22
//
33
// Part of the Inner-Unikernels project, based on the LLVM project under
44
// the Apache License v2.0 with LLVM Exceptions.
@@ -9,13 +9,13 @@
99
/// \file
1010
///
1111
/// This file provides the primary interface to the entry-code-insertion
12-
/// pass for the Inner-Unikernels project. This pass is suitable for use in
13-
/// the new pass manager and it does not support the legacy pass manager.
12+
/// pass for the Rex project. This pass is suitable for use in the new pass
13+
/// managermanager and it does not support the legacy pass manager.
1414
///
1515
//===----------------------------------------------------------------------===//
1616

17-
#ifndef LLVM_TRANSFORMS_IUINSERTENTRY_H
18-
#define LLVM_TRANSFORMS_IUINSERTENTRY_H
17+
#ifndef LLVM_TRANSFORMS_REXINSERTENTRY_H
18+
#define LLVM_TRANSFORMS_REXINSERTENTRY_H
1919

2020
#include "llvm/ADT/ArrayRef.h"
2121
#include "llvm/ADT/StringRef.h"
@@ -26,17 +26,18 @@
2626
namespace llvm {
2727

2828
/// Pass to insert entry points for inner-unikernel programs
29-
class IUEntryInsertion : public PassInfoMixin<IUEntryInsertion> {
29+
class RexEntryInsertion : public PassInfoMixin<RexEntryInsertion> {
3030
bool runOnModule(Module &M) const;
3131
Function *insertEntry(Module &M, FunctionCallee &ProgRun,
3232
GlobalVariable *ProgObj, Type *CtxPT, StringRef Name,
3333
unsigned ProgType) const;
34-
AttributeList getIUFnAttr(LLVMContext &C) const;
34+
AttributeList getRexFnAttr(LLVMContext &C) const;
3535
void markUsedGlobalVariables(Module &M, ArrayRef<Constant *> Vec) const;
3636
void validateAndFinalizeSection(Function *EntryFn, GlobalVariable *ProgObj,
3737
unsigned ProgType) const;
3838
bool instrumentStack(Module &M, LLVMContext &C) const;
3939
Function *createTimeoutHandler(Module &M, LLVMContext &C) const;
40+
4041
bool Recursive;
4142

4243
public:
@@ -45,4 +46,4 @@ class IUEntryInsertion : public PassInfoMixin<IUEntryInsertion> {
4546

4647
} // namespace llvm
4748

48-
#endif /* LLVM_TRANSFORMS_IUINSERTENTRY_H */
49+
#endif /* LLVM_TRANSFORMS_REXINSERTENTRY_H */
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
REX_PROG_TYPE_1(BPF_PROG_TYPE_KPROBE, kprobe, "kprobe")
2+
REX_PROG_TYPE_1(BPF_PROG_TYPE_PERF_EVENT, perf_event, "perf_event")
3+
REX_PROG_TYPE_1(BPF_PROG_TYPE_XDP, xdp, "xdp")
4+
REX_PROG_TYPE_2(BPF_PROG_TYPE_SCHED_CLS, sched_cls, "classifier", "tc")
5+
REX_PROG_TYPE_2(BPF_PROG_TYPE_TRACEPOINT, tracepoint, "tracepoint", "tp")

llvm/lib/Passes/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ add_llvm_component_library(LLVMPasses
2323
Coroutines
2424
HipStdPar
2525
IPO
26-
InnerUnikernels
26+
Rex
2727
InstCombine
2828
IRPrinter
2929
ObjCARC

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@
178178
#include "llvm/Transforms/IPO/StripSymbols.h"
179179
#include "llvm/Transforms/IPO/SyntheticCountsPropagation.h"
180180
#include "llvm/Transforms/IPO/WholeProgramDevirt.h"
181-
#include "llvm/Transforms/InnerUnikernels/IUInsertEntry.h"
182181
#include "llvm/Transforms/InstCombine/InstCombine.h"
183182
#include "llvm/Transforms/Instrumentation.h"
184183
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
@@ -203,6 +202,7 @@
203202
#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
204203
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
205204
#include "llvm/Transforms/ObjCARC.h"
205+
#include "llvm/Transforms/Rex/RexInsertEntry.h"
206206
#include "llvm/Transforms/Scalar/ADCE.h"
207207
#include "llvm/Transforms/Scalar/AlignmentFromAssumptions.h"
208208
#include "llvm/Transforms/Scalar/AnnotationRemarks.h"

llvm/lib/Passes/PassRegistry.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ MODULE_PASS("tsan-module", ModuleThreadSanitizerPass())
144144
MODULE_PASS("verify", VerifierPass())
145145
MODULE_PASS("view-callgraph", CallGraphViewerPass())
146146
MODULE_PASS("wholeprogramdevirt", WholeProgramDevirtPass())
147-
MODULE_PASS("iu-entry-insertion", IUEntryInsertion())
147+
MODULE_PASS("rex-entry-insertion", RexEntryInsertion())
148148
#undef MODULE_PASS
149149

150150
#ifndef MODULE_PASS_WITH_PARAMS

llvm/lib/Transforms/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ add_subdirectory(ObjCARC)
99
add_subdirectory(Coroutines)
1010
add_subdirectory(CFGuard)
1111
add_subdirectory(HipStdPar)
12-
add_subdirectory(InnerUnikernels)
12+
add_subdirectory(Rex)

llvm/lib/Transforms/InnerUnikernels/CMakeLists.txt renamed to llvm/lib/Transforms/Rex/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
add_llvm_component_library( LLVMInnerUnikernels
2-
IUInsertEntry.cpp
1+
add_llvm_component_library( LLVMRex
2+
RexInsertEntry.cpp
33

44
ADDITIONAL_HEADER_DIRS
55
${LLVM_MAIN_INCLUDE_DIR}/llvm/Transforms
6-
${LLVM_MAIN_INCLUDE_DIR}/llvm/Transforms/InnerUnikernels
6+
${LLVM_MAIN_INCLUDE_DIR}/llvm/Transforms/Rex
77

88
DEPENDS
99
intrinsics_gen

llvm/lib/Transforms/InnerUnikernels/IUInsertEntry.cpp renamed to llvm/lib/Transforms/Rex/RexInsertEntry.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- IUInsertEntry.cpp - code to perform entry insertion for IU programs-===//
1+
//===- RexInsertEntry.cpp - code to perform entry insertion for Rex programs-===//
22
//
33
// Part of the Inner-Unikernels project, based on the LLVM project under
44
// the Apache License v2.0 with LLVM Exceptions.
@@ -8,14 +8,14 @@
88
//===----------------------------------------------------------------------===//
99
// This file implements the entry code insertion pass for Inner-Unikernels
1010
// programs. It generates a new function that calls into the __iu_entry_*()
11-
// functions in the kernel runtime crate for each global IU program
11+
// functions in the kernel runtime crate for each global Rex program
1212
// objects. The pass then sets the entry functions as "used" to prevent
1313
// link-time stripping using @llvm.used, which will automatically set the
1414
// "SHF_GNU_RETAIN" flag for these symbols.
1515
//
1616
//===----------------------------------------------------------------------===//
1717

18-
#include "llvm/Transforms/InnerUnikernels/IUInsertEntry.h"
18+
#include "llvm/Transforms/Rex/RexInsertEntry.h"
1919
#include "llvm/ADT/ArrayRef.h"
2020
#include "llvm/ADT/SCCIterator.h"
2121
#include "llvm/ADT/SmallVector.h"
@@ -52,41 +52,41 @@
5252

5353
using namespace llvm;
5454

55-
#define DEBUG_TYPE "iu-entry-insertion"
55+
#define DEBUG_TYPE "rex-entry-insertion"
5656

5757
STATISTIC(NumInserted, "Number of entry function inserted");
5858

5959
/// Validate program sections, the put the function and program object
6060
/// into appropriate sections
61-
void IUEntryInsertion::validateAndFinalizeSection(Function *EntryFn,
61+
void RexEntryInsertion::validateAndFinalizeSection(Function *EntryFn,
6262
GlobalVariable *ProgObj,
6363
unsigned ProgType) const {
6464
// We want to strip the "inner_unikernel/" prefix
6565
// strlen("inner_unikernel/") + 1 = 16
6666
EntryFn->setSection(ProgObj->getSection().substr(16));
6767
switch (ProgType) {
68-
#define IU_PROG_TYPE_1(ty_enum, ty_name, sec) \
68+
#define REX_PROG_TYPE_1(ty_enum, ty_name, sec) \
6969
case ty_enum: \
7070
ProgObj->setSection("obj" #ty_name); \
7171
assert(EntryFn->getSection().starts_with(sec) && "invalid section name"); \
7272
break;
73-
#define IU_PROG_TYPE_2(ty_enum, ty_name, sec1, sec2) \
73+
#define REX_PROG_TYPE_2(ty_enum, ty_name, sec1, sec2) \
7474
case ty_enum: \
7575
ProgObj->setSection("obj" #ty_name); \
7676
assert((EntryFn->getSection().starts_with(sec1) || \
7777
EntryFn->getSection().starts_with(sec2)) && \
7878
"invalid section name"); \
7979
break;
80-
#include "llvm/Transforms/InnerUnikernels/IUProgType.def"
81-
#undef IU_PROG_TYPE_1
82-
#undef IU_PROG_TYPE_2
80+
#include "llvm/Transforms/Rex/RexProgType.def"
81+
#undef REX_PROG_TYPE_1
82+
#undef REX_PROG_TYPE_2
8383
default:
8484
llvm_unreachable("Unknown prog type");
8585
}
8686
}
8787

8888
/// Performs the actual insertion of the new function
89-
Function *IUEntryInsertion::insertEntry(Module &M, FunctionCallee &ProgRun,
89+
Function *RexEntryInsertion::insertEntry(Module &M, FunctionCallee &ProgRun,
9090
GlobalVariable *ProgObj, Type *CtxPT,
9191
StringRef Name,
9292
unsigned ProgType) const {
@@ -98,7 +98,7 @@ Function *IUEntryInsertion::insertEntry(Module &M, FunctionCallee &ProgRun,
9898

9999
// Declare the function in module
100100
FunctionType *EntryTy = FunctionType::get(EntryRetty, EntryArgTys, false);
101-
FunctionCallee Entry = M.getOrInsertFunction(Name, EntryTy, getIUFnAttr(C));
101+
FunctionCallee Entry = M.getOrInsertFunction(Name, EntryTy, getRexFnAttr(C));
102102

103103
// Setup attributes
104104
Function *EntryFn = cast<Function>(Entry.getCallee());
@@ -126,8 +126,8 @@ Function *IUEntryInsertion::insertEntry(Module &M, FunctionCallee &ProgRun,
126126
return EntryFn;
127127
}
128128

129-
/// Sets all the needed attribute for the Rust IU programs
130-
AttributeList IUEntryInsertion::getIUFnAttr(LLVMContext &C) const {
129+
/// Sets all the needed attribute for the Rust Rex programs
130+
AttributeList RexEntryInsertion::getRexFnAttr(LLVMContext &C) const {
131131

132132
// SIMD extensions are not allowed in the kernel
133133
std::stringstream TargetFeatureSs;
@@ -151,7 +151,7 @@ AttributeList IUEntryInsertion::getIUFnAttr(LLVMContext &C) const {
151151

152152
/// Entry point of the pass, it looks at all the global variables to identify
153153
/// the inner-unikernel program variables
154-
bool IUEntryInsertion::runOnModule(Module &M) const {
154+
bool RexEntryInsertion::runOnModule(Module &M) const {
155155
bool Changed = false; // Whether transformation is actually made
156156
LLVMContext &C = M.getContext();
157157
SmallVector<GlobalValue *, 8> UsedGV;
@@ -179,17 +179,17 @@ bool IUEntryInsertion::runOnModule(Module &M) const {
179179

180180
std::string ProgRunName;
181181
switch (RTTI) {
182-
#define IU_PROG_TYPE_1(ty_enum, ty_name, sec) \
182+
#define REX_PROG_TYPE_1(ty_enum, ty_name, sec) \
183183
case ty_enum: \
184184
ProgRunName = "__iu_entry_" #ty_name; \
185185
break;
186-
#define IU_PROG_TYPE_2(ty_enum, ty_name, sec1, sec2) \
186+
#define REX_PROG_TYPE_2(ty_enum, ty_name, sec1, sec2) \
187187
case ty_enum: \
188188
ProgRunName = "__iu_entry_" #ty_name; \
189189
break;
190-
#include "llvm/Transforms/InnerUnikernels/IUProgType.def"
191-
#undef IU_PROG_TYPE_1
192-
#undef IU_PROG_TYPE_2
190+
#include "llvm/Transforms/Rex/RexProgType.def"
191+
#undef REX_PROG_TYPE_1
192+
#undef REX_PROG_TYPE_2
193193
default:
194194
errs() << "Unknown RTTI " << RTTI << "\n";
195195
}
@@ -210,7 +210,7 @@ bool IUEntryInsertion::runOnModule(Module &M) const {
210210
FunctionType *ProgRunTy =
211211
FunctionType::get(ProgRunRetty, ProgRunArgTys, false);
212212
FunctionCallee ProgRun =
213-
M.getOrInsertFunction(ProgRunName, ProgRunTy, getIUFnAttr(C));
213+
M.getOrInsertFunction(ProgRunName, ProgRunTy, getRexFnAttr(C));
214214

215215
// name: &'a str
216216
Constant *OP2 = CS->getOperand(2);
@@ -253,15 +253,15 @@ bool IUEntryInsertion::runOnModule(Module &M) const {
253253
return Changed;
254254
}
255255

256-
bool IUEntryInsertion::instrumentStack(Module &M, LLVMContext &C) const {
256+
bool RexEntryInsertion::instrumentStack(Module &M, LLVMContext &C) const {
257257
SmallVector<Instruction *, 32> WorkList;
258258
bool HasIndirect = false;
259259

260260
// Find all calls to other functions
261261
for (auto &F : M) {
262262
std::string Demangled;
263263
nonMicrosoftDemangle(F.getName().data(), Demangled);
264-
if (StringRef(Demangled).starts_with(StringRef("inner_unikernel_rt::")))
264+
if (StringRef(Demangled).starts_with(StringRef("rex::")))
265265
continue;
266266
for (auto &I : instructions(F)) {
267267
if (auto *CI = dyn_cast<CallBase>(&I)) {
@@ -285,7 +285,7 @@ bool IUEntryInsertion::instrumentStack(Module &M, LLVMContext &C) const {
285285
return false;
286286

287287
// No need to instrument if there is no indirect call and no recursion
288-
// will calculate the frame size in backend pass IUFrameSizePass
288+
// will calculate the frame size in backend pass RexFrameSizePass
289289
if (!HasIndirect && !Recursive)
290290
return false;
291291

@@ -300,7 +300,7 @@ bool IUEntryInsertion::instrumentStack(Module &M, LLVMContext &C) const {
300300

301301
FunctionType *CheckStackTy = FunctionType::get(Type::getVoidTy(C), {}, false);
302302
FunctionCallee CheckStack =
303-
M.getOrInsertFunction("__iu_check_stack", CheckStackTy, getIUFnAttr(C));
303+
M.getOrInsertFunction("__iu_check_stack", CheckStackTy, getRexFnAttr(C));
304304

305305
// Add the stack pointer instrumentation
306306
for (auto *I : WorkList) {
@@ -311,17 +311,17 @@ bool IUEntryInsertion::instrumentStack(Module &M, LLVMContext &C) const {
311311
return true;
312312
}
313313

314-
Function *IUEntryInsertion::createTimeoutHandler(Module &M,
314+
Function *RexEntryInsertion::createTimeoutHandler(Module &M,
315315
LLVMContext &C) const {
316316
// Rust uses void return type for noreturn (i.e. the "!" return type)
317317
FunctionType *TimeoutHandlerTy =
318318
FunctionType::get(Type::getVoidTy(C), {}, false);
319319
FunctionCallee TimeoutHandlerInner = M.getOrInsertFunction(
320-
"__iu_handle_timeout", TimeoutHandlerTy, getIUFnAttr(C));
320+
"__iu_handle_timeout", TimeoutHandlerTy, getRexFnAttr(C));
321321

322322
Function *TimeoutHandler = cast<Function>(
323323
M.getOrInsertFunction(M.getName().str() + "_iu_handle_timeout",
324-
TimeoutHandlerTy, getIUFnAttr(C))
324+
TimeoutHandlerTy, getRexFnAttr(C))
325325
.getCallee());
326326

327327
// Construct function body, starting with entry BB
@@ -338,7 +338,7 @@ Function *IUEntryInsertion::createTimeoutHandler(Module &M,
338338
}
339339

340340
/// Wrapper for the new pass manager
341-
PreservedAnalyses IUEntryInsertion::run(Module &M, ModuleAnalysisManager &AM) {
341+
PreservedAnalyses RexEntryInsertion::run(Module &M, ModuleAnalysisManager &AM) {
342342
// Run entry insertion pass
343343
Recursive = false;
344344
CallGraph &CG = AM.getResult<CallGraphAnalysis>(M);

0 commit comments

Comments
 (0)