[llvm] [VPlan] Fix partially uninitialized accesses after 17aaa0e590a7. (PR #184583)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 4 02:52:47 PST 2026
https://github.com/fhahn created https://github.com/llvm/llvm-project/pull/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.
>From 384c75540a1352532abec36bc0e9ed90b8af1fa4 Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Wed, 4 Mar 2026 10:31:05 +0000
Subject: [PATCH] [VPlan] Fix partially uninitialized accesses after
17aaa0e590a7.
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.
---
llvm/lib/Transforms/Vectorize/VPlan.h | 51 ++++++++++++++++++---------
1 file changed, 34 insertions(+), 17 deletions(-)
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