[cfe-commits] r67479 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGen/alias.c test/CodeGen/rdr-6095112-alias-references-inline.c test/CodeGen/rdr-6140807-alias-references-forward.c
Chris Lattner
sabre at nondot.org
Sun Mar 22 14:21:57 PDT 2009
Author: lattner
Date: Sun Mar 22 16:21:57 2009
New Revision: 67479
URL: http://llvm.org/viewvc/llvm-project?rev=67479&view=rev
Log:
fix PR3200 by making alias emission use the new infrastructure. Fold
some tests into the alias.c file.
Removed:
cfe/trunk/test/CodeGen/rdr-6095112-alias-references-inline.c
cfe/trunk/test/CodeGen/rdr-6140807-alias-references-forward.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/alias.c
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=67479&r1=67478&r2=67479&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sun Mar 22 16:21:57 2009
@@ -57,8 +57,8 @@
}
void CodeGenModule::Release() {
- EmitDeferred();
EmitAliases();
+ EmitDeferred();
if (Runtime)
if (llvm::Function *ObjCInitFunction = Runtime->ModuleInitFunction())
AddGlobalCtor(ObjCInitFunction);
@@ -337,20 +337,26 @@
if (!AA)
continue;
- const std::string& aliaseeName = AA->getAliasee();
- llvm::GlobalValue *aliasee = getModule().getNamedValue(aliaseeName);
- if (!aliasee) {
- // FIXME: This isn't unsupported, this is just an error, which
- // sema should catch, but...
- ErrorUnsupported(D, "alias referencing a missing function");
- continue;
- }
+ const llvm::Type *DeclTy = getTypes().ConvertTypeForMem(D->getType());
+
+ // Unique the name through the identifier table.
+ const char *AliaseeName = AA->getAliasee().c_str();
+ AliaseeName = getContext().Idents.get(AliaseeName).getName();
+
+
+
+ llvm::Constant *Aliasee;
+ if (isa<llvm::FunctionType>(DeclTy))
+ Aliasee = GetOrCreateLLVMFunction(AliaseeName, DeclTy, 0);
+ else
+ Aliasee = GetOrCreateLLVMGlobal(AliaseeName,
+ llvm::PointerType::getUnqual(DeclTy), 0);
const char *MangledName = getMangledName(D);
llvm::GlobalValue *GA =
- new llvm::GlobalAlias(aliasee->getType(),
+ new llvm::GlobalAlias(Aliasee->getType(),
llvm::Function::ExternalLinkage,
- MangledName, aliasee, &getModule());
+ MangledName, Aliasee, &getModule());
llvm::GlobalValue *&Entry = GlobalDeclMap[MangledName];
if (Entry) {
Modified: cfe/trunk/test/CodeGen/alias.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/alias.c?rev=67479&r1=67478&r2=67479&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/alias.c (original)
+++ cfe/trunk/test/CodeGen/alias.c Sun Mar 22 16:21:57 2009
@@ -2,7 +2,7 @@
// RUN: grep '@g0 = common global i32 0' %t &&
// RUN: grep '@f1 = alias void ()\* @f0' %t &&
// RUN: grep '@g1 = alias i32\* @g0' %t &&
-// RUN: grep 'define void @f0() nounwind {' %t
+// RUN: grep 'define void @f0() nounwind {' %t &&
void f0(void) { }
extern void f1(void);
@@ -11,3 +11,15 @@
int g0;
extern int g1;
extern int g1 __attribute((alias("g0")));
+
+// Make sure that aliases cause referenced values to be emitted.
+// PR3200
+// RUN: grep 'define internal i32 @foo1()' %t &&
+static inline int foo1() { return 0; }
+int foo() __attribute__((alias("foo1")));
+
+
+// RUN: grep '@bar1 = internal global i32 42' %t
+static inline int bar1 = 42;
+int bar() __attribute__((alias("bar1")));
+
Removed: cfe/trunk/test/CodeGen/rdr-6095112-alias-references-inline.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/rdr-6095112-alias-references-inline.c?rev=67478&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/rdr-6095112-alias-references-inline.c (original)
+++ cfe/trunk/test/CodeGen/rdr-6095112-alias-references-inline.c (removed)
@@ -1,6 +0,0 @@
-// RUN: clang -triple i386-unknown-unknown --emit-llvm -o %t %s &&
-// RUN: grep -e "alias" %t
-// XFAIL
-
-static inline int foo () { return 0; }
-int bar () __attribute__ ((alias ("foo")));
Removed: cfe/trunk/test/CodeGen/rdr-6140807-alias-references-forward.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/rdr-6140807-alias-references-forward.c?rev=67478&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/rdr-6140807-alias-references-forward.c (original)
+++ cfe/trunk/test/CodeGen/rdr-6140807-alias-references-forward.c (removed)
@@ -1,14 +0,0 @@
-// RUN: clang -triple i386-unknown-unknown -emit-llvm -o %t %s &&
-// RUN: grep -e "@f = alias" %t | count 1 &&
-// RUN: grep -e "bitcast (i32 (i32)\\* @f to i32 (float)\\*)" %t | count 1
-// <rdar://problem/6140807>
-
-int f(float) __attribute__((weak, alias("x")));
-
-// Make sure we replace uses properly...
-int y() {
- return f(1.);
-}
-
-int x(int a) {
-}
More information about the cfe-commits
mailing list