Skip to content

Commit

Permalink
Fix variable naming in LLVM IR
Browse files Browse the repository at this point in the history
Avoid ".L" prefix as those indicate linker-local names
  • Loading branch information
arshajii committed Apr 27, 2024
1 parent e7bb5c1 commit e936d5e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions codon/cir/llvm/llvisitor.cpp
Expand Up @@ -59,10 +59,12 @@ std::string LLVMVisitor::getNameForVar(const Var *x) {
if (auto *f = cast<Func>(x))
return getNameForFunction(f);

auto name = x->getName();
if (x->isExternal()) {
return x->getName();
return name;
} else {
return "." + x->getName();
// ".Lxxx" is a linker-local name, so add an underscore if needed
return ((!name.empty() && name[0] == 'L') ? "._" : ".") + name;
}
}

Expand Down

0 comments on commit e936d5e

Please sign in to comment.