Skip to content

Commit 9ac874f

Browse files
committed
[nfc] [mte] use InstrIter.
this improves code clarity.
1 parent 019f022 commit 9ac874f

File tree

1 file changed

+34
-35
lines changed

1 file changed

+34
-35
lines changed

llvm/lib/Target/AArch64/AArch64StackTagging.cpp

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "llvm/IR/Function.h"
4343
#include "llvm/IR/GetElementPtrTypeIterator.h"
4444
#include "llvm/IR/IRBuilder.h"
45+
#include "llvm/IR/InstIterator.h"
4546
#include "llvm/IR/Instruction.h"
4647
#include "llvm/IR/Instructions.h"
4748
#include "llvm/IR/IntrinsicInst.h"
@@ -543,46 +544,44 @@ bool AArch64StackTagging::runOnFunction(Function &Fn) {
543544
SmallVector<Instruction *, 4> UnrecognizedLifetimes;
544545

545546
bool CallsReturnTwice = false;
546-
for (auto &BB : *F) {
547-
for (Instruction &I : BB) {
548-
if (CallInst *CI = dyn_cast<CallInst>(&I)) {
549-
if (CI->canReturnTwice()) {
550-
CallsReturnTwice = true;
551-
}
552-
}
553-
if (auto *AI = dyn_cast<AllocaInst>(&I)) {
554-
Allocas[AI].AI = AI;
555-
Allocas[AI].OldAI = AI;
556-
continue;
547+
for (Instruction &I : instructions(F)) {
548+
if (CallInst *CI = dyn_cast<CallInst>(&I)) {
549+
if (CI->canReturnTwice()) {
550+
CallsReturnTwice = true;
557551
}
552+
}
553+
if (auto *AI = dyn_cast<AllocaInst>(&I)) {
554+
Allocas[AI].AI = AI;
555+
Allocas[AI].OldAI = AI;
556+
continue;
557+
}
558558

559-
if (auto *DVI = dyn_cast<DbgVariableIntrinsic>(&I)) {
560-
for (Value *V : DVI->location_ops())
561-
if (auto *AI = dyn_cast_or_null<AllocaInst>(V))
562-
if (Allocas[AI].DbgVariableIntrinsics.empty() ||
563-
Allocas[AI].DbgVariableIntrinsics.back() != DVI)
564-
Allocas[AI].DbgVariableIntrinsics.push_back(DVI);
565-
continue;
566-
}
559+
if (auto *DVI = dyn_cast<DbgVariableIntrinsic>(&I)) {
560+
for (Value *V : DVI->location_ops())
561+
if (auto *AI = dyn_cast_or_null<AllocaInst>(V))
562+
if (Allocas[AI].DbgVariableIntrinsics.empty() ||
563+
Allocas[AI].DbgVariableIntrinsics.back() != DVI)
564+
Allocas[AI].DbgVariableIntrinsics.push_back(DVI);
565+
continue;
566+
}
567567

568-
auto *II = dyn_cast<IntrinsicInst>(&I);
569-
if (II && (II->getIntrinsicID() == Intrinsic::lifetime_start ||
570-
II->getIntrinsicID() == Intrinsic::lifetime_end)) {
571-
AllocaInst *AI = findAllocaForValue(II->getArgOperand(1));
572-
if (!AI) {
573-
UnrecognizedLifetimes.push_back(&I);
574-
continue;
575-
}
576-
if (II->getIntrinsicID() == Intrinsic::lifetime_start)
577-
Allocas[AI].LifetimeStart.push_back(II);
578-
else
579-
Allocas[AI].LifetimeEnd.push_back(II);
568+
auto *II = dyn_cast<IntrinsicInst>(&I);
569+
if (II && (II->getIntrinsicID() == Intrinsic::lifetime_start ||
570+
II->getIntrinsicID() == Intrinsic::lifetime_end)) {
571+
AllocaInst *AI = findAllocaForValue(II->getArgOperand(1));
572+
if (!AI) {
573+
UnrecognizedLifetimes.push_back(&I);
574+
continue;
580575
}
581-
582-
Instruction *ExitUntag = getUntagLocationIfFunctionExit(I);
583-
if (ExitUntag)
584-
RetVec.push_back(ExitUntag);
576+
if (II->getIntrinsicID() == Intrinsic::lifetime_start)
577+
Allocas[AI].LifetimeStart.push_back(II);
578+
else
579+
Allocas[AI].LifetimeEnd.push_back(II);
585580
}
581+
582+
Instruction *ExitUntag = getUntagLocationIfFunctionExit(I);
583+
if (ExitUntag)
584+
RetVec.push_back(ExitUntag);
586585
}
587586

588587
if (Allocas.empty())

0 commit comments

Comments
 (0)