yaxunl added a comment.

I still got assertion when I use the built clang with check-mlir. The reduced 
testcase is

  class A {
  public:
    int foo();
  };
  
  static A a;
  
  struct B {
    B(int x = a.foo());
  };
  
  void test() {
    B x;
  }

The assertion I got is:

  clang: /home/yaxunl/git/llvm/llvm/tools/clang/lib/CodeGen/CGExpr.cpp:2628: 
clang::CodeGen::LValue clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(const 
clang::DeclRefExpr *): Assertion `(ND->isUsed(false) || !isa<VarDecl>(ND) || 
E->isNonOdrUse() || !E->getLocation().isValid()) && "Should not use decl 
without marking it used!"' failed.
  Stack dump:
  
  
   #0 0x000000000258c614 PrintStackTraceSignalHandler(void*) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x258c614)
   #1 0x000000000258a1ae llvm::sys::RunSignalHandlers() 
(/home/yaxunl/git/llvm/assert/bin/clang+0x258a1ae)
   #2 0x000000000258b7a2 llvm::sys::CleanupOnSignal(unsigned long) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x258b7a2)
   #3 0x000000000251d0c3 (anonymous 
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x251d0c3)
   #4 0x000000000251d1fc CrashRecoverySignalHandler(int) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x251d1fc)
   #5 0x00007f0dde3bf390 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
   #6 0x00007f0ddcf29428 raise 
/build/glibc-LK5gWL/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
   #7 0x00007f0ddcf2b02a abort 
/build/glibc-LK5gWL/glibc-2.23/stdlib/abort.c:91:0
   #8 0x00007f0ddcf21bd7 __assert_fail_base 
/build/glibc-LK5gWL/glibc-2.23/assert/assert.c:92:0
   #9 0x00007f0ddcf21c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
  #10 0x0000000002a1a5df 
clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x2a1a5df)
  #11 0x0000000002a0dfb6 
clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x2a0dfb6)
  #12 0x0000000002a39973 
clang::CodeGen::CodeGenFunction::EmitCXXMemberOrOperatorMemberCallExpr(clang::CallExpr
 const*, clang::CXXMethodDecl const*, clang::CodeGen::ReturnValueSlot, bool, 
clang::NestedNameSpecifier*, bool, clang::Expr const*) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x2a39973)
  #13 0x0000000002a389b9 
clang::CodeGen::CodeGenFunction::EmitCXXMemberCallExpr(clang::CXXMemberCallExpr 
const*, clang::CodeGen::ReturnValueSlot) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x2a389b9)
  #14 0x0000000002a28f95 
clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, 
clang::CodeGen::ReturnValueSlot) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x2a28f95)
  #15 0x0000000002a5be29 (anonymous 
namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x2a5be29)
  #16 0x0000000002a55b19 clang::StmtVisitorBase<std::add_pointer, (anonymous 
namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x2a55b19)
  #17 0x0000000002a4b615 
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x2a4b615)
  #18 0x0000000002a0da30 
clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, 
clang::CodeGen::AggValueSlot, bool) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x2a0da30)
  #19 0x0000000002a0edde 
clang::CodeGen::CodeGenFunction::EmitAnyExprToTemp(clang::Expr const*) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x2a0edde)
  #20 0x00000000029cdd6b 
clang::CodeGen::CodeGenFunction::EmitCallArg(clang::CodeGen::CallArgList&, 
clang::Expr const*, clang::QualType) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x29cdd6b)
  #21 0x00000000029ccc41 
clang::CodeGen::CodeGenFunction::EmitCallArgs(clang::CodeGen::CallArgList&, 
llvm::ArrayRef<clang::QualType>, 
llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, clang::Expr const* 
const, clang::Stmt const* const> >, 
clang::CodeGen::CodeGenFunction::AbstractCallee, unsigned int, 
clang::CodeGen::CodeGenFunction::EvaluationOrder) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x29ccc41)
  #22 0x00000000028d8e7b void 
clang::CodeGen::CodeGenFunction::EmitCallArgs<clang::FunctionProtoType>(clang::CodeGen::CallArgList&,
 clang::FunctionProtoType const*, 
llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, clang::Expr const* 
const, clang::Stmt const* const> >, 
clang::CodeGen::CodeGenFunction::AbstractCallee, unsigned int, 
clang::CodeGen::CodeGenFunction::EvaluationOrder) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x28d8e7b)
  #23 0x00000000029de431 
clang::CodeGen::CodeGenFunction::EmitCXXConstructorCall(clang::CXXConstructorDecl
 const*, clang::CXXCtorType, bool, bool, clang::CodeGen::AggValueSlot, 
clang::CXXConstructExpr const*) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x29de431)
  #24 0x0000000002a3b84e 
clang::CodeGen::CodeGenFunction::EmitCXXConstructExpr(clang::CXXConstructExpr 
const*, clang::CodeGen::AggValueSlot) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x2a3b84e)
  #25 0x0000000002a32a8b (anonymous 
namespace)::AggExprEmitter::VisitCXXConstructExpr(clang::CXXConstructExpr 
const*) (/home/yaxunl/git/llvm/assert/bin/clang+0x2a32a8b)
  #26 0x0000000002a2d44f 
clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, 
clang::CodeGen::AggValueSlot) (/home/yaxunl/git/llvm/assert/bin/clang+0x2a2d44f)
  #27 0x00000000029f96fc 
clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, 
clang::ValueDecl const*, clang::CodeGen::LValue, bool) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x29f96fc)
  #28 0x00000000029f68d9 
clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission
 const&) (/home/yaxunl/git/llvm/assert/bin/clang+0x29f68d9)
  #29 0x00000000029f1ca5 
clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x29f1ca5)
  #30 0x00000000029f1935 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl 
const&) (/home/yaxunl/git/llvm/assert/bin/clang+0x29f1935)
  #31 0x00000000027e07fb 
clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x27e07fb)
  #32 0x00000000027d7a4c 
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x27d7a4c)
  #33 0x00000000027d66cb clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt 
const*, llvm::ArrayRef<clang::Attr const*>) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x27d66cb)
  #34 0x00000000027e15f0 
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
 const&, bool, clang::CodeGen::AggValueSlot) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x27e15f0)
  #35 0x000000000282ffb6 
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, 
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x282ffb6)
  #36 0x000000000284dc52 
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, 
llvm::GlobalValue*) (/home/yaxunl/git/llvm/assert/bin/clang+0x284dc52)
  #37 0x0000000002845cc7 
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, 
llvm::GlobalValue*) (/home/yaxunl/git/llvm/assert/bin/clang+0x2845cc7)
  #38 0x0000000002852271 
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) 
(/home/yaxunl/git/llvm/assert/bin/clang+0x2852271)

It is weird since this is not en OpenMP nor CUDA program and there is no 
deferred diags involved.

It seems somehow my change caused some decl missing used flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70172



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

Reply via email to