فهرست منبع

TranslatePreciseAttribute for libraries.

Tex Riddell 7 سال پیش
والد
کامیت
824f7b0f8d
2فایلهای تغییر یافته به همراه19 افزوده شده و 12 حذف شده
  1. 15 8
      lib/HLSL/DxilGenerationPass.cpp
  2. 4 4
      tools/clang/test/CodeGenHLSL/quick-test/incomp_array.hlsl

+ 15 - 8
lib/HLSL/DxilGenerationPass.cpp

@@ -778,15 +778,22 @@ void DxilGenerationPass::TranslatePreciseAttribute() {
   // argument and call site without precise argument, need to clone the function
   // to propagate the precise for the precise call site.
   // This should be done at CGMSHLSLRuntime::FinishCodeGen.
-  Function *EntryFn = m_pHLModule->GetEntryFunction();
-  if (!m_pHLModule->GetShaderModel()->IsLib()) {
+  if (m_pHLModule->GetShaderModel()->IsLib()) {
+    // TODO: If all functions have been inlined, and unreferenced functions removed,
+    //        it should make sense to run on all funciton bodies,
+    //        even when not processing a library.
+    for (Function &F : M.functions()) {
+      if (!F.isDeclaration())
+        TranslatePreciseAttributeOnFunction(F, M);
+    }
+  } else {
+    Function *EntryFn = m_pHLModule->GetEntryFunction();
     TranslatePreciseAttributeOnFunction(*EntryFn, M);
-  }
-
-  if (m_pHLModule->GetShaderModel()->IsHS()) {
-    DxilFunctionProps &EntryQual = m_pHLModule->GetDxilFunctionProps(EntryFn);
-    Function *patchConstantFunc = EntryQual.ShaderProps.HS.patchConstantFunc;
-    TranslatePreciseAttributeOnFunction(*patchConstantFunc, M);
+    if (m_pHLModule->GetShaderModel()->IsHS()) {
+      DxilFunctionProps &EntryQual = m_pHLModule->GetDxilFunctionProps(EntryFn);
+      Function *patchConstantFunc = EntryQual.ShaderProps.HS.patchConstantFunc;
+      TranslatePreciseAttributeOnFunction(*patchConstantFunc, M);
+    }
   }
 }
 

+ 4 - 4
tools/clang/test/CodeGenHLSL/quick-test/incomp_array.hlsl

@@ -1,4 +1,4 @@
-// RUN: %dxc -T lib_6_1 %s | FileCheck %s
+// RUN: %dxc -T lib_6_3 %s | FileCheck %s
 
 // Verify no hang on incomplete array
 
@@ -32,7 +32,7 @@ float4 fn1(in Special in1: SEMANTIC_IN) : SEMANTIC_OUT {
   // CHECK: getelementptr
   // CHECK: load i32, i32*
   // CHECK: sitofp i32
-  // CHECK: fadd float
+  // CHECK: fadd fast float
   return in1.member + (float)s_testa[i];
 }
 
@@ -55,7 +55,7 @@ float4 fn3(in Special in1: SEMANTIC_IN) : SEMANTIC_OUT {
   // CHECK: getelementptr
   // CHECK: load i32, i32*
   // CHECK: sitofp i32
-  // CHECK: fadd float
+  // CHECK: fadd fast float
   return in1.member + (float)in1.a[i];
 }
 
@@ -72,6 +72,6 @@ float4 fn4(in Special in1: SEMANTIC_IN) : SEMANTIC_OUT {
   // CHECK: extractvalue
   // CHECK: , 0
   // CHECK: sitofp i32
-  // CHECK: fadd float
+  // CHECK: fadd fast float
   return in1.member + c_special.a[i];
 }