Index: lib/CodeGen/TargetInfo.cpp =================================================================== --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -432,6 +432,7 @@ // space, an address space conversion may end up as a bitcast. if (auto *C = dyn_cast(Src)) return performAddrSpaceCast(CGF.CGM, C, SrcAddr, DestAddr, DestTy); + CGF.EnsureInsertPoint(); return CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Src, DestTy); } Index: test/CodeGenCXX/amdgcn-automatic-variable.cpp =================================================================== --- test/CodeGenCXX/amdgcn-automatic-variable.cpp +++ test/CodeGenCXX/amdgcn-automatic-variable.cpp @@ -81,4 +81,10 @@ func1(&x); } +// CHECK-LABEL: define void @_Z5func5v +void func5() { + return; + int x = 0; +} + // CHECK-NOT: !opencl.ocl.version