瀏覽代碼

PIX: (DIA front-end): Use module entry point as backup iteration start #2527

Jeff Noyle 6 年之前
父節點
當前提交
73e2229bf3
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      lib/DxilDia/DxilDiaSymbolManager.cpp

+ 12 - 0
lib/DxilDia/DxilDiaSymbolManager.cpp

@@ -1197,6 +1197,7 @@ HRESULT dxil_dia::hlsl_symbols::SymbolManagerInit::CreateFunctionBlocksForFuncti
 }
 
 HRESULT dxil_dia::hlsl_symbols::SymbolManagerInit::CreateFunctionsForCU(llvm::DICompileUnit *CU) {
+  bool FoundFunctions = false;
   for (llvm::DISubprogram *SubProgram : CU->getSubprograms()) {
     DWORD dwNewFunID;
     const DWORD dwParentID = SubProgram->isLocalToUnit() ? HlslCompilandId : HlslProgramId;
@@ -1207,9 +1208,20 @@ HRESULT dxil_dia::hlsl_symbols::SymbolManagerInit::CreateFunctionsForCU(llvm::DI
 
     if (llvm::Function *F = SubProgram->getFunction()) {
       IFR(CreateFunctionBlocksForFunction(F));
+      FoundFunctions = true;
     }
   }
 
+  if (!FoundFunctions) {
+    // This works around an old bug in dxcompiler whose effects are still
+    // sometimes present in PIX users' traces. (The bug was that the subprogram(s)
+    // weren't pointing to their contained function.)
+    llvm::Module *M = &m_Session.ModuleRef();
+    auto &DM = M->GetDxilModule();
+    llvm::Function *EntryPoint = DM.GetEntryFunction();
+    IFR(CreateFunctionBlocksForFunction(EntryPoint));
+  }
+
   return S_OK;
 }