[PATCH] D137630: [IR] Don't assume readnone/readonly intrinsics are willreturn
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 6 02:49:03 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0b20c3034c9c: [IR] Don't assume readnone/readonly intrinsics are willreturn (authored by nikic).
Changed prior to commit:
https://reviews.llvm.org/D137630?vs=473949&id=480411#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137630/new/
https://reviews.llvm.org/D137630
Files:
llvm/lib/IR/Instruction.cpp
llvm/lib/Transforms/Utils/Local.cpp
Index: llvm/lib/Transforms/Utils/Local.cpp
===================================================================
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -58,6 +58,7 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/IntrinsicsWebAssembly.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Metadata.h"
@@ -444,8 +445,24 @@
if (isRemovableAlloc(CB, TLI))
return true;
- if (!I->willReturn())
- return false;
+ if (!I->willReturn()) {
+ auto *II = dyn_cast<IntrinsicInst>(I);
+ if (!II)
+ return false;
+
+ // TODO: These intrinsics are not safe to remove, because this may remove
+ // a well-defined trap.
+ switch (II->getIntrinsicID()) {
+ case Intrinsic::wasm_trunc_signed:
+ case Intrinsic::wasm_trunc_unsigned:
+ case Intrinsic::ptrauth_auth:
+ case Intrinsic::ptrauth_resign:
+ case Intrinsic::ptrauth_sign:
+ return true;
+ default:
+ return false;
+ }
+ }
if (!I->mayHaveSideEffects())
return true;
Index: llvm/lib/IR/Instruction.cpp
===================================================================
--- llvm/lib/IR/Instruction.cpp
+++ llvm/lib/IR/Instruction.cpp
@@ -744,11 +744,7 @@
return !SI->isVolatile();
if (const auto *CB = dyn_cast<CallBase>(this))
- // FIXME: Temporarily assume that all side-effect free intrinsics will
- // return. Remove this workaround once all intrinsics are appropriately
- // annotated.
- return CB->hasFnAttr(Attribute::WillReturn) ||
- (isa<IntrinsicInst>(CB) && CB->onlyReadsMemory());
+ return CB->hasFnAttr(Attribute::WillReturn);
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137630.480411.patch
Type: text/x-patch
Size: 1768 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221206/05a3d544/attachment-0001.bin>
More information about the llvm-commits
mailing list