diff options
author | Yaxun Liu <Yaxun.Liu@amd.com> | 2017-05-18 18:51:09 +0000 |
---|---|---|
committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2017-05-18 18:51:09 +0000 |
commit | 6d96f163476be00b36a9acf0d5abe1ac0136e12f (patch) | |
tree | e2c369d3a0e3bbefc85bc981d62707f91b9abb26 /clang/lib/CodeGen/TargetInfo.h | |
parent | b00ffd8cb7a0f5fd51c9968e4f59b4b3eca52e47 (diff) | |
download | bcm5719-llvm-6d96f163476be00b36a9acf0d5abe1ac0136e12f.tar.gz bcm5719-llvm-6d96f163476be00b36a9acf0d5abe1ac0136e12f.zip |
CodeGen: Cast alloca to expected address space
Alloca always returns a pointer in alloca address space, which may
be different from the type defined by the language. For example,
in C++ the auto variables are in the default address space. Therefore
cast alloca to the expected address space when necessary.
Differential Revision: https://reviews.llvm.org/D32248
llvm-svn: 303370
Diffstat (limited to 'clang/lib/CodeGen/TargetInfo.h')
-rw-r--r-- | clang/lib/CodeGen/TargetInfo.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h index 223d6d047af..247d01dcb08 100644 --- a/clang/lib/CodeGen/TargetInfo.h +++ b/clang/lib/CodeGen/TargetInfo.h @@ -229,13 +229,20 @@ public: virtual llvm::Constant *getNullPointer(const CodeGen::CodeGenModule &CGM, llvm::PointerType *T, QualType QT) const; + /// Get the AST address space for alloca. + virtual unsigned getASTAllocaAddressSpace() const { return LangAS::Default; } + /// Perform address space cast of an expression of pointer type. /// \param V is the LLVM value to be casted to another address space. - /// \param SrcTy is the QualType of \p V. - /// \param DestTy is the destination QualType. + /// \param SrcAddr is the language address space of \p V. + /// \param DestAddr is the targeted language address space. + /// \param DestTy is the destination LLVM pointer type. + /// \param IsNonNull is the flag indicating \p V is known to be non null. virtual llvm::Value *performAddrSpaceCast(CodeGen::CodeGenFunction &CGF, - llvm::Value *V, QualType SrcTy, QualType DestTy) const; - + llvm::Value *V, unsigned SrcAddr, + unsigned DestAddr, + llvm::Type *DestTy, + bool IsNonNull = false) const; }; } // namespace CodeGen |