mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Change the .ll syntax for comdats and add a syntactic sugar.
In order to make comdats always explicit in the IR, we decided to make the syntax a bit more compact for the case of a GlobalObject in a comdat with the same name. Just dropping the $name causes problems for @foo = globabl i32 0, comdat $bar = comdat ... and declare void @foo() comdat $bar = comdat ... So the syntax is changed to @g1 = globabl i32 0, comdat($c1) @g2 = globabl i32 0, comdat and declare void @foo() comdat($c1) declare void @foo() comdat git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225302 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
+20
-8
@@ -1683,6 +1683,24 @@ static void PrintThreadLocalModel(GlobalVariable::ThreadLocalMode TLM,
|
||||
}
|
||||
}
|
||||
|
||||
static void maybePrintComdat(formatted_raw_ostream &Out,
|
||||
const GlobalObject &GO) {
|
||||
const Comdat *C = GO.getComdat();
|
||||
if (!C)
|
||||
return;
|
||||
|
||||
if (isa<GlobalVariable>(GO))
|
||||
Out << ',';
|
||||
Out << " comdat";
|
||||
|
||||
if (GO.getName() == C->getName())
|
||||
return;
|
||||
|
||||
Out << '(';
|
||||
PrintLLVMName(Out, C->getName(), ComdatPrefix);
|
||||
Out << ')';
|
||||
}
|
||||
|
||||
void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
|
||||
if (GV->isMaterializable())
|
||||
Out << "; Materializable\n";
|
||||
@@ -1716,10 +1734,7 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
|
||||
PrintEscapedString(GV->getSection(), Out);
|
||||
Out << '"';
|
||||
}
|
||||
if (GV->hasComdat()) {
|
||||
Out << ", comdat ";
|
||||
PrintLLVMName(Out, GV->getComdat()->getName(), ComdatPrefix);
|
||||
}
|
||||
maybePrintComdat(Out, *GV);
|
||||
if (GV->getAlignment())
|
||||
Out << ", align " << GV->getAlignment();
|
||||
|
||||
@@ -1900,10 +1915,7 @@ void AssemblyWriter::printFunction(const Function *F) {
|
||||
PrintEscapedString(F->getSection(), Out);
|
||||
Out << '"';
|
||||
}
|
||||
if (F->hasComdat()) {
|
||||
Out << " comdat ";
|
||||
PrintLLVMName(Out, F->getComdat()->getName(), ComdatPrefix);
|
||||
}
|
||||
maybePrintComdat(Out, *F);
|
||||
if (F->getAlignment())
|
||||
Out << " align " << F->getAlignment();
|
||||
if (F->hasGC())
|
||||
|
||||
Reference in New Issue
Block a user