summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCall.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2018-02-06 18:52:44 +0000
committerJohn McCall <rjmccall@apple.com>2018-02-06 18:52:44 +0000
commit9831b843d2044818d7a01a4b0f78c12c1c28192a (patch)
tree361bf6640141ecd2917d2803cf2e727e47b7ae38 /clang/lib/CodeGen/CGCall.cpp
parent1c570566c39a62fa620085bff03f715c965cfaee (diff)
downloadbcm5719-llvm-9831b843d2044818d7a01a4b0f78c12c1c28192a.tar.gz
bcm5719-llvm-9831b843d2044818d7a01a4b0f78c12c1c28192a.zip
Pass around function pointers as CGCallees, not bare llvm::Value*s.
The intention here is to make it easy to write frontend-assisted CFI systems by propagating extra information in the CGCallee. llvm-svn: 324377
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
-rw-r--r--clang/lib/CodeGen/CGCall.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 0f222ae21ab..de42d159fa4 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -4052,14 +4052,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
}
}
- llvm::Value *CalleePtr;
- if (Callee.isVirtual()) {
- const CallExpr *CE = Callee.getVirtualCallExpr();
- CalleePtr = CGM.getCXXABI().getVirtualFunctionPointer(
- *this, Callee.getVirtualMethodDecl(), Callee.getThisAddress(),
- Callee.getFunctionType(), CE ? CE->getLocStart() : SourceLocation());
- } else
- CalleePtr = Callee.getFunctionPointer();
+ const CGCallee &ConcreteCallee = Callee.prepareConcreteCallee(*this);
+ llvm::Value *CalleePtr = ConcreteCallee.getFunctionPointer();
// If we're using inalloca, set up that argument.
if (ArgMemory.isValid()) {
@@ -4412,6 +4406,17 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
return Ret;
}
+CGCallee CGCallee::prepareConcreteCallee(CodeGenFunction &CGF) const {
+ if (isVirtual()) {
+ const CallExpr *CE = getVirtualCallExpr();
+ return CGF.CGM.getCXXABI().getVirtualFunctionPointer(
+ CGF, getVirtualMethodDecl(), getThisAddress(),
+ getFunctionType(), CE ? CE->getLocStart() : SourceLocation());
+ }
+
+ return *this;
+}
+
/* VarArg handling */
Address CodeGenFunction::EmitVAArg(VAArgExpr *VE, Address &VAListAddr) {
OpenPOWER on IntegriCloud