[llvm-bugs] [Bug 27870] New: [DeadArgElim] discard comdats
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue May 24 17:57:38 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=27870
Bug ID: 27870
Summary: [DeadArgElim] discard comdats
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: Interprocedural Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: rnk at google.com
CC: david.majnemer at gmail.com, llvm-bugs at lists.llvm.org,
rafael.espindola at gmail.com
Classification: Unclassified
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160525/0b72a23c/attachment.html>
More information about the llvm-bugs
mailing list