[llvm] [nsan] minor fix for the nsan pass (PR #101147)
Wu Yingcong via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 30 19:36:58 PDT 2024
https://github.com/yingcong-wu updated https://github.com/llvm/llvm-project/pull/101147
>From 1a6c9296bb30ccc32eb4a350c8518e45da2d4f2e Mon Sep 17 00:00:00 2001
From: "Wu, Yingcong" <yingcong.wu at intel.com>
Date: Tue, 30 Jul 2024 16:23:16 +0800
Subject: [PATCH 1/2] minor fix
---
.../Instrumentation/NumericalStabilitySanitizer.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
index 832506f639a74..ec0f3c4544e5c 100644
--- a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
@@ -850,7 +850,7 @@ void NumericalStabilitySanitizer::populateShadowStack(
IRBuilder<> Builder(&CI);
SmallVector<Value *, 8> ArgShadows;
const bool ShouldCheckArgs = shouldCheckArgs(CI, TLI, CheckFunctionsFilter);
- for (auto [ArgIdx, Arg] : enumerate(CI.operands())) {
+ for (auto &[ArgIdx, Arg] : enumerate(CI.operands())) {
if (Config.getExtendedFPType(Arg->getType()) == nullptr)
continue; // Not an FT value.
Value *ArgShadow = Map.getShadow(Arg);
@@ -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);
>From 38783be19ba35e164c3b5e85a089721276484b0e Mon Sep 17 00:00:00 2001
From: "Wu, Yingcong" <yingcong.wu at intel.com>
Date: Wed, 31 Jul 2024 10:36:43 +0800
Subject: [PATCH 2/2] remove wrong fix
---
.../Transforms/Instrumentation/NumericalStabilitySanitizer.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
index ec0f3c4544e5c..5872396669435 100644
--- a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
@@ -850,7 +850,7 @@ void NumericalStabilitySanitizer::populateShadowStack(
IRBuilder<> Builder(&CI);
SmallVector<Value *, 8> ArgShadows;
const bool ShouldCheckArgs = shouldCheckArgs(CI, TLI, CheckFunctionsFilter);
- for (auto &[ArgIdx, Arg] : enumerate(CI.operands())) {
+ for (auto [ArgIdx, Arg] : enumerate(CI.operands())) {
if (Config.getExtendedFPType(Arg->getType()) == nullptr)
continue; // Not an FT value.
Value *ArgShadow = Map.getShadow(Arg);
More information about the llvm-commits
mailing list