On Sat, Apr 8, 2023 at 2:50 AM Timm Bäder via cfe-commits <cfe-commits@lists.llvm.org> wrote: > > > Author: Timm Bäder > Date: 2023-04-08T08:49:22+02:00 > New Revision: e7f55bbdb880eb0c096b05d915ee920fe1f2fb98 > > URL: > https://github.com/llvm/llvm-project/commit/e7f55bbdb880eb0c096b05d915ee920fe1f2fb98 > DIFF: > https://github.com/llvm/llvm-project/commit/e7f55bbdb880eb0c096b05d915ee920fe1f2fb98.diff > > LOG: [clang][Interp][NFCI] Call* ops don't modify the PC
Err, I don't think this is actually NFC given that it's fixing a crash. Can you add test coverage for the change? ~Aaron > > This caused the reported errors from the Call*() handlers to report the > wrong source location. > > Fixes: https://github.com/llvm/llvm-project/issues/62002 > > Added: > > > Modified: > clang/lib/AST/Interp/Interp.h > clang/lib/AST/Interp/Opcodes.td > > Removed: > > > > ################################################################################ > diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h > index afc5f24baf73..1eda38e9fa5b 100644 > --- a/clang/lib/AST/Interp/Interp.h > +++ b/clang/lib/AST/Interp/Interp.h > @@ -1486,28 +1486,29 @@ inline bool ArrayElemPtrPop(InterpState &S, CodePtr > OpPC) { > return NarrowPtr(S, OpPC); > } > > -inline bool CheckGlobalCtor(InterpState &S, CodePtr &PC) { > +inline bool CheckGlobalCtor(InterpState &S, CodePtr OpPC) { > const Pointer &Obj = S.Stk.peek<Pointer>(); > - return CheckCtorCall(S, PC, Obj); > + return CheckCtorCall(S, OpPC, Obj); > } > > -inline bool Call(InterpState &S, CodePtr &PC, const Function *Func) { > +inline bool Call(InterpState &S, CodePtr OpPC, const Function *Func) { > if (Func->hasThisPointer()) { > size_t ThisOffset = > Func->getArgSize() + (Func->hasRVO() ? primSize(PT_Ptr) : 0); > + > const Pointer &ThisPtr = S.Stk.peek<Pointer>(ThisOffset); > > - if (!CheckInvoke(S, PC, ThisPtr)) > + if (!CheckInvoke(S, OpPC, ThisPtr)) > return false; > > if (S.checkingPotentialConstantExpression()) > return false; > } > > - if (!CheckCallable(S, PC, Func)) > + if (!CheckCallable(S, OpPC, Func)) > return false; > > - auto NewFrame = std::make_unique<InterpFrame>(S, Func, PC); > + auto NewFrame = std::make_unique<InterpFrame>(S, Func, OpPC); > InterpFrame *FrameBefore = S.Current; > S.Current = NewFrame.get(); > > @@ -1541,14 +1542,14 @@ inline bool CallBI(InterpState &S, CodePtr &PC, const > Function *Func) { > return false; > } > > -inline bool CallPtr(InterpState &S, CodePtr &PC) { > +inline bool CallPtr(InterpState &S, CodePtr OpPC) { > const FunctionPointer &FuncPtr = S.Stk.pop<FunctionPointer>(); > > const Function *F = FuncPtr.getFunction(); > if (!F || !F->isConstexpr()) > return false; > > - return Call(S, PC, F); > + return Call(S, OpPC, F); > } > > inline bool GetFnPtr(InterpState &S, CodePtr &PC, const Function *Func) { > > diff --git a/clang/lib/AST/Interp/Opcodes.td > b/clang/lib/AST/Interp/Opcodes.td > index f3662dcd6f43..ed0774a78833 100644 > --- a/clang/lib/AST/Interp/Opcodes.td > +++ b/clang/lib/AST/Interp/Opcodes.td > @@ -179,19 +179,16 @@ def NoRet : Opcode {} > def Call : Opcode { > let Args = [ArgFunction]; > let Types = []; > - let ChangesPC = 1; > } > > def CallBI : Opcode { > let Args = [ArgFunction]; > let Types = []; > - let ChangesPC = 1; > } > > def CallPtr : Opcode { > let Args = []; > let Types = []; > - let ChangesPC = 1; > } > > > //===----------------------------------------------------------------------===// > > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits