[PATCH] D158591: Add support of Windows Trace Logging macros
Richard Dzenis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 25 04:43:57 PDT 2023
RIscRIpt added a comment.
Regarding new interpreter.
It takes more time and effort than I expected.
Here's what I found:
1. Assertion in ByteCodeExprGen<Emitter>::VisitPredefinedExpr <https://github.com/llvm/llvm-project/blob/6dfe55569d88ff654d13e6c09267eff0cd9c9f0d/clang/lib/AST/Interp/ByteCodeExprGen.cpp#L1256> seems unnecessary.
2. StringLiteral of PredefinedExpr gets initialized in ByteCodeExprGen<Emitter>::VisitStringLiteral <https://github.com/llvm/llvm-project/blob/6dfe55569d88ff654d13e6c09267eff0cd9c9f0d/clang/lib/AST/Interp/ByteCodeExprGen.cpp#L844>; I observe creation of InitMap, and initialization of each element of array.
3. However when I am at the following call-stack (just before exiting constexpr interpreter and doing final checks):
00 00000066`04580990 00007ff6`55fb7257 clang!clang::interp::CheckArrayInitialized+0x257 [C:\projects\my-llvm\clang\lib\AST\Interp\Interp.cpp @ 425]
01 00000066`04580b50 00007ff6`55f67ae6 clang!clang::interp::CheckCtorCall+0xc7 [C:\projects\my-llvm\clang\lib\AST\Interp\Interp.cpp @ 476]
02 00000066`04580bb0 00007ff6`55ebdd17 clang!clang::interp::CheckGlobalCtor+0x36 [C:\projects\my-llvm\clang\lib\AST\Interp\Interp.h @ 1681]
03 00000066`04580bf0 00007ff6`55fb3e3d clang!clang::interp::EvalEmitter::emitCheckGlobalCtor+0x57 [C:\projects\my-llvm\build\tools\clang\lib\AST\Opcodes.inc @ 4133]
04 00000066`04580c20 00007ff6`55fb4db1 clang!clang::interp::ByteCodeExprGen<clang::interp::EvalEmitter>::visitGlobalInitializer+0xdd [C:\projects\my-llvm\clang\lib\AST\Interp\ByteCodeExprGen.h @ 180]
05 00000066`04580c90 00007ff6`55fb33ce clang!clang::interp::ByteCodeExprGen<clang::interp::EvalEmitter>::visitVarDecl+0x291 [C:\projects\my-llvm\clang\lib\AST\Interp\ByteCodeExprGen.cpp @ 1827]
06 00000066`04580e40 00007ff6`55eb7023 clang!clang::interp::ByteCodeExprGen<clang::interp::EvalEmitter>::visitDecl+0x8e [C:\projects\my-llvm\clang\lib\AST\Interp\ByteCodeExprGen.cpp @ 1772]
07 00000066`04580f30 00007ff6`55d18d54 clang!clang::interp::EvalEmitter::interpretDecl+0x33 [C:\projects\my-llvm\clang\lib\AST\Interp\EvalEmitter.cpp @ 39]
08 00000066`04580f90 00007ff6`55633abf clang!clang::interp::Context::evaluateAsInitializer+0xf4 [C:\projects\my-llvm\clang\lib\AST\Interp\Context.cpp @ 74]
09 00000066`04581290 00007ff6`553b4398 clang!clang::Expr::EvaluateAsInitializer+0x28f [C:\projects\my-llvm\clang\lib\AST\ExprConstant.cpp @ 15545]
0a 00000066`04581880 00007ff6`553b4744 clang!clang::VarDecl::evaluateValueImpl+0x148 [C:\projects\my-llvm\clang\lib\AST\Decl.cpp @ 2555]
0b 00000066`04581940 00007ff6`537e94fc clang!clang::VarDecl::checkForConstantInitialization+0xe4 [C:\projects\my-llvm\clang\lib\AST\Decl.cpp @ 2625]
0c 00000066`04581980 00007ff6`537f8109 clang!clang::Sema::CheckCompleteVariableDeclaration+0xddc [C:\projects\my-llvm\clang\lib\Sema\SemaDecl.cpp @ 14315]
0d 00000066`04582770 00000000`00000000 clang!clang::Sema::AddInitializerToDecl+0x2669 [C:\projects\my-llvm\clang\lib\Sema\SemaDecl.cpp @ 13712]
In CheckArrayInitialized <https://github.com/llvm/llvm-project/blob/6dfe55569d88ff654d13e6c09267eff0cd9c9f0d/clang/lib/AST/Interp/Interp.cpp#L426> `BasePtr.atIndex(I).isInitialized()` returns false, because InitMap does not exist. And it seems that `BasePtr` points to a different object, not the one which corresponds to StringLiteral (at step 2). This new interpreter does not use clang's AST, so it becomes difficult to understand what's happening. Any help would be appreciated. cc @tbaeder.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158591/new/
https://reviews.llvm.org/D158591
More information about the cfe-commits
mailing list