Skip to content

Commit

Permalink
Fix bug with Opaque-ifying identified structs with non-identified mem…
Browse files Browse the repository at this point in the history
…bers
  • Loading branch information
ivanradanov committed Oct 26, 2023
1 parent 06bc20e commit dcd4d0e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/polygeist/Passes/ConvertToOpaquePtr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,10 @@ struct ConvertToOpaquePtrPass
}
for (auto ty : st.getBody()) {
StringRef fieldKey = "";
if (auto fieldST = ty.dyn_cast<LLVM::LLVMStructType>())
fieldKey = fieldST.getName();
if (auto fieldST = ty.dyn_cast<LLVM::LLVMStructType>()) {
if (fieldST.isIdentified())
fieldKey = fieldST.getName();
}
if (typeCache.find(fieldKey) != typeCache.end()) {
bodyTypes.push_back(typeCache[fieldKey]);
} else {
Expand Down
23 changes: 23 additions & 0 deletions tools/cgeist/Test/Verification/opaquestr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// RUN: cgeist %s %stdinclude -S | FileCheck %s

struct Str {
int a;
float b;
};

struct OperandInfo {
OperandInfo *info;
struct {
int a;
float b;
} intfloat;
Str a;
Str *b;
int c;
};

void *foo(OperandInfo *info) {
return info;
}

// CHECK: memref<?x!llvm.struct<"opaque@polygeist@mlir@struct.OperandInfo", (memref<?x!llvm.struct<"opaque@polygeist@mlir@struct.OperandInfo">>, struct<(i32, f32)>, struct<(i32, f32)>, memref<?x!llvm.struct<(i32, f32)>>, i32)>>

0 comments on commit dcd4d0e

Please sign in to comment.