forked from OSchip/llvm-project
CodeGen: minor style tweaks to SSP
Clean up some style related things in the StackProtector CodeGen. NFC. llvm-svn: 224693
This commit is contained in:
parent
23fd69560b
commit
90c224a143
|
@ -333,7 +333,7 @@ static CallInst *FindPotentialTailCall(BasicBlock *BB, ReturnInst *RI,
|
|||
/// Returns true if the platform/triple supports the stackprotectorcreate pseudo
|
||||
/// node.
|
||||
static bool CreatePrologue(Function *F, Module *M, ReturnInst *RI,
|
||||
const TargetLoweringBase *TLI, const Triple &Trip,
|
||||
const TargetLoweringBase *TLI, const Triple &TT,
|
||||
AllocaInst *&AI, Value *&StackGuardVar) {
|
||||
bool SupportsSelectionDAGSP = false;
|
||||
PointerType *PtrTy = Type::getInt8PtrTy(RI->getContext());
|
||||
|
@ -342,9 +342,10 @@ static bool CreatePrologue(Function *F, Module *M, ReturnInst *RI,
|
|||
Constant *OffsetVal =
|
||||
ConstantInt::get(Type::getInt32Ty(RI->getContext()), Offset);
|
||||
|
||||
StackGuardVar = ConstantExpr::getIntToPtr(
|
||||
OffsetVal, PointerType::get(PtrTy, AddressSpace));
|
||||
} else if (Trip.isOSOpenBSD()) {
|
||||
StackGuardVar =
|
||||
ConstantExpr::getIntToPtr(OffsetVal, PointerType::get(PtrTy,
|
||||
AddressSpace));
|
||||
} else if (TT.isOSOpenBSD()) {
|
||||
StackGuardVar = M->getOrInsertGlobal("__guard_local", PtrTy);
|
||||
cast<GlobalValue>(StackGuardVar)
|
||||
->setVisibility(GlobalValue::HiddenVisibility);
|
||||
|
@ -397,14 +398,13 @@ bool StackProtector::InsertStackProtectors() {
|
|||
InsertionPt = RI;
|
||||
// At this point we know that BB has a return statement so it *DOES*
|
||||
// have a terminator.
|
||||
assert(InsertionPt != nullptr && "BB must have a terminator instruction at "
|
||||
"this point.");
|
||||
assert(InsertionPt != nullptr &&
|
||||
"BB must have a terminator instruction at this point.");
|
||||
}
|
||||
|
||||
Function *Intrinsic =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::stackprotectorcheck);
|
||||
CallInst::Create(Intrinsic, StackGuardVar, "", InsertionPt);
|
||||
|
||||
} else {
|
||||
// If we do not support SelectionDAG based tail calls, generate IR level
|
||||
// tail calls.
|
||||
|
@ -467,7 +467,7 @@ bool StackProtector::InsertStackProtectors() {
|
|||
}
|
||||
}
|
||||
|
||||
// Return if we didn't modify any basic blocks. I.e., there are no return
|
||||
// Return if we didn't modify any basic blocks. i.e., there are no return
|
||||
// statements in the function.
|
||||
if (!HasPrologue)
|
||||
return false;
|
||||
|
@ -482,14 +482,16 @@ BasicBlock *StackProtector::CreateFailBB() {
|
|||
BasicBlock *FailBB = BasicBlock::Create(Context, "CallStackCheckFailBlk", F);
|
||||
IRBuilder<> B(FailBB);
|
||||
if (Trip.isOSOpenBSD()) {
|
||||
Constant *StackChkFail = M->getOrInsertFunction(
|
||||
"__stack_smash_handler", Type::getVoidTy(Context),
|
||||
Constant *StackChkFail =
|
||||
M->getOrInsertFunction("__stack_smash_handler",
|
||||
Type::getVoidTy(Context),
|
||||
Type::getInt8PtrTy(Context), nullptr);
|
||||
|
||||
B.CreateCall(StackChkFail, B.CreateGlobalStringPtr(F->getName(), "SSH"));
|
||||
} else {
|
||||
Constant *StackChkFail = M->getOrInsertFunction(
|
||||
"__stack_chk_fail", Type::getVoidTy(Context), nullptr);
|
||||
Constant *StackChkFail =
|
||||
M->getOrInsertFunction("__stack_chk_fail", Type::getVoidTy(Context),
|
||||
nullptr);
|
||||
B.CreateCall(StackChkFail);
|
||||
}
|
||||
B.CreateUnreachable();
|
||||
|
|
Loading…
Reference in New Issue