summaryrefslogtreecommitdiff
path: root/bolt/lib
diff options
context:
space:
mode:
authorAmir Ayupov <amir.aupov@gmail.com>2023-03-03 11:58:59 -0800
committerAmir Ayupov <aaupov@fb.com>2023-03-03 12:02:17 -0800
commit1e1dfbb94a20d81693176d885b5f773072bf0786 (patch)
tree8e6632a341d857e14f13b094611526bb085608db /bolt/lib
parent96ff21243eba3873e0da814baa9a7ff19b748b7c (diff)
downloadllvm-1e1dfbb94a20d81693176d885b5f773072bf0786.tar.gz
[BOLT][Instrumentation] Preserve red zone for functions with tail calls only
Allow a function with tail calls only to clobber its red zone. Fixes https://github.com/llvm/llvm-project/issues/61114. Reviewed By: #bolt, yota9 Differential Revision: https://reviews.llvm.org/D145202
Diffstat (limited to 'bolt/lib')
-rw-r--r--bolt/lib/Passes/Instrumentation.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/bolt/lib/Passes/Instrumentation.cpp b/bolt/lib/Passes/Instrumentation.cpp
index a0350b14d2b5..c6e1bf9e6b16 100644
--- a/bolt/lib/Passes/Instrumentation.cpp
+++ b/bolt/lib/Passes/Instrumentation.cpp
@@ -357,12 +357,13 @@ void Instrumentation::instrumentFunction(BinaryFunction &Function,
// instructions to protect the red zone
bool IsLeafFunction = true;
DenseSet<const BinaryBasicBlock *> InvokeBlocks;
- for (auto BBI = Function.begin(), BBE = Function.end(); BBI != BBE; ++BBI) {
- for (auto I = BBI->begin(), E = BBI->end(); I != E; ++I) {
- if (BC.MIB->isCall(*I)) {
- if (BC.MIB->isInvoke(*I))
- InvokeBlocks.insert(&*BBI);
- IsLeafFunction = false;
+ for (const BinaryBasicBlock &BB : Function) {
+ for (const MCInst &Inst : BB) {
+ if (BC.MIB->isCall(Inst)) {
+ if (BC.MIB->isInvoke(Inst))
+ InvokeBlocks.insert(&BB);
+ if (!BC.MIB->isTailCall(Inst))
+ IsLeafFunction = false;
}
}
}