summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/TargetInfo.h
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-09-04 20:04:38 +0000
committerReid Kleckner <reid@kleckner.net>2014-09-04 20:04:38 +0000
commit9b3e3dfc54d9823074407323b0a60ebd223cd721 (patch)
tree272fcb6b13b9be87c80535e7473a4b83d316f9a3 /clang/lib/CodeGen/TargetInfo.h
parent878065bb218dea18b7943a7b59a98050995200d9 (diff)
downloadbcm5719-llvm-9b3e3dfc54d9823074407323b0a60ebd223cd721.tar.gz
bcm5719-llvm-9b3e3dfc54d9823074407323b0a60ebd223cd721.zip
MS inline asm: Allow __asm blocks to set a return value
If control falls off the end of a function after an __asm block, MSVC assumes that the inline assembly filled the EAX and possibly EDX registers with an appropriate return value. This functionality is used in inline functions returning 64-bit integers in system headers, so we need some amount of compatibility. This is implemented in Clang by adding extra output constraints to every inline asm block, and storing the resulting output registers into the return value slot. If we see an asm block somewhere in the function body, we emit a normal epilogue instead of marking the end of the function with a return type unreachable. Normal returns in functions not using this functionality will overwrite the return value slot, and in most cases LLVM should be able to eliminate the dead stores. Fixes PR17201. Reviewed By: majnemer Differential Revision: http://reviews.llvm.org/D5177 llvm-svn: 217187
Diffstat (limited to 'clang/lib/CodeGen/TargetInfo.h')
-rw-r--r--clang/lib/CodeGen/TargetInfo.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h
index 5b18f6b1e1d..f14965009d9 100644
--- a/clang/lib/CodeGen/TargetInfo.h
+++ b/clang/lib/CodeGen/TargetInfo.h
@@ -15,6 +15,7 @@
#ifndef LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
#define LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
+#include "CGValue.h"
#include "clang/AST/Type.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/SmallString.h"
@@ -129,6 +130,14 @@ public:
return Ty;
}
+ /// Adds constraints and types for result registers.
+ virtual void addReturnRegisterOutputs(
+ CodeGen::CodeGenFunction &CGF, CodeGen::LValue ReturnValue,
+ std::string &Constraints, std::vector<llvm::Type *> &ResultRegTypes,
+ std::vector<llvm::Type *> &ResultTruncRegTypes,
+ std::vector<CodeGen::LValue> &ResultRegDests, std::string &AsmString,
+ unsigned NumOutputs) const {}
+
/// doesReturnSlotInterfereWithArgs - Return true if the target uses an
/// argument slot for an 'sret' type.
virtual bool doesReturnSlotInterfereWithArgs() const { return true; }
OpenPOWER on IntegriCloud