From e936d5ef25b30282d65bec5a97dfbbf53193adc4 Mon Sep 17 00:00:00 2001 From: "A. R. Shajii" Date: Sat, 27 Apr 2024 12:23:48 -0400 Subject: [PATCH] Fix variable naming in LLVM IR Avoid ".L" prefix as those indicate linker-local names --- codon/cir/llvm/llvisitor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/codon/cir/llvm/llvisitor.cpp b/codon/cir/llvm/llvisitor.cpp index c2349ce5..99b543d6 100644 --- a/codon/cir/llvm/llvisitor.cpp +++ b/codon/cir/llvm/llvisitor.cpp @@ -59,10 +59,12 @@ std::string LLVMVisitor::getNameForVar(const Var *x) { if (auto *f = cast(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; } }