[llvm-commits] [gcc-plugin] r81853 - in /gcc-plugin/trunk: llvm-backend.cpp llvm-convert.cpp llvm-internal.h
Duncan Sands
baldrick at free.fr
Tue Sep 15 01:36:42 PDT 2009
Author: baldrick
Date: Tue Sep 15 03:36:41 2009
New Revision: 81853
URL: http://llvm.org/viewvc/llvm-project?rev=81853&view=rev
Log:
GCC adds a star '*' at the front of user specified
assembler names. LLVM has a similar scheme, only
it uses '\1'. Make sure '*' is turned into '\1' in
assembler names. With this change sqlite3 links.
Modified:
gcc-plugin/trunk/llvm-backend.cpp
gcc-plugin/trunk/llvm-convert.cpp
gcc-plugin/trunk/llvm-internal.h
Modified: gcc-plugin/trunk/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-backend.cpp?rev=81853&r1=81852&r2=81853&view=diff
==============================================================================
--- gcc-plugin/trunk/llvm-backend.cpp (original)
+++ gcc-plugin/trunk/llvm-backend.cpp Tue Sep 15 03:36:41 2009
@@ -1375,14 +1375,11 @@
//TODO timevar_push(TV_LLVM_GLOBALS);
- const char *Name = "";
- if (DECL_NAME(decl))
- if (tree AssemblerName = DECL_ASSEMBLER_NAME(decl))
- Name = IDENTIFIER_POINTER(AssemblerName);
-
+ std::string Name = getLLVMAssemblerName(decl).str();
+
// Now handle ordinary static variables and functions (in memory).
// Also handle vars declared register invalidly.
- if (Name[0] == 1) {
+ if (!Name.empty() && Name[0] == 1) {
#ifdef REGISTER_PREFIX
if (strlen (REGISTER_PREFIX) != 0) {
int reg_number = decode_reg_name(Name);
@@ -1407,7 +1404,7 @@
// object. Note that this is quite possibly a forward reference to the
// object, so its type may change later.
if (TREE_CODE(decl) == FUNCTION_DECL) {
- assert(Name[0] && "Function with empty name!");
+ assert(!Name.empty() && "Function with empty name!");
// If this function has already been created, reuse the decl. This happens
// when we have something like __builtin_memset and memset in the same file.
Function *FnEntry = TheModule->getFunction(Name);
@@ -1464,7 +1461,7 @@
if (Ty == Type::getVoidTy(Context))
Ty = StructType::get(Context);
- if (Name[0] == 0) { // Global has no name.
+ if (Name.empty()) { // Global has no name.
GV = new GlobalVariable(*TheModule, Ty, false,
GlobalValue::ExternalLinkage, 0, "");
@@ -1553,15 +1550,6 @@
//TODO timevar_pop(TV_LLVM_GLOBALS);
}
-/// llvm_get_decl_name - Used by varasm.c, returns the specified declaration's
-/// name.
-const char *llvm_get_decl_name(void *LLVM) {
- if (LLVM)
- if (const ValueName *VN = ((Value*)LLVM)->getValueName())
- return VN->getKeyData();
- return "";
-}
-
/// llvm_mark_decl_weak - Used by varasm.c, called when a decl is found to be
/// weak, but it already had an llvm object created for it. This marks the LLVM
/// object weak as well.
@@ -1641,10 +1629,24 @@
/// extractRegisterName - Get a register name given its decl. In 4.2 unlike 4.0
/// these names have been run through set_user_assembler_name which means they
-/// may have a leading \1 at this point; compensate.
+/// may have a leading star at this point; compensate.
const char* extractRegisterName(tree decl) {
const char* Name = IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(decl));
- return (*Name == 1) ? Name + 1 : Name;
+ return (*Name == '*') ? Name + 1 : Name;
+}
+
+/// getLLVMAssemblerName - Get the assembler name (DECL_ASSEMBLER_NAME) for the
+/// declaration, with any leading star replaced by '\1'.
+Twine getLLVMAssemblerName(union tree_node *decl) {
+ tree Ident = DECL_ASSEMBLER_NAME(decl);
+ if (!Ident)
+ return "";
+
+ const char *Name = IDENTIFIER_POINTER(Ident);
+ if (*Name != '*')
+ return Name;
+
+ return "\1" + Twine(Name + 1);
}
/// FinalizePlugin - Shutdown the plugin.
Modified: gcc-plugin/trunk/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-convert.cpp?rev=81853&r1=81852&r2=81853&view=diff
==============================================================================
--- gcc-plugin/trunk/llvm-convert.cpp (original)
+++ gcc-plugin/trunk/llvm-convert.cpp Tue Sep 15 03:36:41 2009
@@ -396,10 +396,10 @@
}
void TreeToLLVM::StartFunctionBody() {
- const char *Name = "";
- // Get the name of the function.
- if (tree ID = DECL_ASSEMBLER_NAME(FnDecl))
- Name = IDENTIFIER_POINTER(ID);
+ std::string Name = getLLVMAssemblerName(FnDecl).str();
+ // TODO: Add support for dropping the leading '\1' in order to support
+ // unsigned bswap(unsigned) __asm__("llvm.bswap");
+ // This would also require adjustments in make_decl_llvm.
// Determine the FunctionType and calling convention for this function.
tree static_chain = cfun->static_chain_decl;
Modified: gcc-plugin/trunk/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-internal.h?rev=81853&r1=81852&r2=81853&view=diff
==============================================================================
--- gcc-plugin/trunk/llvm-internal.h (original)
+++ gcc-plugin/trunk/llvm-internal.h Tue Sep 15 03:36:41 2009
@@ -127,6 +127,7 @@
void clearTargetBuiltinCache();
const char* extractRegisterName(union tree_node*);
void handleVisibility(union tree_node* decl, GlobalValue *GV);
+Twine getLLVMAssemblerName(union tree_node *);
struct StructTypeConversionInfo;
More information about the llvm-commits
mailing list