[dragonegg] r194730 - Handle weakref in cases where target is not an IDENTIFIER_NODE.
Rafael Espindola
rafael.espindola at gmail.com
Thu Nov 14 13:28:55 PST 2013
Author: rafael
Date: Thu Nov 14 15:28:55 2013
New Revision: 194730
URL: http://llvm.org/viewvc/llvm-project?rev=194730&view=rev
Log:
Handle weakref in cases where target is not an IDENTIFIER_NODE.
These two test cases now also match the output produced by clang. Fixes
building llvm with gcc 4.6 + dragonegg.
Modified:
dragonegg/trunk/src/Backend.cpp
dragonegg/trunk/test/validator/c/InternFunctionWeakref.c
dragonegg/trunk/test/validator/c/InternVariableWeakref.c
Modified: dragonegg/trunk/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=194730&r1=194729&r2=194730&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Thu Nov 14 15:28:55 2013
@@ -952,11 +952,11 @@ static void emit_alias(tree decl, tree t
}
GlobalValue *Aliasee = 0;
- bool IsWeakRef = false;
+ bool IsWeakRef = lookup_attribute("weakref", DECL_ATTRIBUTES(decl));
if (isa<IDENTIFIER_NODE>(target)) {
StringRef AliaseeName(IDENTIFIER_POINTER(target),
IDENTIFIER_LENGTH(target));
- if (!lookup_attribute("weakref", DECL_ATTRIBUTES(decl))) {
+ if (!IsWeakRef) {
Aliasee = TheModule->getNamedValue(AliaseeName);
if (!Aliasee)
Aliasee = TheModule->getNamedValue(("\1" + AliaseeName).str());
@@ -966,7 +966,6 @@ static void emit_alias(tree decl, tree t
return;
}
} else {
- IsWeakRef = true;
// weakref to external symbol.
if (GlobalVariable *GV = llvm::dyn_cast<GlobalVariable>(V))
Aliasee = new GlobalVariable(
Modified: dragonegg/trunk/test/validator/c/InternFunctionWeakref.c
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/validator/c/InternFunctionWeakref.c?rev=194730&r1=194729&r2=194730&view=diff
==============================================================================
--- dragonegg/trunk/test/validator/c/InternFunctionWeakref.c (original)
+++ dragonegg/trunk/test/validator/c/InternFunctionWeakref.c Thu Nov 14 15:28:55 2013
@@ -4,4 +4,4 @@ int foo(int x) { return x; }
static void function_weakref(void) __attribute__ ((weakref("foo")));
void *use_function = (void *)function_weakref;
-// CHECK: @function_weakref = alias weak i32 (i32)* @foo
+// CHECK: @use_function = unnamed_addr global {{.*}} @foo
Modified: dragonegg/trunk/test/validator/c/InternVariableWeakref.c
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/validator/c/InternVariableWeakref.c?rev=194730&r1=194729&r2=194730&view=diff
==============================================================================
--- dragonegg/trunk/test/validator/c/InternVariableWeakref.c (original)
+++ dragonegg/trunk/test/validator/c/InternVariableWeakref.c Thu Nov 14 15:28:55 2013
@@ -4,4 +4,4 @@ int bar;
static int variable_weakref __attribute__ ((weakref("bar")));
int *use_variable = &variable_weakref;
-// CHECK: @variable_weakref = alias weak i32* @bar
+// CHECK: @use_variable = unnamed_addr global i32* @bar
More information about the llvm-commits
mailing list