werat added a comment.

In D113498#3139112 <https://reviews.llvm.org/D113498#3139112>, @shafik wrote:

> On the other hand this is a well-formed constant expression:
>
>   static const int x =0;
>   constexpr const int* ip1 = &x + 1;
>
> Does that get you the test case you need?

This expression seems to be similar to what I have in the test case now.

  (lldb) p static const int x = 0; constexpr const int* ip1 = &x + 1;
  ...
  ; Function Attrs: convergent noinline nounwind optnone
  define dso_local void @"?$__lldb_expr@@YAXPEAX@Z"(i8* %"$__lldb_arg") #0 {
  entry:
    %"$__lldb_arg.addr" = alloca i8*, align 8, !clang.decl.ptr !9
    %ip1 = alloca i32*, align 8, !clang.decl.ptr !10
    store i8* %"$__lldb_arg", i8** %"$__lldb_arg.addr", align 8
    store i32* bitcast (i8* getelementptr (i8, i8* bitcast (i32* 
@"?x@?1??$__lldb_expr@@YAXPEAX@Z@4HB" to i8*), i64 4) to i32*), i32** %ip1, 
align 8
    ret void
  }

As far as I understand, `getelementptr (i8, i8* bitcast (i32* 
@"?x@?1??$__lldb_expr@@YAXPEAX@Z@4HB" to i8*), i64 4)` is a well-formed 
constant expression, however it has `GlobalVariableVal` as one of it's operand. 
Even though `GlobalVariableVal` is `Constant`, I think it's not always possible 
to resolve its value (please correct me if that's not true, not very familiar 
with IR). Even if there's a way, it's not currently implemented in the 
IRInterpreter -- `CanResolveConstant` will return false when it sees 
`GlobalVariableVal`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113498/new/

https://reviews.llvm.org/D113498

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to