[llvm] f702ee8 - [VPlan] Fix partially uninitialized accesses after 17aaa0e590a7. (#184583)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 4 02:56:33 PST 2026
Author: Florian Hahn
Date: 2026-03-04T10:56:27Z
New Revision: f702ee89c1d72fa5ff9b3b9b4e58f4f41321419b
URL: https://github.com/llvm/llvm-project/commit/f702ee89c1d72fa5ff9b3b9b4e58f4f41321419b
DIFF: https://github.com/llvm/llvm-project/commit/f702ee89c1d72fa5ff9b3b9b4e58f4f41321419b.diff
LOG: [VPlan] Fix partially uninitialized accesses after 17aaa0e590a7. (#184583)
17aaa0e590a7 adjusted how parts of the union members are managed. Make
sure the full union is initialized, to fix MSan failure in
https://lab.llvm.org/buildbot/#/builders/164/builds/19313.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlan.h
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 978b467521a52..41eef2a368343 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -759,12 +759,13 @@ class VPIRFlags {
FastMathFlagsTy FMFs;
FCmpFlagsTy FCmpFlags;
ReductionFlagsTy ReductionFlags;
+ uint8_t AllFlags[2];
};
public:
- VPIRFlags() : OpType(OperationType::Other), CmpPredStorage(0) {}
+ VPIRFlags() : OpType(OperationType::Other), AllFlags() {}
- VPIRFlags(Instruction &I) {
+ VPIRFlags(Instruction &I) : VPIRFlags() {
if (auto *FCmp = dyn_cast<FCmpInst>(&I)) {
OpType = OperationType::FCmp;
Bitfield::set<CmpInst::PredicateField>(FCmpFlags.CmpPredStorage,
@@ -799,49 +800,65 @@ class VPIRFlags {
} else if (auto *Op = dyn_cast<FPMathOperator>(&I)) {
OpType = OperationType::FPMathOp;
FMFs = Op->getFastMathFlags();
- } else {
- OpType = OperationType::Other;
- CmpPredStorage = 0;
}
}
- VPIRFlags(CmpInst::Predicate Pred) : OpType(OperationType::Cmp) {
+ VPIRFlags(CmpInst::Predicate Pred) : OpType(OperationType::Cmp), AllFlags() {
Bitfield::set<CmpInst::PredicateField>(CmpPredStorage, Pred);
assert(getPredicate() == Pred && "predicate truncated");
}
VPIRFlags(CmpInst::Predicate Pred, FastMathFlags FMFs)
- : OpType(OperationType::FCmp) {
+ : OpType(OperationType::FCmp), AllFlags() {
Bitfield::set<CmpInst::PredicateField>(FCmpFlags.CmpPredStorage, Pred);
assert(getPredicate() == Pred && "predicate truncated");
FCmpFlags.FMFs = FMFs;
}
VPIRFlags(WrapFlagsTy WrapFlags)
- : OpType(OperationType::OverflowingBinOp), WrapFlags(WrapFlags) {}
+ : OpType(OperationType::OverflowingBinOp), AllFlags() {
+ this->WrapFlags = WrapFlags;
+ }
VPIRFlags(TruncFlagsTy TruncFlags)
- : OpType(OperationType::Trunc), TruncFlags(TruncFlags) {}
+ : OpType(OperationType::Trunc), AllFlags() {
+ this->TruncFlags = TruncFlags;
+ }
- VPIRFlags(FastMathFlags FMFs) : OpType(OperationType::FPMathOp), FMFs(FMFs) {}
+ VPIRFlags(FastMathFlags FMFs) : OpType(OperationType::FPMathOp), AllFlags() {
+ this->FMFs = FMFs;
+ }
VPIRFlags(DisjointFlagsTy DisjointFlags)
- : OpType(OperationType::DisjointOp), DisjointFlags(DisjointFlags) {}
+ : OpType(OperationType::DisjointOp), AllFlags() {
+ this->DisjointFlags = DisjointFlags;
+ }
VPIRFlags(NonNegFlagsTy NonNegFlags)
- : OpType(OperationType::NonNegOp), NonNegFlags(NonNegFlags) {}
+ : OpType(OperationType::NonNegOp), AllFlags() {
+ this->NonNegFlags = NonNegFlags;
+ }
VPIRFlags(ExactFlagsTy ExactFlags)
- : OpType(OperationType::PossiblyExactOp), ExactFlags(ExactFlags) {}
+ : OpType(OperationType::PossiblyExactOp), AllFlags() {
+ this->ExactFlags = ExactFlags;
+ }
VPIRFlags(GEPNoWrapFlags GEPFlags)
- : OpType(OperationType::GEPOp), GEPFlagsStorage(GEPFlags.getRaw()) {}
+ : OpType(OperationType::GEPOp), AllFlags() {
+ GEPFlagsStorage = GEPFlags.getRaw();
+ }
VPIRFlags(RecurKind Kind, bool IsOrdered, bool IsInLoop, FastMathFlags FMFs)
- : OpType(OperationType::ReductionOp),
- ReductionFlags(Kind, IsOrdered, IsInLoop, FMFs) {}
+ : OpType(OperationType::ReductionOp), AllFlags() {
+ ReductionFlags = ReductionFlagsTy(Kind, IsOrdered, IsInLoop, FMFs);
+ }
- void transferFlags(VPIRFlags &Other) { *this = Other; }
+ void transferFlags(VPIRFlags &Other) {
+ OpType = Other.OpType;
+ AllFlags[0] = Other.AllFlags[0];
+ AllFlags[1] = Other.AllFlags[1];
+ }
/// Only keep flags also present in \p Other. \p Other must have the same
/// OpType as the current object.
More information about the llvm-commits
mailing list