diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2018-02-21 21:47:51 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2018-02-21 21:47:51 +0000 |
commit | c1b46381dbfc070ccdba327d36053c154cde2b4f (patch) | |
tree | 2b25cc709ba0f3fa78092abfb8d1cc028155d5d3 /clang/lib/CodeGen/CGDecl.cpp | |
parent | 2a129dc31bad7c90fc70056171cab40fe5059fca (diff) | |
download | bcm5719-llvm-c1b46381dbfc070ccdba327d36053c154cde2b4f.tar.gz bcm5719-llvm-c1b46381dbfc070ccdba327d36053c154cde2b4f.zip |
CodeGen: handle blocks correctly when inalloca'ed
When using blocks with C++ on Windows x86, it is possible to have the
block literal be pushed into the inalloca'ed parameters. Teach IRGen to
handle the case properly by extracting the block literal from the
inalloca parameter. This fixes the use of blocks with C++ on Windows
x86.
llvm-svn: 325724
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index c036cd414e4..19cdc24270c 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -1848,9 +1848,12 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, ParamValue Arg, // Use better IR generation for certain implicit parameters. if (auto IPD = dyn_cast<ImplicitParamDecl>(&D)) { // The only implicit argument a block has is its literal. - // We assume this is always passed directly. + // This may be passed as an inalloca'ed value on Windows x86. if (BlockInfo) { - setBlockContextParameter(IPD, ArgNo, Arg.getDirectValue()); + llvm::Value *V = Arg.isIndirect() + ? Builder.CreateLoad(Arg.getIndirectAddress()) + : Arg.getDirectValue(); + setBlockContextParameter(IPD, ArgNo, V); return; } } |