yaxunl added a comment. In https://reviews.llvm.org/D35438#810385, @rjmccall wrote:
> Oh, of course. Sadly, in C/C++ the declaration point of a variable does not > necessarily dominate all uses of the variable, so you need to emit the cast > immediately after the alloca. Just temporarily move CGF.Builder to that > point; hopefully we can assume that this function will never try to add > control flow. > > Test case: > > extern void use(int*); > void foo() { > goto later; > int x; > later: > use(&x); > } Right. performAddressSpaceCast could be used in general cases. We only need to change insert position when emitting automatic or temporary variables. I will move this logic to CodeGenFunction::CreateTempAlloca. https://reviews.llvm.org/D35438 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits