|
42 | 42 | #include "llvm/IR/Function.h"
|
43 | 43 | #include "llvm/IR/GetElementPtrTypeIterator.h"
|
44 | 44 | #include "llvm/IR/IRBuilder.h"
|
| 45 | +#include "llvm/IR/InstIterator.h" |
45 | 46 | #include "llvm/IR/Instruction.h"
|
46 | 47 | #include "llvm/IR/Instructions.h"
|
47 | 48 | #include "llvm/IR/IntrinsicInst.h"
|
@@ -543,46 +544,44 @@ bool AArch64StackTagging::runOnFunction(Function &Fn) {
|
543 | 544 | SmallVector<Instruction *, 4> UnrecognizedLifetimes;
|
544 | 545 |
|
545 | 546 | 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; |
557 | 551 | }
|
| 552 | + } |
| 553 | + if (auto *AI = dyn_cast<AllocaInst>(&I)) { |
| 554 | + Allocas[AI].AI = AI; |
| 555 | + Allocas[AI].OldAI = AI; |
| 556 | + continue; |
| 557 | + } |
558 | 558 |
|
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 | + } |
567 | 567 |
|
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; |
580 | 575 | }
|
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); |
585 | 580 | }
|
| 581 | + |
| 582 | + Instruction *ExitUntag = getUntagLocationIfFunctionExit(I); |
| 583 | + if (ExitUntag) |
| 584 | + RetVec.push_back(ExitUntag); |
586 | 585 | }
|
587 | 586 |
|
588 | 587 | if (Allocas.empty())
|
|
0 commit comments