diff options
author | Nikita Popov <npopov@redhat.com> | 2025-05-30 10:56:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-30 10:56:49 +0200 |
commit | ea096c98ae2c88ce9ba879be832caa8b254a348a (patch) | |
tree | 1e6bf1d5033869fe876ad63f2ed1e041c88b7958 /llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | |
parent | 5483190216cb0ff3b9f0e1a3ca901ad1b259ba82 (diff) | |
download | llvm-ea096c98ae2c88ce9ba879be832caa8b254a348a.zip llvm-ea096c98ae2c88ce9ba879be832caa8b254a348a.tar.gz llvm-ea096c98ae2c88ce9ba879be832caa8b254a348a.tar.bz2 |
[SDAG] Remove noundef workaround for range metadata/attributes (#141745)
In https://reviews.llvm.org/D157685 I changed SDAG to only transfer
range metadata to SDAG if it also has !noundef. At the time, this was
necessary because SDAG incorrectly propagated poison when folding
logical and/or to bitwise and/or.
The root cause of that issue has since been addressed by
https://github.com/llvm/llvm-project/pull/84924, so drop the workaround
now.
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 693a7f5..77771ee 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4468,23 +4468,13 @@ void SelectionDAGBuilder::visitAlloca(const AllocaInst &I) { } static const MDNode *getRangeMetadata(const Instruction &I) { - // If !noundef is not present, then !range violation results in a poison - // value rather than immediate undefined behavior. In theory, transferring - // these annotations to SDAG is fine, but in practice there are key SDAG - // transforms that are known not to be poison-safe, such as folding logical - // and/or to bitwise and/or. For now, only transfer !range if !noundef is - // also present. - if (!I.hasMetadata(LLVMContext::MD_noundef)) - return nullptr; return I.getMetadata(LLVMContext::MD_range); } static std::optional<ConstantRange> getRange(const Instruction &I) { - if (const auto *CB = dyn_cast<CallBase>(&I)) { - // see comment in getRangeMetadata about this check - if (CB->hasRetAttr(Attribute::NoUndef)) - return CB->getRange(); - } + if (const auto *CB = dyn_cast<CallBase>(&I)) + if (std::optional<ConstantRange> CR = CB->getRange()) + return CR; if (const MDNode *Range = getRangeMetadata(I)) return getConstantRangeFromMetadata(*Range); return std::nullopt; |