aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp16
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;