[PATCH] D48455: Remove hip.amdgcn.bc hc.amdgcn.bc from HIP Toolchains

2018-06-21 Thread Aaron En Ye Shi via Phabricator via cfe-commits
ashi1 created this revision.
ashi1 added a reviewer: yaxunl.
ashi1 added projects: clang, AMDGPU.
Herald added a subscriber: cfe-commits.

Removing hip.amdgcn.bc and hc.amdgcn.bc from HIP ToolChains. These need to be 
removed in VDI build.


Repository:
  rC Clang

https://reviews.llvm.org/D48455

Files:
  lib/Driver/ToolChains/HIP.cpp


Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -75,12 +75,12 @@
 std::string ISAVerBC =
 "oclc_isa_version_" + SubArchName.drop_front(3).str() + ".amdgcn.bc";

-BCLibs.append({"hip.amdgcn.bc", "hc.amdgcn.bc", "opencl.amdgcn.bc",
+BCLibs.append({"opencl.amdgcn.bc",
"ockl.amdgcn.bc", "irif.amdgcn.bc", "ocml.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
"oclc_daz_opt_off.amdgcn.bc",
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
-   "oclc_unsafe_math_off.amdgcn.bc", "hc.amdgcn.bc", 
ISAVerBC});
+   "oclc_unsafe_math_off.amdgcn.bc", ISAVerBC});
   }
   for (auto Lib : BCLibs)
 addBCLib(C, Args, CmdArgs, LibraryPaths, Lib);


Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -75,12 +75,12 @@
 std::string ISAVerBC =
 "oclc_isa_version_" + SubArchName.drop_front(3).str() + ".amdgcn.bc";

-BCLibs.append({"hip.amdgcn.bc", "hc.amdgcn.bc", "opencl.amdgcn.bc",
+BCLibs.append({"opencl.amdgcn.bc",
"ockl.amdgcn.bc", "irif.amdgcn.bc", "ocml.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
"oclc_daz_opt_off.amdgcn.bc",
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
-   "oclc_unsafe_math_off.amdgcn.bc", "hc.amdgcn.bc", ISAVerBC});
+   "oclc_unsafe_math_off.amdgcn.bc", ISAVerBC});
   }
   for (auto Lib : BCLibs)
 addBCLib(C, Args, CmdArgs, LibraryPaths, Lib);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39739: [HCC] Add flag to Import Weak Functions in Function Importer

2018-03-22 Thread Aaron En Ye Shi via Phabricator via cfe-commits
ashi1 added a comment.
Herald added a subscriber: llvm-commits.

Is first one encountered a poor design?


Repository:
  rL LLVM

https://reviews.llvm.org/D39739



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39739: [HCC] Add flag to Import Weak Functions in Function Importer

2017-11-09 Thread Aaron En Ye Shi via Phabricator via cfe-commits
ashi1 updated this revision to Diff 122271.
ashi1 added subscribers: scchan, yaxunl, ashi1.
ashi1 added a comment.
Herald added a subscriber: eraman.

I've added the lit tests for this change, and also showing full context.

My lit test import_weak_type.ll follows similar format to import_opaque_type.ll.


Repository:
  rL LLVM

https://reviews.llvm.org/D39739

Files:
  include/llvm/Transforms/Utils/FunctionImportUtils.h
  lib/Transforms/IPO/FunctionImport.cpp
  lib/Transforms/Utils/FunctionImportUtils.cpp
  test/ThinLTO/X86/Inputs/import_weak_type.ll
  test/ThinLTO/X86/import_weak_type.ll


Index: test/ThinLTO/X86/import_weak_type.ll
===
--- /dev/null
+++ test/ThinLTO/X86/import_weak_type.ll
@@ -0,0 +1,19 @@
+; Do setup work for all below tests: generate bitcode and combined index
+; RUN: opt -module-summary %s -o %t.bc
+; RUN: opt -module-summary %p/Inputs/import_weak_type.ll -o %t2.bc
+; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
+
+; Check that we import correctly the imported weak type to replace declaration 
here
+; RUN: llvm-lto -thinlto-action=import %t.bc -thinlto-index=%t3.bc 
-force-import-weak -o - | llvm-dis -o - | FileCheck %s
+; CHECK: define weak void @foo()
+
+
+target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target triple = "amdgcn--amdhsa-hcc"
+
+declare extern_weak void @foo()
+define weak_odr amdgpu_kernel void @main() {
+call void @foo()
+  ret void
+}
+
Index: test/ThinLTO/X86/Inputs/import_weak_type.ll
===
--- /dev/null
+++ test/ThinLTO/X86/Inputs/import_weak_type.ll
@@ -0,0 +1,7 @@
+target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target triple = "amdgcn--amdhsa-hcc"
+
+define weak void @foo() {
+  ret void
+}
+
Index: lib/Transforms/Utils/FunctionImportUtils.cpp
===
--- lib/Transforms/Utils/FunctionImportUtils.cpp
+++ lib/Transforms/Utils/FunctionImportUtils.cpp
@@ -151,7 +151,8 @@
 // program semantics, since the linker will pick the first weak_any
 // definition and importing would change the order they are seen by the
 // linker. The module linking caller needs to enforce this.
-assert(!doImportAsDefinition(SGV));
+if(!ForceImportWeakFlag)
+  assert(!doImportAsDefinition(SGV));
 // If imported as a declaration, it becomes external_weak.
 return SGV->getLinkage();
 
Index: lib/Transforms/IPO/FunctionImport.cpp
===
--- lib/Transforms/IPO/FunctionImport.cpp
+++ lib/Transforms/IPO/FunctionImport.cpp
@@ -102,6 +102,12 @@
 static cl::opt ComputeDead("compute-dead", cl::init(true), cl::Hidden,
  cl::desc("Compute dead symbols"));
 
+bool llvm::ForceImportWeakFlag;
+static cl::opt
+ForceImportWeak("force-import-weak", cl::Hidden,
+cl::desc("Allow weak functions to be imported"),
+cl::location(ForceImportWeakFlag), cl::init(false));
+
 static cl::opt EnableImportMetadata(
 "enable-import-metadata", cl::init(
 #if !defined(NDEBUG)
@@ -169,7 +175,7 @@
 // filtered out.
 if (GVSummary->getSummaryKind() == GlobalValueSummary::GlobalVarKind)
   return false;
-if (GlobalValue::isInterposableLinkage(GVSummary->linkage()))
+if (!ForceImportWeakFlag && 
GlobalValue::isInterposableLinkage(GVSummary->linkage()))
   // There is no point in importing these, we can't inline them
   return false;
 if (isa(GVSummary))
Index: include/llvm/Transforms/Utils/FunctionImportUtils.h
===
--- include/llvm/Transforms/Utils/FunctionImportUtils.h
+++ include/llvm/Transforms/Utils/FunctionImportUtils.h
@@ -21,6 +21,9 @@
 namespace llvm {
 class Module;
 
+// Set to true depending on option -force-import-weak
+extern bool ForceImportWeakFlag;
+
 /// Class to handle necessary GlobalValue changes required by ThinLTO
 /// function importing, including linkage changes and any necessary renaming.
 class FunctionImportGlobalProcessing {


Index: test/ThinLTO/X86/import_weak_type.ll
===
--- /dev/null
+++ test/ThinLTO/X86/import_weak_type.ll
@@ -0,0 +1,19 @@
+; Do setup work for all below tests: generate bitcode and combined index
+; RUN: opt -module-summary %s -o %t.bc
+; RUN: opt -module-summary %p/Inputs/import_weak_type.ll -o %t2.bc
+; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
+
+; Check that we import correctly the imported weak type to replace declaration here
+; RUN: llvm-lto -