Currently clang will produce a @foo when given
int foo;
extern int foo __asm__("bar");
The attached patch makes it produce a @bar, which is what gcc produces.
I am confused by the output changes in the microsoft abi tests.
Hopefully someone more familiar with it can comment on why using a
more recent decl causes problems and has an idea of what should be
changed to accommodate it.
Cheers,
Rafael
diff --git a/include/clang/AST/GlobalDecl.h b/include/clang/AST/GlobalDecl.h
index 54c9d88..cf766e4 100644
--- a/include/clang/AST/GlobalDecl.h
+++ b/include/clang/AST/GlobalDecl.h
@@ -57,6 +57,14 @@ public:
return CanonGD;
}
+ GlobalDecl getMostRecentDecl() const {
+ GlobalDecl Ret;
+ Ret.Value.setPointer(Value.getPointer()->getMostRecentDecl());
+ Ret.Value.setInt(Value.getInt());
+
+ return Ret;
+ }
+
const Decl *getDecl() const { return Value.getPointer(); }
CXXCtorType getCtorType() const {
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 7845fba..dd3238e 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -547,7 +547,8 @@ void CodeGenModule::setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const {
GV->setThreadLocalMode(TLM);
}
-StringRef CodeGenModule::getMangledName(GlobalDecl GD) {
+StringRef CodeGenModule::getMangledName(GlobalDecl CurGD) {
+ GlobalDecl GD = CurGD.getMostRecentDecl();
StringRef &FoundStr = MangledDeclNames[GD.getCanonicalDecl()];
if (!FoundStr.empty())
return FoundStr;
diff --git a/test/CodeGen/mangle.c b/test/CodeGen/mangle.c
index 46ef512..d5c1622 100644
--- a/test/CodeGen/mangle.c
+++ b/test/CodeGen/mangle.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o %t.ll %s
+// RUN: FileCheck %s < %t.ll
+// RUN: FileCheck --check-prefix=VAR %s < %t.ll
// CHECK: @foo
@@ -72,3 +74,7 @@ int foo10(volatile int* add, int from, int to) {
// CHECK: call i32 @llvm.atomic.cmp.swap.i32.p0i32
return llvm_cas(add, from, to);
}
+
+int pr22217_foo __attribute__((nocommon));
+extern int pr22217_foo __asm__("pr22217_bar");
+// VAR: @pr22217_bar = global i32 0
diff --git a/test/CodeGenCXX/microsoft-abi-structors.cpp b/test/CodeGenCXX/microsoft-abi-structors.cpp
index 93d1c24..19ae8e4 100644
--- a/test/CodeGenCXX/microsoft-abi-structors.cpp
+++ b/test/CodeGenCXX/microsoft-abi-structors.cpp
@@ -176,7 +176,7 @@ void foo() {
// Do an adjustment from B* to C*.
// DTORS2: getelementptr i8* %{{.*}}, i32 -4
// DTORS2: bitcast i8* %{{.*}} to %"struct.dtor_in_second_nvbase::C"*
-// DTORS2: %[[CALL:.*]] = call x86_thiscallcc i8* @"\01??_GC@dtor_in_second_nvbase@@UAEPAXI@Z"
+// DTORS2: %[[CALL:.*]] = call x86_thiscallcc i8* @"\01??_GC@dtor_in_second_nvbase@@UAE@XZ"
// DTORS2: ret i8* %[[CALL]]
}
diff --git a/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp b/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
index 7a00a73..3603a16 100644
--- a/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
+++ b/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
@@ -96,7 +96,7 @@ B::~B() {
// CHECK2: call x86_thiscallcc void @"\01??1VBase@@UAE@XZ"(%struct.VBase* %[[VBASE]])
// CHECK2: ret
- // CHECK2-LABEL: define linkonce_odr x86_thiscallcc i8* @"\01??_GB@@UAEPAXI@Z"
+ // CHECK2-LABEL: define linkonce_odr x86_thiscallcc i8* @"\01??_GB@@UAE@XZ"
// CHECK2: %[[THIS_PARAM_i8:.*]] = bitcast %struct.B* {{.*}} to i8*
// CHECK2: %[[THIS_i8:.*]] = getelementptr inbounds i8* %[[THIS_PARAM_i8:.*]], i32 -8
// CHECK2: %[[THIS:.*]] = bitcast i8* %[[THIS_i8]] to %struct.B*
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits