[PATCH] D42715: LTO: Drop comdats when converting definitions to declarations.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 15:53:12 PST 2018


pcc created this revision.
pcc added a reviewer: tejohnson.
Herald added subscribers: hiraditya, inglorion, mehdi_amini.

https://reviews.llvm.org/D42715

Files:
  llvm/lib/Transforms/IPO/FunctionImport.cpp
  llvm/test/LTO/Resolution/X86/not-prevailing.ll


Index: llvm/test/LTO/Resolution/X86/not-prevailing.ll
===================================================================
--- llvm/test/LTO/Resolution/X86/not-prevailing.ll
+++ llvm/test/LTO/Resolution/X86/not-prevailing.ll
@@ -24,7 +24,8 @@
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
-define weak i32 @foo() {
+$foo = comdat any
+define weak i32 @foo() comdat {
   ret i32 65
 }
 
Index: llvm/lib/Transforms/IPO/FunctionImport.cpp
===================================================================
--- llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -618,10 +618,12 @@
   if (Function *F = dyn_cast<Function>(&GV)) {
     F->deleteBody();
     F->clearMetadata();
+    F->setComdat(nullptr);
   } else if (GlobalVariable *V = dyn_cast<GlobalVariable>(&GV)) {
     V->setInitializer(nullptr);
     V->setLinkage(GlobalValue::ExternalLinkage);
     V->clearMetadata();
+    V->setComdat(nullptr);
   } else
     // For now we don't resolve or drop aliases. Once we do we'll
     // need to add support here for creating either a function or


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42715.132068.patch
Type: text/x-patch
Size: 1150 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180130/e3cb5f6b/attachment.bin>


More information about the llvm-commits mailing list