Skip to content

Commit b32e40c

Browse files
committed
fix spurious error when a global var is removed
IPO issues must be skipable so alivecc can find the real issues
1 parent 0a77879 commit b32e40c

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

llvm_util/llvm2alive.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,15 +1617,10 @@ class llvm2alive_ : public llvm::InstVisitor<llvm2alive_, unique_ptr<Instr>> {
16171617
auto &entry_name = Fn.getFirstBB().getName();
16181618
BB = &Fn.getBB("#init", true);
16191619

1620+
// Ensure all src globals exist in target as well
16201621
for (auto &gvname : gvnamesInSrc) {
1621-
auto gv = getGlobalVariable(string(gvname));
1622-
if (!gv) {
1623-
// global variable removed or renamed
1624-
*out << "ERROR: Unsupported interprocedural transformation\n";
1625-
return {};
1626-
}
1627-
// If gvname already exists in tgt, get_operand will immediately return
1628-
get_operand(gv);
1622+
if (auto gv = getGlobalVariable(string(gvname)))
1623+
get_operand(gv);
16291624
}
16301625

16311626
map<string, unique_ptr<Store>> stores;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; ERROR: Mismatch in memory
2+
3+
@glb = internal global i8 0
4+
5+
define void @f() {
6+
store i8 0, ptr @glb
7+
ret void
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
define void @f() {
2+
ret void
3+
}

tests/clang-tv/skip-globalopt.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// TEST-ARGS: -O2
2+
3+
static int x;
4+
5+
void fn() {
6+
x = 0;
7+
}

0 commit comments

Comments
 (0)