Skip to content

Commit 8792320

Browse files
Fznamznonbader
authored andcommitted
[SYCL] Avoid trying to add metadata to nonexistent alloca
If local variable is NRVO variable, i.e. is was optimized away and hence doesn't have an alloca instruction, no need try to do any actions on this alloca instruction. Signed-off-by: Mariya Podchishchaeva <[email protected]>
1 parent 23b7f5e commit 8792320

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,8 @@ void CodeGenFunction::EmitAutoVarDecl(const VarDecl &D) {
13121312
AutoVarEmission emission = EmitAutoVarAlloca(D);
13131313
EmitAutoVarInit(emission);
13141314
EmitAutoVarCleanups(emission);
1315-
if (CGM.getLangOpts().SYCLIsDevice)
1315+
// No alloca in case of NRVO (named return value optimization) variable.
1316+
if (CGM.getLangOpts().SYCLIsDevice && !D.isNRVOVariable())
13161317
CGM.getSYCLRuntime().actOnAutoVarEmit(
13171318
*this, D, emission.getOriginalAllocatedAddress().getPointer());
13181319
}

0 commit comments

Comments
 (0)