summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-06-25 00:55:12 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-06-25 00:55:12 +0000
commit0f45572761388f418dc2c95034416f01eec6bc94 (patch)
treedb55b32cdb033ff3614ab91546eb8343217b45f3
parentf4c56e97dffe9d0d40c1c428a59ec6a3a0d59f66 (diff)
downloadbcm5719-llvm-0f45572761388f418dc2c95034416f01eec6bc94.tar.gz
bcm5719-llvm-0f45572761388f418dc2c95034416f01eec6bc94.zip
The absence of noreturn doesn't ensure mayReturn
There are two separate issues: - LLVM doesn't consider infinite loops to be side effects: we happily hoist/sink above/below loops whose bounds are unknown. - The absence of the noreturn attribute is insufficient for us to know if a function will definitely return. Relying on noreturn in the middle-end for any property is an accident waiting to happen. llvm-svn: 273762
-rw-r--r--llvm/include/llvm/IR/Instruction.h10
-rw-r--r--llvm/lib/IR/Instruction.cpp6
-rw-r--r--llvm/test/Transforms/FunctionAttrs/noreturn.ll18
3 files changed, 1 insertions, 33 deletions
diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h
index ea262def2c2..efcd26cc30f 100644
--- a/llvm/include/llvm/IR/Instruction.h
+++ b/llvm/include/llvm/IR/Instruction.h
@@ -394,21 +394,13 @@ public:
/// Return true if this instruction may throw an exception.
bool mayThrow() const;
- /// Return true if this is a function that may return.
- /// This is true for all normal instructions. The only exception
- /// is functions that are marked with the 'noreturn' attribute.
- ///
- bool mayReturn() const;
-
/// Return true if the instruction may have side effects.
///
/// Note that this does not consider malloc and alloca to have side
/// effects because the newly allocated memory is completely invisible to
/// instructions which don't use the returned value. For cases where this
/// matters, isSafeToSpeculativelyExecute may be more appropriate.
- bool mayHaveSideEffects() const {
- return mayWriteToMemory() || mayThrow() || !mayReturn();
- }
+ bool mayHaveSideEffects() const { return mayWriteToMemory() || mayThrow(); }
/// Return true if the instruction is a variety of EH-block.
bool isEHPad() const {
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index f90ebec06bd..6ca5c8c4637 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -545,12 +545,6 @@ bool Instruction::mayThrow() const {
return isa<ResumeInst>(this);
}
-bool Instruction::mayReturn() const {
- if (const CallInst *CI = dyn_cast<CallInst>(this))
- return !CI->doesNotReturn();
- return true;
-}
-
/// isAssociative - Return true if the instruction is associative:
///
/// Associative operators satisfy: x op (y op z) === (x op y) op z
diff --git a/llvm/test/Transforms/FunctionAttrs/noreturn.ll b/llvm/test/Transforms/FunctionAttrs/noreturn.ll
deleted file mode 100644
index 990bea984df..00000000000
--- a/llvm/test/Transforms/FunctionAttrs/noreturn.ll
+++ /dev/null
@@ -1,18 +0,0 @@
-; RUN: opt < %s -functionattrs -instcombine -S | FileCheck %s
-
-define void @endless_loop() noreturn nounwind readnone ssp uwtable {
-entry:
- br label %while.body
-
-while.body:
- br label %while.body
-}
-;CHECK-LABEL: @main(
-;CHECK: endless_loop
-;CHECK: ret
-define i32 @main() noreturn nounwind ssp uwtable {
-entry:
- tail call void @endless_loop()
- unreachable
-}
-
OpenPOWER on IntegriCloud