<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - [DeadArgElim] discard comdats"
href="https://llvm.org/bugs/show_bug.cgi?id=27870">27870</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[DeadArgElim] discard comdats
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Interprocedural Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>rnk@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>david.majnemer@gmail.com, llvm-bugs@lists.llvm.org, rafael.espindola@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>DAE does this innocuous thing:
// Create the new function body and insert it into the module...
Function *NF = Function::Create(NFTy, Fn.getLinkage());
NF->copyAttributesFrom(&Fn);
Fn.getParent()->getFunctionList().insert(Fn.getIterator(), NF);
NF->takeName(&Fn);
But copyAttributesFrom doesn't copy comdats. I'm not sure why. Doing the
obvious thing results in these test failures:
$ git diff HEAD
diff --git a/lib/IR/Globals.cpp b/lib/IR/Globals.cpp
index 7e8ef65..3bf3cc2 100644
--- a/lib/IR/Globals.cpp
+++ b/lib/IR/Globals.cpp
@@ -96,6 +96,7 @@ void GlobalObject::copyAttributesFrom(const GlobalValue *Src)
{
if (const auto *GV = dyn_cast<GlobalObject>(Src)) {
setAlignment(GV->getAlignment());
setSection(GV->getSection());
+ setComdat(const_cast<GlobalObject *>(GV)->getComdat());
}
}
...
FAIL: LLVM :: Linker/comdat16.ll (10982 of 16849)
******************** TEST 'LLVM :: Linker/comdat16.ll' FAILED
********************
Script:
--
D:/src/llvm/build/./bin\llvm-link.EXE -S -o -
D:\src\llvm\test\Linker\comdat16.ll D:\src\llvm\test\Linker/Inputs/comdat16.ll
| D:/src/llvm/build/./bin\FileCheck.EXE D:\src\llvm\test\Linker\comdat16.ll
--
Exit Code: 2
Command Output (stdout):
--
Command 0: "D:/src/llvm/build/./bin\llvm-link.EXE" "-S" "-o" "-"
"D:\src\llvm\test\Linker\comdat16.ll"
"D:\src\llvm\test\Linker/Inputs/comdat16.ll"
Command 0 Result: 1
Command 0 Output:
Command 0 Stderr:
Declaration may not be in a Comdat!
i32* @will_be_undefined
D:/src/llvm/build/./bin\llvm-link.EXE: error: linked module is broken!
Command 1: "D:/src/llvm/build/./bin\FileCheck.EXE"
"D:\src\llvm\test\Linker\comdat16.ll"
Command 1 Result: 2
Command 1 Output:
Command 1 Stderr:
FileCheck error: '-' is empty.
--
********************
Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
Testing Time: 194.10s
********************
Failing Tests (3):
LLVM :: Linker/comdat11.ll
LLVM :: Linker/comdat14.ll
LLVM :: Linker/comdat16.ll
Filing so experts can look at it.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>