MCPcopy Create free account
hub / github.com/GANGE666/xVMP / checkStackGuard

Method checkStackGuard

src/lib/CodeGen/SafeStack.cpp:463–481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461}
462
463void SafeStack::checkStackGuard(IRBuilder<> &IRB, Function &F, ReturnInst &RI,
464 AllocaInst *StackGuardSlot, Value *StackGuard) {
465 Value *V = IRB.CreateLoad(StackGuardSlot);
466 Value *Cmp = IRB.CreateICmpNE(StackGuard, V);
467
468 auto SuccessProb = BranchProbabilityInfo::getBranchProbStackProtector(true);
469 auto FailureProb = BranchProbabilityInfo::getBranchProbStackProtector(false);
470 MDNode *Weights = MDBuilder(F.getContext())
471 .createBranchWeights(SuccessProb.getNumerator(),
472 FailureProb.getNumerator());
473 Instruction *CheckTerm =
474 SplitBlockAndInsertIfThen(Cmp, &RI,
475 /* Unreachable */ true, Weights);
476 IRBuilder<> IRBFail(CheckTerm);
477 // FIXME: respect -fsanitize-trap / -ftrap-function here?
478 Constant *StackChkFail = F.getParent()->getOrInsertFunction(
479 "__stack_chk_fail", IRB.getVoidTy());
480 IRBFail.CreateCall(StackChkFail, {});
481}
482
483/// We explicitly compute and set the unsafe stack layout for all unsafe
484/// static alloca instructions. We save the unsafe "base pointer" in the

Callers

nothing calls this directly

Calls 10

MDBuilderClass · 0.85
CreateICmpNEMethod · 0.80
createBranchWeightsMethod · 0.80
getNumeratorMethod · 0.80
CreateLoadMethod · 0.45
getContextMethod · 0.45
getOrInsertFunctionMethod · 0.45
getParentMethod · 0.45
getVoidTyMethod · 0.45
CreateCallMethod · 0.45

Tested by

no test coverage detected