aboutsummaryrefslogtreecommitdiff
path: root/lib/IR/InlineAsm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/IR/InlineAsm.cpp')
-rw-r--r--lib/IR/InlineAsm.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/IR/InlineAsm.cpp b/lib/IR/InlineAsm.cpp
index 9f2a9fea4b..121fe1528e 100644
--- a/lib/IR/InlineAsm.cpp
+++ b/lib/IR/InlineAsm.cpp
@@ -293,3 +293,18 @@ bool InlineAsm::Verify(FunctionType *Ty, StringRef ConstStr) {
return true;
}
+// @LOCALMOD-START
+bool InlineAsm::isAsmMemory() const {
+ bool retVoid = getFunctionType()->getReturnType()->isVoidTy();
+ bool noArgs = getFunctionType()->getNumParams() == 0 &&
+ !getFunctionType()->isVarArg();
+ bool isEmptyAsm = AsmString.empty();
+ // Different triples will encode "touch everything" differently, e.g.:
+ // - le32-unknown-nacl has "~{memory}".
+ // - x86 "~{memory},~{dirflag},~{fpsr},~{flags}".
+ // The following code therefore only searches for memory.
+ bool touchesMemory = Constraints.find("~{memory}") != std::string::npos;
+
+ return retVoid && noArgs && hasSideEffects() && isEmptyAsm && touchesMemory;
+}
+// @LOCALMOD-END