Author: Timm Baeder Date: 2026-06-15T06:55:51+02:00 New Revision: 05c8f9b1ead844024f414f45ab9ba11757bef2ea
URL: https://github.com/llvm/llvm-project/commit/05c8f9b1ead844024f414f45ab9ba11757bef2ea DIFF: https://github.com/llvm/llvm-project/commit/05c8f9b1ead844024f414f45ab9ba11757bef2ea.diff LOG: [clang][bytecode] Overide constant context state in CallVar (#203747) We do this for regular calls, so do it for variable calls as well. Also remove two comments that don't have any meaning today anymore. Added: clang/test/AST/ByteCode/codegen-cxx2a.cpp Modified: clang/lib/AST/ByteCode/Interp.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index 0a4a84edd62a4..754046be06d05 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -1774,9 +1774,7 @@ bool CallVar(InterpState &S, CodePtr OpPC, const Function *Func, InterpFrame *FrameBefore = S.Current; S.Current = NewFrame; - // Note that we cannot assert(CallResult.hasValue()) here since - // Ret() above only sets the APValue if the curent frame doesn't - // have a caller set. + InterpStateCCOverride CCOverride(S, Func->isImmediate()); if (Interpret(S)) { assert(S.Current == FrameBefore); return true; @@ -1868,9 +1866,6 @@ bool Call(InterpState &S, CodePtr OpPC, const Function *Func, S.Current = NewFrame; InterpStateCCOverride CCOverride(S, Func->isImmediate()); - // Note that we cannot assert(CallResult.hasValue()) here since - // Ret() above only sets the APValue if the curent frame doesn't - // have a caller set. bool Success = Interpret(S); // Remove initializing block again. if (Func->isConstructor() || Func->isDestructor()) diff --git a/clang/test/AST/ByteCode/codegen-cxx2a.cpp b/clang/test/AST/ByteCode/codegen-cxx2a.cpp new file mode 100644 index 0000000000000..d75a758e19308 --- /dev/null +++ b/clang/test/AST/ByteCode/codegen-cxx2a.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -emit-llvm %s -std=c++2a -triple x86_64-unknown-linux-gnu -fexperimental-new-constant-interpreter -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm %s -std=c++2a -triple x86_64-unknown-linux-gnu -o - | FileCheck %s + + +struct Agg { + int a; + long b; +}; +consteval Agg is_const(...) { + return {5, 19 * __builtin_is_constant_evaluated()}; +} +// CHECK-LABEL: @_Z13test_is_constv( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[B:%.*]] = alloca i64, align 8 +// CHECK-NEXT: [[REF_TMP:%.*]] = alloca [[STRUCT_AGG:%.*]], align 8 +// CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds nuw [[STRUCT_AGG]], ptr [[REF_TMP]], i32 0, i32 0 +// CHECK-NEXT: store i32 5, ptr [[TMP0]], align 8 +// CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds nuw [[STRUCT_AGG]], ptr [[REF_TMP]], i32 0, i32 1 +// CHECK-NEXT: store i64 19, ptr [[TMP1]], align 8 +// CHECK-NEXT: store i64 19, ptr [[B]], align 8 +// CHECK-NEXT: [[TMP2:%.*]] = load i64, ptr [[B]], align 8 +// CHECK-NEXT: ret i64 [[TMP2]] +long test_is_const() { + long b = is_const().b; + return b; +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
