[cfe-commits] r64502 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp test/CodeGen/init.c
Daniel Dunbar
daniel at zuster.org
Fri Feb 13 14:58:39 PST 2009
Author: ddunbar
Date: Fri Feb 13 16:58:39 2009
New Revision: 64502
URL: http://llvm.org/viewvc/llvm-project?rev=64502&view=rev
Log:
Set constant bit on static block vars as well. Patch by Anders Johnson!q
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/test/CodeGen/init.c
Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=64502&r1=64501&r2=64502&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Feb 13 16:58:39 2009
@@ -109,7 +109,7 @@
assert(0 && "Unknown context for block var decl");
llvm::GlobalValue *GV =
- new llvm::GlobalVariable(Init->getType(), false,
+ new llvm::GlobalVariable(Init->getType(), Ty.isConstant(getContext()),
Linkage,
Init, ContextName + Separator +D.getNameAsString(),
&CGM.getModule(), 0, Ty.getAddressSpace());
Modified: cfe/trunk/test/CodeGen/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/init.c?rev=64502&r1=64501&r2=64502&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/init.c (original)
+++ cfe/trunk/test/CodeGen/init.c Fri Feb 13 16:58:39 2009
@@ -1,4 +1,5 @@
-// RUN: clang -emit-llvm %s -o -
+// RUN: clang -triple i386-unknown-unknown -emit-llvm %s -o %t &&
+
void f1() {
// Scalars in braces.
int a = { 1 };
@@ -20,3 +21,11 @@
struct S a[1] = { { foo } };
}
+// Constants
+// RUN: grep '@g3 = constant i32 10' %t &&
+// RUN: grep '@f4.g4 = internal constant i32 12' %t
+const int g3 = 10;
+int f4() {
+ static const int g4 = 12;
+ return g4;
+}
More information about the cfe-commits
mailing list