diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-12-18 20:30:12 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-19 21:23:40 +0000 |
| commit | bdbe302c3396ceb4dd89d1214485439598f05368 (patch) | |
| tree | ccf66c6349b23061ed5e9645c21f15fbe718da8b /contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp | |
| parent | e7a1904fe1ced461b2a31f03b6592ae6564a243a (diff) | |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp b/contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp index 387b653f8815..48dc7cb232e3 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp @@ -178,8 +178,7 @@ static bool HasAddressTaken(const Instruction *AI, TypeSize AllocSize, // the bounds of the allocated object. std::optional<MemoryLocation> MemLoc = MemoryLocation::getOrNone(I); if (MemLoc && MemLoc->Size.hasValue() && - !TypeSize::isKnownGE(AllocSize, - TypeSize::getFixed(MemLoc->Size.getValue()))) + !TypeSize::isKnownGE(AllocSize, MemLoc->Size.getValue())) return true; switch (I->getOpcode()) { case Instruction::Store: @@ -216,14 +215,14 @@ static bool HasAddressTaken(const Instruction *AI, TypeSize AllocSize, APInt Offset(IndexSize, 0); if (!GEP->accumulateConstantOffset(DL, Offset)) return true; - TypeSize OffsetSize = TypeSize::Fixed(Offset.getLimitedValue()); + TypeSize OffsetSize = TypeSize::getFixed(Offset.getLimitedValue()); if (!TypeSize::isKnownGT(AllocSize, OffsetSize)) return true; // Adjust AllocSize to be the space remaining after this offset. // We can't subtract a fixed size from a scalable one, so in that case // assume the scalable value is of minimum size. TypeSize NewAllocSize = - TypeSize::Fixed(AllocSize.getKnownMinValue()) - OffsetSize; + TypeSize::getFixed(AllocSize.getKnownMinValue()) - OffsetSize; if (HasAddressTaken(I, NewAllocSize, M, VisitedPHIs)) return true; break; @@ -419,7 +418,7 @@ static Value *getStackGuard(const TargetLoweringBase *TLI, Module *M, Value *Guard = TLI->getIRStackGuard(B); StringRef GuardMode = M->getStackProtectorGuard(); if ((GuardMode == "tls" || GuardMode.empty()) && Guard) - return B.CreateLoad(B.getInt8PtrTy(), Guard, true, "StackGuard"); + return B.CreateLoad(B.getPtrTy(), Guard, true, "StackGuard"); // Use SelectionDAG SSP handling, since there isn't an IR guard. // @@ -452,7 +451,7 @@ static bool CreatePrologue(Function *F, Module *M, Instruction *CheckLoc, const TargetLoweringBase *TLI, AllocaInst *&AI) { bool SupportsSelectionDAGSP = false; IRBuilder<> B(&F->getEntryBlock().front()); - PointerType *PtrTy = Type::getInt8PtrTy(CheckLoc->getContext()); + PointerType *PtrTy = PointerType::getUnqual(CheckLoc->getContext()); AI = B.CreateAlloca(PtrTy, nullptr, "StackGuardSlot"); Value *GuardSlot = getStackGuard(TLI, M, B, &SupportsSelectionDAGSP); @@ -540,7 +539,7 @@ bool StackProtector::InsertStackProtectors() { // Generate the function-based epilogue instrumentation. // The target provides a guard check function, generate a call to it. IRBuilder<> B(CheckLoc); - LoadInst *Guard = B.CreateLoad(B.getInt8PtrTy(), AI, true, "Guard"); + LoadInst *Guard = B.CreateLoad(B.getPtrTy(), AI, true, "Guard"); CallInst *Call = B.CreateCall(GuardCheck, {Guard}); Call->setAttributes(GuardCheck->getAttributes()); Call->setCallingConv(GuardCheck->getCallingConv()); @@ -579,7 +578,7 @@ bool StackProtector::InsertStackProtectors() { IRBuilder<> B(CheckLoc); Value *Guard = getStackGuard(TLI, M, B); - LoadInst *LI2 = B.CreateLoad(B.getInt8PtrTy(), AI, true); + LoadInst *LI2 = B.CreateLoad(B.getPtrTy(), AI, true); auto *Cmp = cast<ICmpInst>(B.CreateICmpNE(Guard, LI2)); auto SuccessProb = BranchProbabilityInfo::getBranchProbStackProtector(true); @@ -623,7 +622,7 @@ BasicBlock *StackProtector::CreateFailBB() { if (Trip.isOSOpenBSD()) { StackChkFail = M->getOrInsertFunction("__stack_smash_handler", Type::getVoidTy(Context), - Type::getInt8PtrTy(Context)); + PointerType::getUnqual(Context)); Args.push_back(B.CreateGlobalStringPtr(F->getName(), "SSH")); } else { StackChkFail = |
