Skip to content

Commit 075b6d9

Browse files
committed
migrate remaining 'iu' names to 'rex'
Signed-off-by: Jinghao Jia <[email protected]>
1 parent d9b9208 commit 075b6d9

File tree

9 files changed

+55
-57
lines changed

9 files changed

+55
-57
lines changed

llvm/include/llvm/CodeGen/AsmPrinter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ class AsmPrinter : public MachineFunctionPass {
421421
/// Emits the PC sections collected from instructions.
422422
void emitPCSections(const MachineFunction &MF);
423423

424-
void checkStackUsageIU(const MachineFunction &MF) const;
424+
void checkStackUsageRex(const MachineFunction &MF) const;
425425

426426
/// Get the CFISection type for a function.
427427
CFISection getFunctionCFISectionType(const Function &F) const;

llvm/include/llvm/Target/TargetOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ namespace llvm {
382382
unsigned XCOFFReadOnlyPointers : 1;
383383

384384
/// Inner-unikernel flag
385-
unsigned IUEnabled : 1;
385+
unsigned RexEnabled : 1;
386386

387387
/// Name of the stack usage file (i.e., .su file) if user passes
388388
/// -fstack-usage. If empty, it can be implied that -fstack-usage is not

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@ static bool needFuncLabels(const MachineFunction &MF,
16841684
classifyEHPersonality(MF.getFunction().getPersonalityFn()));
16851685
}
16861686

1687-
void AsmPrinter::checkStackUsageIU(const MachineFunction &MF) const {
1687+
void AsmPrinter::checkStackUsageRex(const MachineFunction &MF) const {
16881688
unsigned Limit = 0x1000;
16891689
const MachineFrameInfo &FrameInfo = MF.getFrameInfo();
16901690

@@ -1695,7 +1695,7 @@ void AsmPrinter::checkStackUsageIU(const MachineFunction &MF) const {
16951695
raw_string_ostream OS(ErrMsg);
16961696
OS << "Stack usage exceeded limit of 4096 bytes"
16971697
<< " for function " << MF.getName()
1698-
<< " in inner-unikernel module "
1698+
<< " in Rex module "
16991699
<< MF.getFunction().getParent()->getName();
17001700
}
17011701
report_fatal_error(StringRef(ErrMsg));
@@ -1705,7 +1705,7 @@ void AsmPrinter::checkStackUsageIU(const MachineFunction &MF) const {
17051705
raw_string_ostream OS(ErrMsg);
17061706
OS << "Stack contains variable sized objects"
17071707
<< " for function " << MF.getName()
1708-
<< " in inner-unikernel module "
1708+
<< " in Rex module "
17091709
<< MF.getFunction().getParent()->getName();
17101710
}
17111711
report_fatal_error(StringRef(ErrMsg));
@@ -2038,8 +2038,8 @@ void AsmPrinter::emitFunctionBody() {
20382038
emitStackUsage(*MF);
20392039

20402040
// Check the stack usage for inner-unikernel programs
2041-
if (MF->getTarget().Options.IUEnabled)
2042-
checkStackUsageIU(*MF);
2041+
if (MF->getTarget().Options.RexEnabled)
2042+
checkStackUsageRex(*MF);
20432043

20442044
emitPatchableFunctionEntries();
20452045

llvm/lib/Target/X86/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ set(sources
8989
GISel/X86InstructionSelector.cpp
9090
GISel/X86LegalizerInfo.cpp
9191
GISel/X86RegisterBankInfo.cpp
92-
X86IUFrameSize.cpp
92+
X86RexFrameSize.cpp
9393
)
9494

9595
add_llvm_target(X86CodeGen ${sources}

llvm/lib/Target/X86/X86.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ FunctionPass *createX86LoadValueInjectionRetHardeningPass();
170170
FunctionPass *createX86SpeculativeLoadHardeningPass();
171171
FunctionPass *createX86SpeculativeExecutionSideEffectSuppression();
172172
FunctionPass *createX86ArgumentStackSlotPass();
173-
ModulePass *createX86IUFrameSizePass();
173+
ModulePass *createX86RexFrameSizePass();
174174

175175
void initializeCompressEVEXPassPass(PassRegistry &);
176176
void initializeFPSPass(PassRegistry &);
@@ -205,7 +205,7 @@ void initializeX86ReturnThunksPass(PassRegistry &);
205205
void initializeX86SpeculativeExecutionSideEffectSuppressionPass(PassRegistry &);
206206
void initializeX86SpeculativeLoadHardeningPassPass(PassRegistry &);
207207
void initializeX86TileConfigPass(PassRegistry &);
208-
void initializeX86IUFrameSizePassPass(PassRegistry &);
208+
void initializeX86RexFrameSizePassPass(PassRegistry &);
209209

210210
namespace X86AS {
211211
enum : unsigned {

llvm/lib/Target/X86/X86IUFrameSize.cpp renamed to llvm/lib/Target/X86/X86RexFrameSize.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222

2323
using namespace llvm;
2424

25-
#define X86IUFrameSizePassName "X86 frame buffer size check"
25+
#define X86RexFrameSizePassName "X86 frame buffer size check"
2626
#define PASS_KEY "x86-frame-buffer-size"
2727
#define DEBUG_TYPE PASS_KEY
2828

2929
namespace {
3030

31-
class X86IUFrameSizePassMF {
31+
class X86RexFrameSizePassMF {
3232
public:
33-
X86IUFrameSizePassMF(const Module *M, const MachineModuleInfo *MMI)
33+
X86RexFrameSizePassMF(const Module *M, const MachineModuleInfo *MMI)
3434
: M(M), MMI(MMI) {}
3535
bool run();
3636
void runOnMachineFunction(MachineFunction &MF);
@@ -45,13 +45,13 @@ class X86IUFrameSizePassMF {
4545
static constexpr uint64_t FrameSizeLimit = (0x1000UL << 2) - 0x1000;
4646
};
4747

48-
class X86IUFrameSizePass : public ModulePass {
48+
class X86RexFrameSizePass : public ModulePass {
4949
public:
5050
static char ID;
5151

52-
X86IUFrameSizePass() : ModulePass(ID) {}
52+
X86RexFrameSizePass() : ModulePass(ID) {}
5353
bool runOnModule(Module &M) override;
54-
StringRef getPassName() const override { return X86IUFrameSizePassName; }
54+
StringRef getPassName() const override { return X86RexFrameSizePassName; }
5555
void getAnalysisUsage(AnalysisUsage &AU) const override {
5656
AU.addRequired<MachineModuleInfoWrapperPass>();
5757
AU.setPreservesAll();
@@ -61,39 +61,39 @@ class X86IUFrameSizePass : public ModulePass {
6161

6262
} // end anonymous namespace
6363

64-
char X86IUFrameSizePass::ID = 0;
64+
char X86RexFrameSizePass::ID = 0;
6565

66-
INITIALIZE_PASS(X86IUFrameSizePass, PASS_KEY, X86IUFrameSizePassName, false,
66+
INITIALIZE_PASS(X86RexFrameSizePass, PASS_KEY, X86RexFrameSizePassName, false,
6767
true)
6868

69-
ModulePass *llvm::createX86IUFrameSizePass() {
70-
return new X86IUFrameSizePass();
69+
ModulePass *llvm::createX86RexFrameSizePass() {
70+
return new X86RexFrameSizePass();
7171
}
7272

73-
bool X86IUFrameSizePass::runOnModule(Module &M) {
73+
bool X86RexFrameSizePass::runOnModule(Module &M) {
7474
const MachineModuleInfo *MMI =
7575
&getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
76-
return X86IUFrameSizePassMF(&M, MMI).run();
76+
return X86RexFrameSizePassMF(&M, MMI).run();
7777
}
7878

79-
bool X86IUFrameSizePassMF::run() {
79+
bool X86RexFrameSizePassMF::run() {
8080

8181
bool Failed = false;
8282

83-
// check for iu-stack iu-indirect-call and recursion
84-
NamedMDNode *IUStackMD = M->getNamedMetadata("iu-stack");
83+
// check for rex-stack rex-indirect-call and recursion
84+
NamedMDNode *RexStackMD = M->getNamedMetadata("rex-stack");
8585

86-
if (IUStackMD) {
87-
for (unsigned I = 0, E = IUStackMD->getNumOperands(); I != E; ++I) {
88-
MDNode *Node = IUStackMD->getOperand(I);
86+
if (RexStackMD) {
87+
for (unsigned I = 0, E = RexStackMD->getNumOperands(); I != E; ++I) {
88+
MDNode *Node = RexStackMD->getOperand(I);
8989
if (MDString *Str = dyn_cast<MDString>(Node->getOperand(0))) {
9090
StringRef Value = Str->getString();
9191

9292
// skip pass with recursion
93-
if (Value == "iu-recursion")
93+
if (Value == "rex-recursion")
9494
Failed |= true;
9595

96-
if (Value == "iu-indirect-call")
96+
if (Value == "rex-indirect-call")
9797
Failed |= true;
9898
}
9999
}
@@ -104,12 +104,12 @@ bool X86IUFrameSizePassMF::run() {
104104

105105
SmallVector<StringRef, 32> WorkList;
106106

107-
// get the iu-program function name
108-
NamedMDNode *IUProgMD = M->getNamedMetadata("iu-programs");
107+
// get the rex-program function name
108+
NamedMDNode *RexProgMD = M->getNamedMetadata("rex-programs");
109109

110-
if (IUProgMD) {
111-
for (unsigned I = 0, E = IUProgMD->getNumOperands(); I != E; ++I) {
112-
MDNode *Node = IUProgMD->getOperand(I);
110+
if (RexProgMD) {
111+
for (unsigned I = 0, E = RexProgMD->getNumOperands(); I != E; ++I) {
112+
MDNode *Node = RexProgMD->getOperand(I);
113113
if (MDString *Str = dyn_cast<MDString>(Node->getOperand(0))) {
114114

115115
// add entry function to the worklist
@@ -146,7 +146,7 @@ bool X86IUFrameSizePassMF::run() {
146146
return false;
147147
}
148148

149-
void X86IUFrameSizePassMF::runOnMachineFunction(MachineFunction &MF) {
149+
void X86RexFrameSizePassMF::runOnMachineFunction(MachineFunction &MF) {
150150
uint64_t FrameSize = getFrameSize(MF);
151151
if (FrameSize > FrameSizeLimit) {
152152
std::string ErrMsg;
@@ -160,7 +160,7 @@ void X86IUFrameSizePassMF::runOnMachineFunction(MachineFunction &MF) {
160160
}
161161
}
162162

163-
uint64_t X86IUFrameSizePassMF::getFrameSize(const MachineFunction &MF) {
163+
uint64_t X86RexFrameSizePassMF::getFrameSize(const MachineFunction &MF) {
164164

165165
using FrameSizeEntry = std::pair<const MachineFunction *, uint64_t>;
166166

llvm/lib/Target/X86/X86TargetMachine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86Target() {
9999
initializeX86FlagsCopyLoweringPassPass(PR);
100100
initializeX86LoadValueInjectionLoadHardeningPassPass(PR);
101101
initializeX86LoadValueInjectionRetHardeningPassPass(PR);
102-
initializeX86IUFrameSizePassPass(PR);
102+
initializeX86RexFrameSizePassPass(PR);
103103
initializeX86OptimizeLEAPassPass(PR);
104104
initializeX86PartialReductionPass(PR);
105105
initializePseudoProbeInserterPass(PR);
@@ -653,7 +653,7 @@ void X86PassConfig::addPreEmitPass2() {
653653

654654
// Insert pseudo probe annotation for callsite profiling
655655
addPass(createPseudoProbeInserter());
656-
addPass(createX86IUFrameSizePass());
656+
addPass(createX86RexFrameSizePass());
657657

658658
// KCFI indirect call checks are lowered to a bundle, and on Darwin platforms,
659659
// also CALL_RVMARKER.

llvm/lib/Transforms/Rex/RexInsertEntry.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
//===----------------------------------------------------------------------===//
99
// This file implements the entry code insertion pass for Inner-Unikernels
10-
// programs. It generates a new function that calls into the __iu_entry_*()
10+
// programs. It generates a new function that calls into the __rex_entry_*()
1111
// 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
@@ -62,8 +62,8 @@ void RexEntryInsertion::validateAndFinalizeSection(Function *EntryFn,
6262
GlobalVariable *ProgObj,
6363
unsigned ProgType) const {
6464
// We want to strip the "inner_unikernel/" prefix
65-
// strlen("inner_unikernel/") + 1 = 16
66-
EntryFn->setSection(ProgObj->getSection().substr(16));
65+
// strlen("rex/") = 4
66+
EntryFn->setSection(ProgObj->getSection().substr(4));
6767
switch (ProgType) {
6868
#define REX_PROG_TYPE_1(ty_enum, ty_name, sec) \
6969
case ty_enum: \
@@ -159,13 +159,13 @@ bool RexEntryInsertion::runOnModule(Module &M) const {
159159
// Perform stack depth instrumentation
160160
Changed |= instrumentStack(M, C);
161161

162-
NamedMDNode *NamedMD = M.getOrInsertNamedMetadata("iu-programs");
162+
NamedMDNode *NamedMD = M.getOrInsertNamedMetadata("rex-programs");
163163

164164
LLVMContext &Context = M.getContext();
165165

166166
// Traverse all Global variables
167167
for (GlobalVariable &G : M.globals()) {
168-
if (G.hasSection() && G.getSection().starts_with("inner_unikernel")) {
168+
if (G.hasSection() && G.getSection().starts_with("rex")) {
169169
Constant *Init = G.getInitializer();
170170
auto *CS = cast<ConstantStruct>(Init);
171171

@@ -181,11 +181,11 @@ bool RexEntryInsertion::runOnModule(Module &M) const {
181181
switch (RTTI) {
182182
#define REX_PROG_TYPE_1(ty_enum, ty_name, sec) \
183183
case ty_enum: \
184-
ProgRunName = "__iu_entry_" #ty_name; \
184+
ProgRunName = "__rex_entry_" #ty_name; \
185185
break;
186186
#define REX_PROG_TYPE_2(ty_enum, ty_name, sec1, sec2) \
187187
case ty_enum: \
188-
ProgRunName = "__iu_entry_" #ty_name; \
188+
ProgRunName = "__rex_entry_" #ty_name; \
189189
break;
190190
#include "llvm/Transforms/Rex/RexProgType.def"
191191
#undef REX_PROG_TYPE_1
@@ -240,7 +240,7 @@ bool RexEntryInsertion::runOnModule(Module &M) const {
240240
// Make sure the timeout handler is always in the final executable
241241
UsedGV.push_back(createTimeoutHandler(M, C));
242242

243-
// Mark the Variables (i.e. inserted functions and iu-prog objects) as
243+
// Mark the Variables (i.e. inserted functions and rex-prog objects) as
244244
// used as these symbols are typically considered as dead code during the
245245
// linking stage if the '--gc-sections' option is supplied to the linker.
246246
// Marking the symbols as used would add the 'SHF_GNU_RETAIN' flag and
@@ -291,16 +291,16 @@ bool RexEntryInsertion::instrumentStack(Module &M, LLVMContext &C) const {
291291

292292
// Add metadata to backend pass
293293
if (HasIndirect) {
294-
NamedMDNode *NamedMD = M.getOrInsertNamedMetadata("iu-stack");
294+
NamedMDNode *NamedMD = M.getOrInsertNamedMetadata("rex-stack");
295295
LLVMContext &Context = M.getContext();
296-
Metadata *Str = MDString::get(Context, "iu-indirect-call");
296+
Metadata *Str = MDString::get(Context, "rex-indirect-call");
297297
MDNode *Node = MDNode::get(Context, Str);
298298
NamedMD->addOperand(Node);
299299
}
300300

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

305305
// Add the stack pointer instrumentation
306306
for (auto *I : WorkList) {
@@ -317,18 +317,18 @@ Function *RexEntryInsertion::createTimeoutHandler(Module &M,
317317
FunctionType *TimeoutHandlerTy =
318318
FunctionType::get(Type::getVoidTy(C), {}, false);
319319
FunctionCallee TimeoutHandlerInner = M.getOrInsertFunction(
320-
"__iu_handle_timeout", TimeoutHandlerTy, getRexFnAttr(C));
320+
"__rex_handle_timeout", TimeoutHandlerTy, getRexFnAttr(C));
321321

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

327327
// Construct function body, starting with entry BB
328328
BasicBlock *EntryBB = BasicBlock::Create(C, "start", TimeoutHandler);
329329
IRBuilder<> InstBuilder(EntryBB);
330330

331-
// Construct call to __iu_handle_timeout
331+
// Construct call to __rex_handle_timeout
332332
InstBuilder.CreateCall(TimeoutHandlerInner.getFunctionType(),
333333
TimeoutHandlerInner.getCallee(), {});
334334

@@ -354,9 +354,9 @@ PreservedAnalyses RexEntryInsertion::run(Module &M, ModuleAnalysisManager &AM) {
354354

355355
if (Recursive) {
356356
errs() << "Found recursive call graph with Module " << M.getName() << "\n";
357-
NamedMDNode *NamedMD = M.getOrInsertNamedMetadata("iu-stack");
357+
NamedMDNode *NamedMD = M.getOrInsertNamedMetadata("rex-stack");
358358
LLVMContext &Context = M.getContext();
359-
Metadata *Str = MDString::get(Context, "iu-recursion");
359+
Metadata *Str = MDString::get(Context, "rex-recursion");
360360
MDNode *Node = MDNode::get(Context, Str);
361361
NamedMD->addOperand(Node);
362362
}

llvm/utils/gn/secondary/llvm/lib/Target/X86/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ static_library("LLVMX86CodeGen") {
143143
"X86VZeroUpper.cpp",
144144
"X86WinEHState.cpp",
145145
"X86WinFixupBufferSecurityCheck.cpp",
146-
"X86IUFrameBufferPass.cpp",
147-
"X86IUFrameSize.cpp",
148146
]
149147
}
150148

0 commit comments

Comments
 (0)