Index: llvm/lib/Transforms/IPO/AttributorAttributes.cpp =================================================================== --- llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -7743,6 +7743,16 @@ const std::string getAsStr() const override { return getAssumed() ? "noundef" : "may-undef-or-poison"; } + + ChangeStatus manifest(Attributor &A) override { + // We don't manifest noundef attribute for dead positions because the + // associated values with dead positions would be replaced with undef + // values. + if (A.isAssumedDead(getIRPosition(), nullptr, nullptr, + /* CheckBBLivenessOnly */ true)) + return ChangeStatus::UNCHANGED; + return AANoUndef::manifest(A); + } }; struct AANoUndefFloating : public AANoUndefImpl {