Remove patches that are present in this version of llvm and backport a
fix to prevent linking errors.

Signed-off-by: Anuj Mittal <[email protected]>
---
 .../clang/files/0001-skip-building-tests.patch     |  22 ++--
 ...tils-Add-metadata-fixing-in-SplitBlockPre.patch | 111 ----------------
 ...ify-Do-not-use-SCEV-expander-for-IVCount-.patch | 146 ---------------------
 .../clang/files/fix-shared-libs.patch              |  30 +++++
 .../clang/llvm-project-source.bbappend             |   7 +-
 5 files changed, 44 insertions(+), 272 deletions(-)
 delete mode 100644 
dynamic-layers/clang-layer/recipes-devtools/clang/files/BasicBlockUtils-Add-metadata-fixing-in-SplitBlockPre.patch
 delete mode 100644 
dynamic-layers/clang-layer/recipes-devtools/clang/files/IndVarSimplify-Do-not-use-SCEV-expander-for-IVCount-.patch
 create mode 100644 
dynamic-layers/clang-layer/recipes-devtools/clang/files/fix-shared-libs.patch

diff --git 
a/dynamic-layers/clang-layer/recipes-devtools/clang/files/0001-skip-building-tests.patch
 
b/dynamic-layers/clang-layer/recipes-devtools/clang/files/0001-skip-building-tests.patch
index 9a7b844..8e58ec2 100644
--- 
a/dynamic-layers/clang-layer/recipes-devtools/clang/files/0001-skip-building-tests.patch
+++ 
b/dynamic-layers/clang-layer/recipes-devtools/clang/files/0001-skip-building-tests.patch
@@ -1,4 +1,4 @@
-From 48e50f06b1bbed94cdf5207587161d4bfce7366e Mon Sep 17 00:00:00 2001
+From 455ce9c25df5313f4a6649cc27075bdfbe25af18 Mon Sep 17 00:00:00 2001
 From: Naveen Saini <[email protected]>
 Date: Wed, 21 Aug 2019 14:35:31 +0800
 Subject: [PATCH] llvm-spirv: skip building tests
@@ -19,33 +19,33 @@ Signed-off-by: Naveen Saini <[email protected]>
  1 file changed, 10 deletions(-)
 
 diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 1208741..20ca3e6 100644
+index b718c00..9805140 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
-@@ -15,13 +15,6 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
-   set(CMAKE_CXX_STANDARD 11)
+@@ -24,13 +24,6 @@ if(LLVM_SPIRV_BUILD_EXTERNAL)
+   set(CMAKE_CXX_STANDARD 14)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
  
--  if(LLVM_INCLUDE_TESTS)
+-  if(LLVM_SPIRV_INCLUDE_TESTS)
 -    set(LLVM_TEST_COMPONENTS
 -      llvm-as
 -      llvm-dis
 -    )
--  endif(LLVM_INCLUDE_TESTS)
+-  endif(LLVM_SPIRV_INCLUDE_TESTS)
 -
-   find_package(LLVM 9.0.0 REQUIRED
+   find_package(LLVM 10.0.0 REQUIRED
      COMPONENTS
        Analysis
-@@ -56,9 +49,6 @@ set(LLVM_SPIRV_INCLUDE_DIRS 
${CMAKE_CURRENT_SOURCE_DIR}/include)
+@@ -61,9 +54,6 @@ set(LLVM_SPIRV_INCLUDE_DIRS 
${CMAKE_CURRENT_SOURCE_DIR}/include)
  
  add_subdirectory(lib/SPIRV)
  add_subdirectory(tools/llvm-spirv)
--if(LLVM_INCLUDE_TESTS)
+-if(LLVM_SPIRV_INCLUDE_TESTS)
 -  add_subdirectory(test)
--endif(LLVM_INCLUDE_TESTS)
+-endif(LLVM_SPIRV_INCLUDE_TESTS)
  
  install(
    FILES
 -- 
-2.17.1
+2.7.4
 
diff --git 
a/dynamic-layers/clang-layer/recipes-devtools/clang/files/BasicBlockUtils-Add-metadata-fixing-in-SplitBlockPre.patch
 
b/dynamic-layers/clang-layer/recipes-devtools/clang/files/BasicBlockUtils-Add-metadata-fixing-in-SplitBlockPre.patch
deleted file mode 100644
index cd51997..0000000
--- 
a/dynamic-layers/clang-layer/recipes-devtools/clang/files/BasicBlockUtils-Add-metadata-fixing-in-SplitBlockPre.patch
+++ /dev/null
@@ -1,111 +0,0 @@
-From eeb816d95f0910bd246e37bb2bb3923acf0edf6b Mon Sep 17 00:00:00 2001
-From: Aleksander Us <[email protected]>
-Date: Mon, 26 Aug 2019 15:47:41 +0300
-Subject: [PATCH] [BasicBlockUtils] Add metadata fixing in
- SplitBlockPredecessors.
-
-In case when BB is header of some loop and predecessor is latch of
-this loop, metadata was not attached to newly created basic block.
-This led to loss of loop metadata for other passes.
-
-Upstream-Status: Submitted [https://reviews.llvm.org/D66892]
-
-https://github.com/intel/llvm-patches/commit/8af4449e2d201707f7f2f832b473a0439e255f32
-
-Signed-off-by: Naveen Saini <[email protected]>
----
- lib/Transforms/Utils/BasicBlockUtils.cpp      | 23 ++++++++----
- test/Transforms/LoopSimplify/loop_metadata.ll | 36 +++++++++++++++++++
- 2 files changed, 52 insertions(+), 7 deletions(-)
- create mode 100644 test/Transforms/LoopSimplify/loop_metadata.ll
-
-diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp 
b/lib/Transforms/Utils/BasicBlockUtils.cpp
-index 5fa371377c8..3a90ae061fb 100644
---- a/lib/Transforms/Utils/BasicBlockUtils.cpp
-+++ b/lib/Transforms/Utils/BasicBlockUtils.cpp
-@@ -579,24 +579,33 @@ BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB,
- 
-   // The new block unconditionally branches to the old block.
-   BranchInst *BI = BranchInst::Create(BB, NewBB);
-+  bool IsBBHeader = LI && LI->isLoopHeader(BB);
-+  Loop *BBLoop = LI ? LI->getLoopFor(BB) : nullptr;
-   // Splitting the predecessors of a loop header creates a preheader block.
--  if (LI && LI->isLoopHeader(BB))
-+  if (IsBBHeader)
-     // Using the loop start line number prevents debuggers stepping into the
-     // loop body for this instruction.
--    BI->setDebugLoc(LI->getLoopFor(BB)->getStartLoc());
-+    BI->setDebugLoc(BBLoop->getStartLoc());
-   else
-     BI->setDebugLoc(BB->getFirstNonPHIOrDbg()->getDebugLoc());
- 
-   // Move the edges from Preds to point to NewBB instead of BB.
--  for (unsigned i = 0, e = Preds.size(); i != e; ++i) {
-+  for (BasicBlock *Pred : Preds) {
-+    Instruction *PI = Pred->getTerminator();
-     // This is slightly more strict than necessary; the minimum requirement
-     // is that there be no more than one indirectbr branching to BB. And
-     // all BlockAddress uses would need to be updated.
--    assert(!isa<IndirectBrInst>(Preds[i]->getTerminator()) &&
-+    assert(!isa<IndirectBrInst>(PI) &&
-            "Cannot split an edge from an IndirectBrInst");
--    assert(!isa<CallBrInst>(Preds[i]->getTerminator()) &&
--           "Cannot split an edge from a CallBrInst");
--    Preds[i]->getTerminator()->replaceUsesOfWith(BB, NewBB);
-+    assert(!isa<CallBrInst>(PI) && "Cannot split an edge from a CallBrInst");
-+    if (IsBBHeader && BBLoop->contains(Pred) && BBLoop->isLoopLatch(Pred)) {
-+      // Update loop metadata if it exists.
-+      if (MDNode *LoopMD = PI->getMetadata(LLVMContext::MD_loop)) {
-+        BI->setMetadata(LLVMContext::MD_loop, LoopMD);
-+        PI->setMetadata(LLVMContext::MD_loop, nullptr);
-+      }
-+    }
-+    PI->replaceUsesOfWith(BB, NewBB);
-   }
- 
-   // Insert a new PHI node into NewBB for every PHI node in BB and that new 
PHI
-diff --git a/test/Transforms/LoopSimplify/loop_metadata.ll 
b/test/Transforms/LoopSimplify/loop_metadata.ll
-new file mode 100644
-index 00000000000..c15c92fe3ae
---- /dev/null
-+++ b/test/Transforms/LoopSimplify/loop_metadata.ll
-@@ -0,0 +1,36 @@
-+; RUN: opt -S -loop-simplify < %s | FileCheck %s
-+
-+; CHECK: for.cond.loopexit:
-+; CHECK: br label %for.cond, !llvm.loop !0
-+; CHECK: br i1 %cmp1, label %for.body1, label %for.cond.loopexit
-+
-+define void @foo() {
-+entry:
-+  br label %for.cond
-+
-+for.cond:                                         ; preds = %for.cond1, %entry
-+  %j = phi i32 [ 0, %entry ], [ %add, %for.cond1 ]
-+  %cmp = icmp ult i32 %j, 8
-+  br i1 %cmp, label %for.body, label %for.end
-+
-+for.body:                                         ; preds = %for.cond
-+  %dummy1 = add i32 1, 1
-+  %add = add nuw nsw i32 %j, 1
-+  br label %for.cond1
-+
-+for.cond1:                                      ; preds = %for.body1, 
%for.body
-+  %i.0 = phi i32 [ 1, %for.body ], [ %inc, %for.body1 ]
-+  %cmp1 = icmp ult i32 %i.0, 8
-+  br i1 %cmp1, label %for.body1, label %for.cond, !llvm.loop !0
-+
-+for.body1:                                      ; preds = %for.cond1
-+  %dummy2 = add i32 1, 1
-+  %inc = add nuw nsw i32 %i.0, 1
-+  br label %for.cond1
-+
-+for.end:                                       ; preds = %for.cond
-+  ret void
-+}
-+
-+!0 = distinct !{!0, !1}
-+!1 = !{!"llvm.loop.unroll.full"}
--- 
-2.18.0
-
diff --git 
a/dynamic-layers/clang-layer/recipes-devtools/clang/files/IndVarSimplify-Do-not-use-SCEV-expander-for-IVCount-.patch
 
b/dynamic-layers/clang-layer/recipes-devtools/clang/files/IndVarSimplify-Do-not-use-SCEV-expander-for-IVCount-.patch
deleted file mode 100644
index 48307de..0000000
--- 
a/dynamic-layers/clang-layer/recipes-devtools/clang/files/IndVarSimplify-Do-not-use-SCEV-expander-for-IVCount-.patch
+++ /dev/null
@@ -1,146 +0,0 @@
-From 35e218a886f4c066eabd18685240d55270bd5a6d Mon Sep 17 00:00:00 2001
-From: Aleksander Us <[email protected]>
-Date: Mon, 26 Aug 2019 15:45:47 +0300
-Subject: [PATCH] [IndVarSimplify] Do not use SCEV expander for IVCount in
- LFTR when possible.
-
-SCEV analysis cannot properly cache instruction with poison flags
-(for example, add nsw outside of loop will not be reused by expander).
-This can lead to generating of additional instructions by SCEV expander.
-
-Example IR:
-
-  ...
-  %maxval = add nuw nsw i32 %a1, %a2
-  ...
-for.body:
-  ...
-  %cmp22 = icmp ult i32 %ivadd, %maxval
-  br i1 %cmp22, label %for.body, label %for.end
-  ...
-
-SCEV expander will generate copy of %maxval in preheader but without
-nuw/nsw flags. This can be avoided by explicit check that iv count
-value gives the same SCEV expressions as calculated by LFTR.
-
-Upstream-Status: Submitted [https://reviews.llvm.org/D66890]
-
-https://github.com/intel/llvm-patches/commit/fd6a6c97341a56fd21bc32bc940afea751312e8f
-
-Signed-off-by: Naveen Saini <[email protected]>
----
- lib/Transforms/Scalar/IndVarSimplify.cpp     | 12 +++++++++-
- test/Transforms/IndVarSimplify/add_nsw.ll    | 23 ++++++++++++++++++++
- test/Transforms/IndVarSimplify/lftr-reuse.ll |  9 +++-----
- test/Transforms/IndVarSimplify/udiv.ll       |  1 +
- 4 files changed, 38 insertions(+), 7 deletions(-)
- create mode 100644 test/Transforms/IndVarSimplify/add_nsw.ll
-
-diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp 
b/lib/Transforms/Scalar/IndVarSimplify.cpp
-index f9fc698a4a9..5e04dac8aa6 100644
---- a/lib/Transforms/Scalar/IndVarSimplify.cpp
-+++ b/lib/Transforms/Scalar/IndVarSimplify.cpp
-@@ -2375,6 +2375,17 @@ static Value *genLoopLimit(PHINode *IndVar, BasicBlock 
*ExitingBB,
-     if (UsePostInc)
-       IVLimit = SE->getAddExpr(IVLimit, SE->getOne(IVLimit->getType()));
- 
-+    // If computed limit is equal to old limit then do not use SCEV expander
-+    // because it can lost NUW/NSW flags and create extra instructions.
-+    BranchInst *BI = cast<BranchInst>(ExitingBB->getTerminator());
-+    if (ICmpInst *Cmp = dyn_cast<ICmpInst>(BI->getOperand(0))) {
-+      Value *Limit = Cmp->getOperand(0);
-+      if (!L->isLoopInvariant(Limit))
-+        Limit = Cmp->getOperand(1);
-+      if (SE->getSCEV(Limit) == IVLimit)
-+        return Limit;
-+    }
-+
-     // Expand the code for the iteration count.
-     assert(SE->isLoopInvariant(IVLimit, L) &&
-            "Computed iteration count is not loop invariant!");
-@@ -2383,7 +2394,6 @@ static Value *genLoopLimit(PHINode *IndVar, BasicBlock 
*ExitingBB,
-     // SCEV expression (IVInit) for a pointer type IV value (IndVar).
-     Type *LimitTy = ExitCount->getType()->isPointerTy() ?
-       IndVar->getType() : ExitCount->getType();
--    BranchInst *BI = cast<BranchInst>(ExitingBB->getTerminator());
-     return Rewriter.expandCodeFor(IVLimit, LimitTy, BI);
-   }
- }
-diff --git a/test/Transforms/IndVarSimplify/add_nsw.ll 
b/test/Transforms/IndVarSimplify/add_nsw.ll
-new file mode 100644
-index 00000000000..abd1cbb6c51
---- /dev/null
-+++ b/test/Transforms/IndVarSimplify/add_nsw.ll
-@@ -0,0 +1,23 @@
-+; RUN: opt -indvars -S %s | FileCheck %s
-+
-+target datalayout = "e-p:32:32-i64:64-n8:16:32"
-+
-+; CHECK: for.body.preheader:
-+; CHECK-NOT: add
-+; CHECK: for.body:
-+
-+define void @foo(i32 %a1, i32 %a2) {
-+entry:
-+  %maxval = add nuw nsw i32 %a1, %a2
-+  %cmp = icmp slt i32 %maxval, 1
-+  br i1 %cmp, label %for.end, label %for.body
-+
-+for.body:                                         ; preds = %entry, %for.body
-+  %j.02 = phi i32 [ 0, %entry ], [ %add31, %for.body ]
-+  %add31 = add nuw nsw i32 %j.02, 1
-+  %cmp22 = icmp slt i32 %add31, %maxval
-+  br i1 %cmp22, label %for.body, label %for.end
-+
-+for.end:                                          ; preds = %for.body
-+  ret void
-+}
-diff --git a/test/Transforms/IndVarSimplify/lftr-reuse.ll 
b/test/Transforms/IndVarSimplify/lftr-reuse.ll
-index 14ae9738696..509d662b767 100644
---- a/test/Transforms/IndVarSimplify/lftr-reuse.ll
-+++ b/test/Transforms/IndVarSimplify/lftr-reuse.ll
-@@ -67,11 +67,9 @@ define void @expandOuterRecurrence(i32 %arg) nounwind {
- ; CHECK-NEXT:    [[CMP1:%.*]] = icmp slt i32 0, [[SUB1]]
- ; CHECK-NEXT:    br i1 [[CMP1]], label [[OUTER_PREHEADER:%.*]], label 
[[EXIT:%.*]]
- ; CHECK:       outer.preheader:
--; CHECK-NEXT:    [[TMP0:%.*]] = add i32 [[ARG]], -1
- ; CHECK-NEXT:    br label [[OUTER:%.*]]
- ; CHECK:       outer:
--; CHECK-NEXT:    [[INDVARS_IV:%.*]] = phi i32 [ [[TMP0]], [[OUTER_PREHEADER]] 
], [ [[INDVARS_IV_NEXT:%.*]], [[OUTER_INC:%.*]] ]
--; CHECK-NEXT:    [[I:%.*]] = phi i32 [ [[I_INC:%.*]], [[OUTER_INC]] ], [ 0, 
[[OUTER_PREHEADER]] ]
-+; CHECK-NEXT:    [[I:%.*]] = phi i32 [ [[I_INC:%.*]], [[OUTER_INC:%.*]] ], [ 
0, [[OUTER_PREHEADER]] ]
- ; CHECK-NEXT:    [[SUB2:%.*]] = sub nsw i32 [[ARG]], [[I]]
- ; CHECK-NEXT:    [[SUB3:%.*]] = sub nsw i32 [[SUB2]], 1
- ; CHECK-NEXT:    [[CMP2:%.*]] = icmp slt i32 0, [[SUB3]]
-@@ -81,14 +79,13 @@ define void @expandOuterRecurrence(i32 %arg) nounwind {
- ; CHECK:       inner:
- ; CHECK-NEXT:    [[J:%.*]] = phi i32 [ 0, [[INNER_PH]] ], [ [[J_INC:%.*]], 
[[INNER]] ]
- ; CHECK-NEXT:    [[J_INC]] = add nuw nsw i32 [[J]], 1
--; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp ne i32 [[J_INC]], [[INDVARS_IV]]
-+; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp ne i32 [[J_INC]], [[SUB3]]
- ; CHECK-NEXT:    br i1 [[EXITCOND]], label [[INNER]], label 
[[OUTER_INC_LOOPEXIT:%.*]]
- ; CHECK:       outer.inc.loopexit:
- ; CHECK-NEXT:    br label [[OUTER_INC]]
- ; CHECK:       outer.inc:
- ; CHECK-NEXT:    [[I_INC]] = add nuw nsw i32 [[I]], 1
--; CHECK-NEXT:    [[INDVARS_IV_NEXT]] = add i32 [[INDVARS_IV]], -1
--; CHECK-NEXT:    [[EXITCOND1:%.*]] = icmp ne i32 [[I_INC]], [[TMP0]]
-+; CHECK-NEXT:    [[EXITCOND1:%.*]] = icmp ne i32 [[I_INC]], [[SUB1]]
- ; CHECK-NEXT:    br i1 [[EXITCOND1]], label [[OUTER]], label 
[[EXIT_LOOPEXIT:%.*]]
- ; CHECK:       exit.loopexit:
- ; CHECK-NEXT:    br label [[EXIT]]
-diff --git a/test/Transforms/IndVarSimplify/udiv.ll 
b/test/Transforms/IndVarSimplify/udiv.ll
-index b3f2c2a6a66..3530343ef4a 100644
---- a/test/Transforms/IndVarSimplify/udiv.ll
-+++ b/test/Transforms/IndVarSimplify/udiv.ll
-@@ -133,6 +133,7 @@ declare i32 @printf(i8* nocapture, ...) nounwind
- ; CHECK-LABEL: @foo(
- ; CHECK: for.body.preheader:
- ; CHECK-NOT: udiv
-+; CHECK: for.body:
- 
- define void @foo(double* %p, i64 %n) nounwind {
- entry:
--- 
-2.18.0
-
diff --git 
a/dynamic-layers/clang-layer/recipes-devtools/clang/files/fix-shared-libs.patch 
b/dynamic-layers/clang-layer/recipes-devtools/clang/files/fix-shared-libs.patch
new file mode 100644
index 0000000..d69d2a9
--- /dev/null
+++ 
b/dynamic-layers/clang-layer/recipes-devtools/clang/files/fix-shared-libs.patch
@@ -0,0 +1,30 @@
+From a6d4ccf082858e63e139ca06c02a071c343d2657 Mon Sep 17 00:00:00 2001
+From: Andrea Bocci <[email protected]>
+Date: Sun, 15 Mar 2020 17:35:44 +0100
+Subject: [PATCH] Fix building in-tree with cmake -DLLVM_LINK_LLVM_DYLIB=ON
+
+Building in-tree with LLVM 11.0 master with the LLVM_LINK_LLVM_DYLIB
+cmake flag fails to link with the LLVMSPIRVLib library.
+
+Add an explicit dependency to force the correct build order and linking.
+
+Signed-off-by: Andrea Bocci <[email protected]>
+Upstream-Status: Backport
+Signed-off-by: Anuj Mittal <[email protected]>
+---
+ tools/llvm-spirv/CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tools/llvm-spirv/CMakeLists.txt b/tools/llvm-spirv/CMakeLists.txt
+index 9aa96d9c..501c0daf 100644
+--- a/tools/llvm-spirv/CMakeLists.txt
++++ b/tools/llvm-spirv/CMakeLists.txt
+@@ -14,7 +14,7 @@ add_llvm_tool(llvm-spirv
+   NO_INSTALL_RPATH
+ )
+ 
+-if (LLVM_SPIRV_BUILD_EXTERNAL)
++if (LLVM_SPIRV_BUILD_EXTERNAL OR LLVM_LINK_LLVM_DYLIB)
+   target_link_libraries(llvm-spirv PRIVATE LLVMSPIRVLib)
+ endif()
+ 
diff --git 
a/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend
 
b/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend
index 65115bc..c448ba4 100644
--- 
a/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend
+++ 
b/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend
@@ -1,10 +1,9 @@
 FILESEXTRAPATHS_prepend_intel-x86-common := "${THISDIR}/files:"
 
 SRC_URI_append_intel-x86-common = " \
-                                    
file://BasicBlockUtils-Add-metadata-fixing-in-SplitBlockPre.patch;patchdir=llvm 
\
-                                    
file://IndVarSimplify-Do-not-use-SCEV-expander-for-IVCount-.patch;patchdir=llvm 
\
-                                    
git://github.com/KhronosGroup/SPIRV-LLVM-Translator.git;protocol=https;branch=llvm_release_90;destsuffix=git/llvm/projects/llvm-spirv;name=spirv
 \
+                                    
git://github.com/KhronosGroup/SPIRV-LLVM-Translator.git;protocol=https;branch=llvm_release_100;destsuffix=git/llvm/projects/llvm-spirv;name=spirv
 \
                                     
file://0001-skip-building-tests.patch;patchdir=llvm/projects/llvm-spirv \
+                                    
file://fix-shared-libs.patch;patchdir=llvm/projects/llvm-spirv \
                                     "
 
-SRCREV_spirv = "07f29780e5c4128924508d5d1c00bdf9ff7fd43d"
+SRCREV_spirv = "7743482f2053582be990e93ca46d15239c509c9d"
-- 
2.7.4

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#6461): 
https://lists.yoctoproject.org/g/meta-intel/message/6461
Mute This Topic: https://lists.yoctoproject.org/mt/72767450/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-intel/unsub  
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to