Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Fixes SjLj preparation step on iOS #12

Closed
wants to merge 4 commits into from
Closed
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
3 changes: 3 additions & 0 deletions include/llvm/InitializePasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ void initializeBBVectorizePass(PassRegistry&);
void initializeMachineFunctionPrinterPassPass(PassRegistry&);
void initializeStackMapLivenessPass(PassRegistry&);
void initializeLoadCombinePass(PassRegistry&);

// Specific to the rust-lang llvm branch:
void initializeNullCheckEliminationPass(PassRegistry&);
}

#endif
3 changes: 3 additions & 0 deletions include/llvm/LinkAllPasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ namespace {
(void) llvm::createScalarizerPass();
(void) llvm::createSeparateConstOffsetFromGEPPass();

// Specific to the rust-lang llvm branch:
(void) llvm::createNullCheckEliminationPass();

(void)new llvm::IntervalPartition();
(void)new llvm::FindUsedTypes();
(void)new llvm::ScalarEvolution();
Expand Down
7 changes: 7 additions & 0 deletions include/llvm/Transforms/Scalar.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,13 @@ FunctionPass *createSeparateConstOffsetFromGEPPass();
//
BasicBlockPass *createLoadCombinePass();

// Specific to the rust-lang llvm branch:
//===----------------------------------------------------------------------===//
//
// NullCheckElimination - Eliminate null checks.
//
FunctionPass *createNullCheckEliminationPass();

} // End llvm namespace

#endif
22 changes: 11 additions & 11 deletions lib/CodeGen/SjLjEHPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,18 @@ void SjLjEHPrepare::lowerIncomingArguments(Function &F) {
++AI) {
Type *Ty = AI->getType();

// Aggregate types can't be cast, but are legal argument types, so we have
// to handle them differently. We use an extract/insert pair as a
// lightweight method to achieve the same goal.
if (isa<StructType>(Ty) || isa<ArrayType>(Ty)) {
Instruction *EI = ExtractValueInst::Create(AI, 0, "", AfterAllocaInsPt);
Instruction *NI = InsertValueInst::Create(AI, EI, 0);
NI->insertAfter(EI);
AI->replaceAllUsesWith(NI);

// Set the operand of the instructions back to the AllocaInst.
EI->setOperand(0, AI);
NI->setOperand(0, AI);
// Aggregate types can't be cast, but are legal argument types,
// so we have to handle them differently. We use
// select i8 true, %arg, undef to achieve the same goal
Value *TrueValue = ConstantInt::getTrue(F.getContext());
Value *UndefValue = UndefValue::get(Ty);
Instruction *SI = SelectInst::Create(TrueValue, AI, UndefValue,
AI->getName() + ".tmp",
AfterAllocaInsPt);
AI->replaceAllUsesWith(SI);

SI->setOperand(1, AI);
} else {
// This is always a no-op cast because we're casting AI to AI->getType()
// so src and destination types are identical. BitCast is the only
Expand Down
4 changes: 4 additions & 0 deletions lib/Transforms/IPO/PassManagerBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) {
MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
MPM.add(createJumpThreadingPass()); // Thread jumps.
MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals
// Specific to the rust-lang llvm branch:
MPM.add(createNullCheckEliminationPass()); // Eliminate null checks
MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
MPM.add(createInstructionCombiningPass()); // Combine silly seq's
addExtensionsToPM(EP_Peephole, MPM);
Expand Down Expand Up @@ -218,6 +220,8 @@ void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) {
addExtensionsToPM(EP_Peephole, MPM);
MPM.add(createJumpThreadingPass()); // Thread jumps
MPM.add(createCorrelatedValuePropagationPass());
// Specific to the rust-lang llvm branch:
MPM.add(createNullCheckEliminationPass()); // Eliminate null checks
MPM.add(createDeadStoreEliminationPass()); // Delete dead stores

addExtensionsToPM(EP_ScalarOptimizerLate, MPM);
Expand Down
1 change: 1 addition & 0 deletions lib/Transforms/Scalar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ add_llvm_library(LLVMScalarOpts
LoopUnswitch.cpp
LowerAtomic.cpp
MemCpyOptimizer.cpp
NullCheckElimination.cpp
PartiallyInlineLibCalls.cpp
Reassociate.cpp
Reg2Mem.cpp
Expand Down
Loading