Skip to content

Commit 7abbb3a

Browse files
authored
Fix bug with Opaque-ifying identified structs with non-identified members (#365)
1 parent 06bc20e commit 7abbb3a

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

lib/polygeist/Passes/ConvertToOpaquePtr.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,10 @@ struct ConvertToOpaquePtrPass
247247
}
248248
for (auto ty : st.getBody()) {
249249
StringRef fieldKey = "";
250-
if (auto fieldST = ty.dyn_cast<LLVM::LLVMStructType>())
251-
fieldKey = fieldST.getName();
250+
if (auto fieldST = ty.dyn_cast<LLVM::LLVMStructType>()) {
251+
if (fieldST.isIdentified())
252+
fieldKey = fieldST.getName();
253+
}
252254
if (typeCache.find(fieldKey) != typeCache.end()) {
253255
bodyTypes.push_back(typeCache[fieldKey]);
254256
} else {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: cgeist %s %stdinclude -S | FileCheck %s
2+
3+
struct Str {
4+
int a;
5+
float b;
6+
};
7+
8+
struct OperandInfo {
9+
OperandInfo *info;
10+
struct {
11+
int a;
12+
float b;
13+
} intfloat;
14+
Str a;
15+
Str *b;
16+
int c;
17+
};
18+
19+
void *foo(OperandInfo *info) {
20+
return info;
21+
}
22+
23+
// CHECK: memref<?x!llvm.struct<"opaque@polygeist@[email protected]", (memref<?x!llvm.struct<"opaque@polygeist@[email protected]">>, struct<(i32, f32)>, struct<(i32, f32)>, memref<?x!llvm.struct<(i32, f32)>>, i32)>>

0 commit comments

Comments
 (0)