Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 0 additions & 1 deletion llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class StackInfoBuilder {

uint64_t getAllocaSizeInBytes(const AllocaInst &AI);
void alignAndPadAlloca(memtag::AllocaInfo &Info, llvm::Align Align);
bool isLifetimeIntrinsic(Value *V);

Value *readRegister(IRBuilder<> &IRB, StringRef Name);
Value *getFP(IRBuilder<> &IRB);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/AArch64StackTagging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ bool AArch64StackTagging::runOnFunction(Function &Fn) {
TagPCall->setName(Info.AI->getName() + ".tag");
// Does not replace metadata, so we don't have to handle DbgVariableRecords.
Info.AI->replaceUsesWithIf(TagPCall, [&](const Use &U) {
return !memtag::isLifetimeIntrinsic(U.getUser());
return !isa<LifetimeIntrinsic>(U.getUser());
});
TagPCall->setOperand(0, Info.AI);

Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Transforms/Coroutines/SpillUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,8 @@ struct AllocaUseVisitor : PtrUseVisitor<AllocaUseVisitor> {
if (auto *S = dyn_cast<StoreInst>(U))
if (S->getPointerOperand() == I)
continue;
if (auto *II = dyn_cast<IntrinsicInst>(U))
if (II->isLifetimeStartOrEnd())
continue;
if (isa<LifetimeIntrinsic>(U))
continue;
// BitCastInst creats aliases of the memory location being stored
// into.
if (auto *BI = dyn_cast<BitCastInst>(U)) {
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1518,8 +1518,7 @@ bool HWAddressSanitizer::instrumentStack(memtag::StackInfo &SInfo,

AI->replaceUsesWithIf(Replacement, [AICast, AILong](const Use &U) {
auto *User = U.getUser();
return User != AILong && User != AICast &&
!memtag::isLifetimeIntrinsic(User);
return User != AILong && User != AICast && !isa<LifetimeIntrinsic>(User);
});

memtag::annotateDebugRecords(Info, retagMask(N));
Expand Down
13 changes: 2 additions & 11 deletions llvm/lib/Transforms/Instrumentation/TypeSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,8 @@ void collectMemAccessInfo(
if (CallInst *CI = dyn_cast<CallInst>(&Inst))
maybeMarkSanitizerLibraryCallNoBuiltin(CI, &TLI);

if (isa<MemIntrinsic>(Inst)) {
if (isa<MemIntrinsic>(Inst) || isa<LifetimeIntrinsic>(Inst))
MemTypeResetInsts.push_back(&Inst);
} else if (auto *II = dyn_cast<IntrinsicInst>(&Inst)) {
if (II->getIntrinsicID() == Intrinsic::lifetime_start ||
II->getIntrinsicID() == Intrinsic::lifetime_end)
MemTypeResetInsts.push_back(&Inst);
}
} else if (isa<AllocaInst>(Inst)) {
MemTypeResetInsts.push_back(&Inst);
}
Expand Down Expand Up @@ -819,11 +814,7 @@ bool TypeSanitizer::instrumentMemInst(Value *V, Instruction *ShadowBase,
NeedsMemMove = isa<MemMoveInst>(MTI);
}
}
} else if (auto *II = dyn_cast<IntrinsicInst>(I)) {
if (II->getIntrinsicID() != Intrinsic::lifetime_start &&
II->getIntrinsicID() != Intrinsic::lifetime_end)
return false;

} else if (auto *II = dyn_cast<LifetimeIntrinsic>(I)) {
Size = II->getArgOperand(0);
Dest = II->getArgOperand(1);
} else if (auto *AI = dyn_cast<AllocaInst>(I)) {
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,9 +968,8 @@ bool MemCpyOptPass::performCallSlotOptzn(Instruction *cpyLoad,
append_range(srcUseList, U->users());
continue;
}
if (const auto *IT = dyn_cast<IntrinsicInst>(U))
if (IT->isLifetimeStartOrEnd())
continue;
if (isa<LifetimeIntrinsic>(U))
continue;

if (U != C && U != cpyLoad) {
LLVM_DEBUG(dbgs() << "Call slot: Source accessed by " << *U << "\n");
Expand Down
9 changes: 3 additions & 6 deletions llvm/lib/Transforms/Utils/CodeExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,13 +535,10 @@ void CodeExtractor::findAllocas(const CodeExtractorAnalysisCache &CEAC,

Instruction *Bitcast = cast<Instruction>(U);
for (User *BU : Bitcast->users()) {
IntrinsicInst *IntrInst = dyn_cast<IntrinsicInst>(BU);
IntrinsicInst *IntrInst = dyn_cast<LifetimeIntrinsic>(BU);
if (!IntrInst)
continue;

if (!IntrInst->isLifetimeStartOrEnd())
continue;

if (definedInRegion(Blocks, IntrInst))
continue;

Expand Down Expand Up @@ -1083,8 +1080,8 @@ static void eraseLifetimeMarkersOnInputs(const SetVector<BasicBlock *> &Blocks,
SetVector<Value *> &LifetimesStart) {
for (BasicBlock *BB : Blocks) {
for (Instruction &I : llvm::make_early_inc_range(*BB)) {
auto *II = dyn_cast<IntrinsicInst>(&I);
if (!II || !II->isLifetimeStartOrEnd())
auto *II = dyn_cast<LifetimeIntrinsic>(&I);
if (!II)
continue;

// Get the memory operand of the lifetime marker. If the underlying
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Transforms/Utils/InlineFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1777,9 +1777,8 @@ static Value *HandleByValArgument(Type *ByValType, Value *Arg,
// Check whether this Value is used by a lifetime intrinsic.
static bool isUsedByLifetimeMarker(Value *V) {
for (User *U : V->users())
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(U))
if (II->isLifetimeStartOrEnd())
return true;
if (isa<LifetimeIntrinsic>(U))
return true;
return false;
}

Expand Down
5 changes: 1 addition & 4 deletions llvm/lib/Transforms/Utils/Local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,7 @@ bool llvm::wouldInstructionBeTriviallyDead(const Instruction *I,
// are lifetime intrinsics then the intrinsics are dead.
if (isa<AllocaInst>(Arg) || isa<GlobalValue>(Arg) || isa<Argument>(Arg))
return llvm::all_of(Arg->uses(), [](Use &Use) {
if (IntrinsicInst *IntrinsicUse =
dyn_cast<IntrinsicInst>(Use.getUser()))
return IntrinsicUse->isLifetimeStartOrEnd();
return false;
return isa<LifetimeIntrinsic>(Use.getUser());
});
return false;
}
Expand Down
9 changes: 1 addition & 8 deletions llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ void StackInfoBuilder::visit(OptimizationRemarkEmitter &ORE,
}
return;
}
auto *II = dyn_cast<IntrinsicInst>(&Inst);
if (II && (II->getIntrinsicID() == Intrinsic::lifetime_start ||
II->getIntrinsicID() == Intrinsic::lifetime_end)) {
if (auto *II = dyn_cast<LifetimeIntrinsic>(&Inst)) {
AllocaInst *AI = findAllocaForValue(II->getArgOperand(1));
if (!AI) {
Info.UnrecognizedLifetimes.push_back(&Inst);
Expand Down Expand Up @@ -261,11 +259,6 @@ void alignAndPadAlloca(memtag::AllocaInfo &Info, llvm::Align Alignment) {
Info.AI = NewAI;
}

bool isLifetimeIntrinsic(Value *V) {
auto *II = dyn_cast<IntrinsicInst>(V);
return II && II->isLifetimeStartOrEnd();
}

Value *readRegister(IRBuilder<> &IRB, StringRef Name) {
Module *M = IRB.GetInsertBlock()->getParent()->getParent();
MDNode *MD =
Expand Down
16 changes: 1 addition & 15 deletions llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2187,20 +2187,6 @@ bool SimplifyCFGOpt::hoistSuccIdenticalTerminatorToSwitchOrIf(
return Changed;
}

// Check lifetime markers.
static bool isLifeTimeMarker(const Instruction *I) {
if (auto II = dyn_cast<IntrinsicInst>(I)) {
switch (II->getIntrinsicID()) {
default:
break;
case Intrinsic::lifetime_start:
case Intrinsic::lifetime_end:
return true;
}
}
return false;
}

// TODO: Refine this. This should avoid cases like turning constant memcpy sizes
// into variables.
static bool replacingOperandWithVariableIsCheap(const Instruction *I,
Expand Down Expand Up @@ -2321,7 +2307,7 @@ static bool canSinkInstructions(
// backend may handle such lifetimes incorrectly as well (#104776).
// Don't sink lifetimes if it would introduce a phi on the pointer
// argument.
if (isLifeTimeMarker(I0) && OI == 1 &&
if (isa<LifetimeIntrinsic>(I0) && OI == 1 &&
any_of(Insts, [](const Instruction *I) {
return isa<AllocaInst>(I->getOperand(1)->stripPointerCasts());
}))
Expand Down