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

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 18:42:08 PST 2018


LGTM

Peter Collingbourne via Phabricator via llvm-commits
<llvm-commits at lists.llvm.org> writes:

> 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
>
>
> 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
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list