[llvm] [nsan] minor fix for the nsan pass (PR #101147)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 30 19:37:29 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Wu Yingcong (yingcong-wu)
<details>
<summary>Changes</summary>
1. Avoid an auto copy
2. use cast instead to replace dyn_cast when dyn_cast is not needed/not checked.
---
Full diff: https://github.com/llvm/llvm-project/pull/101147.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp (+2-2)
``````````diff
diff --git a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
index 832506f639a74..5872396669435 100644
--- a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
@@ -1715,7 +1715,7 @@ Value *NumericalStabilitySanitizer::createShadowValueWithOperandsAvailable(
Map.getShadow(BinOp->getOperand(1)));
if (isa<UIToFPInst>(&Inst) || isa<SIToFPInst>(&Inst)) {
- auto *Cast = dyn_cast<CastInst>(&Inst);
+ auto *Cast = cast<CastInst>(&Inst);
return Builder.CreateCast(Cast->getOpcode(), Cast->getOperand(0),
ExtendedVT);
}
@@ -2168,7 +2168,7 @@ bool NumericalStabilitySanitizer::sanitizeFunction(
// The last pass populates shadow phis with shadow values.
for (PHINode *Phi : OriginalPhis) {
- PHINode *ShadowPhi = dyn_cast<PHINode>(ValueToShadow.getShadow(Phi));
+ PHINode *ShadowPhi = cast<PHINode>(ValueToShadow.getShadow(Phi));
for (unsigned I : seq(Phi->getNumOperands())) {
Value *V = Phi->getOperand(I);
Value *Shadow = ValueToShadow.getShadow(V);
``````````
</details>
https://github.com/llvm/llvm-project/pull/101147
More information about the llvm-commits
mailing list