summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-12-21 05:52:02 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-12-21 05:52:02 +0000
commitb4039f633cc14f798b6bafc14b29e8f4cf66c618 (patch)
treee1cedd42226c479786102bbcea2d46f519b8ceed /llvm/lib/Analysis
parentf2b681b4d81942a62d725a95553271afd1e86a42 (diff)
downloadbcm5719-llvm-b4039f633cc14f798b6bafc14b29e8f4cf66c618.tar.gz
bcm5719-llvm-b4039f633cc14f798b6bafc14b29e8f4cf66c618.zip
Make some intrinsics safe to speculatively execute.
llvm-svn: 147036
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index ef19e065b70..4739d1b881a 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1912,11 +1912,31 @@ bool llvm::isSafeToSpeculativelyExecute(const Instruction *Inst,
return false;
return LI->getPointerOperand()->isDereferenceablePointer();
}
- case Instruction::Call:
+ case Instruction::Call: {
+ if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(Inst)) {
+ switch (II->getIntrinsicID()) {
+ case Intrinsic::bswap:
+ case Intrinsic::ctlz:
+ case Intrinsic::ctpop:
+ case Intrinsic::cttz:
+ case Intrinsic::objectsize:
+ case Intrinsic::sadd_with_overflow:
+ case Intrinsic::smul_with_overflow:
+ case Intrinsic::ssub_with_overflow:
+ case Intrinsic::uadd_with_overflow:
+ case Intrinsic::umul_with_overflow:
+ case Intrinsic::usub_with_overflow:
+ return true;
+ // TODO: some fp intrinsics are marked as having the same error handling
+ // as libm. They're safe to speculate when they won't error.
+ // TODO: are convert_{from,to}_fp16 safe?
+ // TODO: can we list target-specific intrinsics here?
+ default: break;
+ }
+ }
return false; // The called function could have undefined behavior or
- // side-effects.
- // FIXME: We should special-case some intrinsics (bswap,
- // overflow-checking arithmetic, etc.)
+ // side-effects, even if marked readnone nounwind.
+ }
case Instruction::VAArg:
case Instruction::Alloca:
case Instruction::Invoke:
OpenPOWER on IntegriCloud