瀏覽代碼

Revert "Generate global variable for local constant."

This reverts commit b3cfa21fa17417af49c25781e0b840759b133c44.
Xiang Li 7 年之前
父節點
當前提交
6753f88ca7
共有 2 個文件被更改,包括 0 次插入23 次删除
  1. 0 12
      tools/clang/lib/CodeGen/CGDecl.cpp
  2. 0 11
      tools/clang/test/CodeGenHLSL/quick-test/local_constant.hlsl

+ 0 - 12
tools/clang/lib/CodeGen/CGDecl.cpp

@@ -138,18 +138,6 @@ void CodeGenFunction::EmitVarDecl(const VarDecl &D) {
 
 
     return EmitStaticVarDecl(D, Linkage);
     return EmitStaticVarDecl(D, Linkage);
   }
   }
-  // HLSL Change Begin - treat local constant as static.
-  // Global variable will be generated instead of alloca.
-  if (D.getType().isConstQualified() && D.isLocalVarDecl()) {
-    llvm::Constant *Init = CGM.EmitConstantInit(D, this);
-    // Only create global when has constant init.
-    if (Init) {
-      llvm::GlobalValue::LinkageTypes Linkage =
-          CGM.getLLVMLinkageVarDefinition(&D, /*isConstant=*/false);
-      return EmitStaticVarDecl(D, Linkage);
-    }
-  }
-  // HLSL Change End.
 
 
   if (D.hasExternalStorage())
   if (D.hasExternalStorage())
     // Don't emit it now, allow it to be emitted lazily on its first use.
     // Don't emit it now, allow it to be emitted lazily on its first use.

+ 0 - 11
tools/clang/test/CodeGenHLSL/quick-test/local_constant.hlsl

@@ -1,11 +0,0 @@
-// RUN: %dxc -T ps_6_0 -E main  -fcgl %s | FileCheck %s
-
-// Make sure global variable is created for local constant.
-// CHECK: internal constant [3 x float]
-// CHECK-NOT: alloca [3 x float]
-
-float main(uint i : A) : SV_TARGET
-{
-  const float cb[] = {1.3, 1.2, 3.3};
-  return cb[i];
-}