[clang] [clang codegen] Emit !unpredictable metadata more consistently. (PR #111065)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 3 14:34: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 82a36468c74a29b6154639d659550c62457e655b bc7b771fce25d13c2da89f7992eda6e6ccb07242 --extensions c,cpp,h -- clang/lib/CodeGen/CGExprScalar.cpp clang/lib/CodeGen/CGStmt.cpp clang/lib/CodeGen/CodeGenFunction.cpp clang/lib/CodeGen/CodeGenFunction.h clang/test/CodeGen/builtin-unpredictable.c
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 0b00e1218b..30550303af 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -5338,9 +5338,10 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
assert(!RHS && "LHS and RHS types must match");
return nullptr;
}
- Value* Select = Builder.CreateSelect(CondV, LHS, RHS, "cond");
+ Value *Select = Builder.CreateSelect(CondV, LHS, RHS, "cond");
if (auto *SelectI = dyn_cast<llvm::Instruction>(Select)) {
- if (llvm::MDNode *Unpredictable = CGF.getUnpredictableMetadata(condExpr)) {
+ if (llvm::MDNode *Unpredictable =
+ CGF.getUnpredictableMetadata(condExpr)) {
SelectI->setMetadata(llvm::LLVMContext::MD_unpredictable,
Unpredictable);
}
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 9f3018d0e4..024dab4be7 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -2258,8 +2258,7 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) {
incrementProfileCounter(&S);
if (llvm::MDNode *Unpredictable = getUnpredictableMetadata(S.getCond())) {
- SwitchInsn->setMetadata(llvm::LLVMContext::MD_unpredictable,
- Unpredictable);
+ SwitchInsn->setMetadata(llvm::LLVMContext::MD_unpredictable, Unpredictable);
}
if (SwitchWeights) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/111065
More information about the cfe-commits
mailing list