Browse Source

[linux-port] 'auto' not allowed in lambda parameter.

It is allowed starting C++14, but C++11 is assumed currently.
Ehsan Nasiri 7 years ago
parent
commit
b86e5efe1b
3 changed files with 29 additions and 18 deletions
  1. 1 0
      include/dxc/Support/WinAdapter.h
  2. 4 3
      lib/HLSL/DxilModule.cpp
  3. 24 15
      lib/HLSL/DxilValidation.cpp

+ 1 - 0
include/dxc/Support/WinAdapter.h

@@ -292,6 +292,7 @@
 #define _Ret_opt_
 
 #define _Use_decl_annotations_
+#define __analysis_assume(expr)
 #define _Analysis_assume_(expr)
 #define _Analysis_assume_nullterminated_(x)
 #define _Success_(expr)

+ 4 - 3
lib/HLSL/DxilModule.cpp

@@ -15,6 +15,7 @@
 #include "dxc/HLSL/DxilContainer.h"
 #include "dxc/HLSL/DxilRootSignature.h"
 #include "dxc/HLSL/DxilFunctionProps.h"
+#include "dxc/Support/WinAdapter.h"
 #include "DxilEntryProps.h"
 
 #include "llvm/IR/Constants.h"
@@ -889,8 +890,8 @@ namespace {
 template <typename TResource>
 static void RemoveResourceSymbols(std::vector<std::unique_ptr<TResource>> &vec) {
   unsigned resID = 0;
-  for (std::vector<std::unique_ptr<TResource>>::iterator p = vec.begin(); p != vec.end();) {
-    std::vector<std::unique_ptr<TResource>>::iterator c = p++;
+  for (auto p = vec.begin(); p != vec.end();) {
+    auto c = p++;
     GlobalVariable *GV = cast<GlobalVariable>((*c)->GetGlobalSymbol());
     GV->removeDeadConstantUsers();
     if (GV->user_empty()) {
@@ -1197,7 +1198,7 @@ void DxilModule::EmitDxilMetadata() {
     std::transform( m_DxilEntryPropsMap.begin(),
                     m_DxilEntryPropsMap.end(),
                     std::back_inserter(funcOrder),
-                    [](auto &p) -> const Function* { return p.first; } );
+                    [](const std::pair<const llvm::Function * const, std::unique_ptr<DxilEntryProps>> &p) -> const Function* { return p.first; } );
     std::sort(funcOrder.begin(), funcOrder.end(), [](const Function *F1, const Function *F2) {
       return F1->getName() < F2->getName();
     });

+ 24 - 15
lib/HLSL/DxilValidation.cpp

@@ -472,16 +472,14 @@ struct ValidationContext {
     if (isLibProfile) {
       std::unordered_set<Value *> ResSet;
       // Start from all global variable in resTab.
-      auto collectRes = [&](auto &ResTab) {
-        for (auto &Res : ResTab) {
-          PropagateResMap(Res->GetGlobalSymbol(), Res.get());
-        }
-      };
-
-      collectRes(DxilMod.GetCBuffers());
-      collectRes(DxilMod.GetUAVs());
-      collectRes(DxilMod.GetSRVs());
-      collectRes(DxilMod.GetSamplers());
+      for (auto &Res : DxilMod.GetCBuffers())
+        PropagateResMap(Res->GetGlobalSymbol(), Res.get());
+      for (auto &Res : DxilMod.GetUAVs())
+        PropagateResMap(Res->GetGlobalSymbol(), Res.get());
+      for (auto &Res : DxilMod.GetSRVs())
+        PropagateResMap(Res->GetGlobalSymbol(), Res.get());
+      for (auto &Res : DxilMod.GetSamplers())
+        PropagateResMap(Res->GetGlobalSymbol(), Res.get());
     } else {
       // Scan all createHandle.
       for (auto &it : hlslOP->GetOpFuncList(DXIL::OpCode::CreateHandle)) {
@@ -3328,18 +3326,29 @@ static void ValidateGlobalVariable(GlobalVariable &GV,
       dxilutil::IsStaticGlobal(&GV) || dxilutil::IsSharedMemoryGlobal(&GV);
 
   if (ValCtx.isLibProfile) {
-    auto isResourceGlobal = [&](auto &ResTab) -> bool {
-      for (auto &Res : ResTab) {
+    auto isCBufferGlobal = [&](const std::vector<std::unique_ptr<DxilCBuffer>> &ResTab) -> bool {
+      for (auto &Res : ResTab)
+        if (Res->GetGlobalSymbol() == &GV)
+          return true;
+      return false;
+    };
+    auto isResourceGlobal = [&](const std::vector<std::unique_ptr<DxilResource>> &ResTab) -> bool {
+      for (auto &Res : ResTab)
+        if (Res->GetGlobalSymbol() == &GV)
+          return true;
+      return false;
+    };
+    auto isSamplerGlobal = [&](const std::vector<std::unique_ptr<DxilSampler>> &ResTab) -> bool {
+      for (auto &Res : ResTab)
         if (Res->GetGlobalSymbol() == &GV)
           return true;
-      }
       return false;
     };
 
-    bool isRes = isResourceGlobal(ValCtx.DxilMod.GetCBuffers());
+    bool isRes = isCBufferGlobal(ValCtx.DxilMod.GetCBuffers());
     isRes |= isResourceGlobal(ValCtx.DxilMod.GetUAVs());
     isRes |= isResourceGlobal(ValCtx.DxilMod.GetSRVs());
-    isRes |= isResourceGlobal(ValCtx.DxilMod.GetSamplers());
+    isRes |= isSamplerGlobal(ValCtx.DxilMod.GetSamplers());
     isInternalGV |= isRes;
   }