[clang] [Clang] Add fake use emission to Clang with -fextend-lifetimes (PR #110102)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 26 03:35:29 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 22829f757dc76b23071d9438ae9c6ddc3e966db0 e04a16c6d51539421dd134f7524641e843f5d555 --extensions cpp,c,h -- clang/test/CodeGen/extend-liveness1.c clang/test/CodeGen/extend-liveness2.cpp clang/test/CodeGen/fake-use-determinism.c clang/test/CodeGen/fake-use-lambda.cpp clang/test/CodeGen/fake-use-landingpad.c clang/test/CodeGen/fake-use-noreturn.cpp clang/test/CodeGen/fake-use-return-line.c clang/test/CodeGen/fake-use-sanitizer.cpp clang/test/CodeGen/fake-use-scalar.c clang/test/CodeGen/fake-use-small-aggs.c clang/test/CodeGen/fake-use-while.c clang/test/CodeGen/fake-use.cpp clang/test/CodeGen/no-fake-use-O0.cpp clang/lib/CodeGen/CGCall.cpp clang/lib/CodeGen/CGCleanup.cpp clang/lib/CodeGen/CGCleanup.h clang/lib/CodeGen/CGDecl.cpp clang/lib/CodeGen/CodeGenFunction.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/CodeGen/CodeGenModule.h clang/lib/CodeGen/EHScopeStack.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 13c556a4e2..26441b4135 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3566,26 +3566,27 @@ static llvm::StoreInst *findDominatingStoreToReturnValue(CodeGenFunction &CGF) {
llvm::BasicBlock *IP = CGF.Builder.GetInsertBlock();
if (IP->empty()) return nullptr;
- // Look at directly preceding instruction, skipping bitcasts, lifetime
- // markers, and fake uses and their operands.
- const llvm::Instruction *LoadIntoFakeUse = nullptr;
- for (llvm::Instruction &I : make_range(IP->rbegin(), IP->rend())) {
- // Ignore instructions that are just loads for fake uses; the load should
- // immediately precede the fake use, so we only need to remember the
- // operand for the last fake use seen.
- if (LoadIntoFakeUse == &I)
- continue;
- if (isa<llvm::BitCastInst>(&I))
- continue;
- if (auto *II = dyn_cast<llvm::IntrinsicInst>(&I)) {
- if (II->getIntrinsicID() == llvm::Intrinsic::lifetime_end)
- continue;
-
- if (II->getIntrinsicID() == llvm::Intrinsic::fake_use) {
- LoadIntoFakeUse = dyn_cast<llvm::Instruction>(II->getArgOperand(0));
- continue;
- }
- } return GetStoreIfValid(&I);
+ // Look at directly preceding instruction, skipping bitcasts, lifetime
+ // markers, and fake uses and their operands.
+ const llvm::Instruction *LoadIntoFakeUse = nullptr;
+ for (llvm::Instruction &I : make_range(IP->rbegin(), IP->rend())) {
+ // Ignore instructions that are just loads for fake uses; the load should
+ // immediately precede the fake use, so we only need to remember the
+ // operand for the last fake use seen.
+ if (LoadIntoFakeUse == &I)
+ continue;
+ if (isa<llvm::BitCastInst>(&I))
+ continue;
+ if (auto *II = dyn_cast<llvm::IntrinsicInst>(&I)) {
+ if (II->getIntrinsicID() == llvm::Intrinsic::lifetime_end)
+ continue;
+
+ if (II->getIntrinsicID() == llvm::Intrinsic::fake_use) {
+ LoadIntoFakeUse = dyn_cast<llvm::Instruction>(II->getArgOperand(0));
+ continue;
+ }
+ }
+ return GetStoreIfValid(&I);
}
return nullptr;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/110102
More information about the cfe-commits
mailing list