Fix assertion in tryEmitAsConstant
due to cd95338ee3
Need to check if result is LValue before getLValueBase.
This commit is contained in:
parent
dcdd231df6
commit
3a781b912f
|
@ -1529,7 +1529,7 @@ CodeGenFunction::tryEmitAsConstant(DeclRefExpr *refExpr) {
|
|||
// global variable as compile time constant, since the host variable is not
|
||||
// accessible on device. The DRE of the captured reference variable has to be
|
||||
// loaded from captures.
|
||||
if (CGM.getLangOpts().CUDAIsDevice &&
|
||||
if (CGM.getLangOpts().CUDAIsDevice && result.Val.isLValue() &&
|
||||
refExpr->refersToEnclosingVariableOrCapture()) {
|
||||
auto *MD = dyn_cast_or_null<CXXMethodDecl>(CurCodeDecl);
|
||||
if (MD && MD->getParent()->isLambda() &&
|
||||
|
|
|
@ -27,6 +27,15 @@ __device__ void dev_capture_dev_ref_by_copy(int *out) {
|
|||
[=](){ *out = ref;}();
|
||||
}
|
||||
|
||||
// DEV-LABEL: @_ZZ28dev_capture_dev_rval_by_copyPiENKUlvE_clEv(
|
||||
// DEV: store i32 3
|
||||
__device__ void dev_capture_dev_rval_by_copy(int *out) {
|
||||
constexpr int a = 1;
|
||||
constexpr int b = 2;
|
||||
constexpr int c = a + b;
|
||||
[=](){ *out = c;}();
|
||||
}
|
||||
|
||||
// DEV-LABEL: @_ZZ26dev_capture_dev_ref_by_refPiENKUlvE_clEv(
|
||||
// DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
|
||||
// DEV: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1
|
||||
|
|
Loading…
Reference in New Issue