Skip to content

Support of symbol references in CIRGenExprConst #242

@yugr

Description

@yugr

Some parts of CIRGenExprConst.cpp assumes that attributes generated for RHS of assignments are TypedAttr's e.g.

  auto typedC = llvm::dyn_cast<mlir::TypedAttr>(C);                                                                                                                                                        
  if (!typedC)                                                                  
    llvm_unreachable("this should always be typed");                            
  return typedC;                                                                

But in some cases SymbolRefAttr could be generated as well e.g. in

$ cat tmp.c
typedef struct {
  char *name;
} A;

A foo = {"1"};

$ /home/huawei/src/clangir/build/bin/clang -fclangir-enable -S tmp.c
this should always be typed
UNREACHABLE executed at /home/huawei/src/clangir/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp:1428!
...
#13 0x00007fa8faecf572 cir::ConstantEmitter::tryEmitPrivate(clang::Expr const*, clang::QualType) /home/huawei/src/clangir/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp:1429:10

Perhaps GlobalViewAttr should be used instead of SymbolRefAttr in such cases?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions