r241941 - [MS ABI] Don't generates code for unreferenced inline definitions of library builtins
David Majnemer
david.majnemer at gmail.com
Fri Jul 10 13:55:38 PDT 2015
Author: majnemer
Date: Fri Jul 10 15:55:38 2015
New Revision: 241941
URL: http://llvm.org/viewvc/llvm-project?rev=241941&view=rev
Log:
[MS ABI] Don't generates code for unreferenced inline definitions of library builtins
We should only consider declarations which were written, implicit
declarations shouldn't be considered.
This fixes PR24084.
Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/CodeGen/inline.c
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=241941&r1=241940&r2=241941&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Fri Jul 10 15:55:38 2015
@@ -2712,7 +2712,7 @@ bool FunctionDecl::isMSExternInline() co
for (const FunctionDecl *FD = getMostRecentDecl(); FD;
FD = FD->getPreviousDecl())
- if (FD->getStorageClass() == SC_Extern)
+ if (!FD->isImplicit() && FD->getStorageClass() == SC_Extern)
return true;
return false;
@@ -2724,7 +2724,7 @@ static bool redeclForcesDefMSVC(const Fu
for (const FunctionDecl *FD = Redecl->getPreviousDecl(); FD;
FD = FD->getPreviousDecl())
- if (FD->getStorageClass() == SC_Extern)
+ if (!FD->isImplicit() && FD->getStorageClass() == SC_Extern)
return false;
return true;
Modified: cfe/trunk/test/CodeGen/inline.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/inline.c?rev=241941&r1=241940&r2=241941&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/inline.c (original)
+++ cfe/trunk/test/CodeGen/inline.c Fri Jul 10 15:55:38 2015
@@ -54,6 +54,7 @@
// RUN: echo "MS C Mode tests:"
// RUN: %clang_cc1 %s -triple i386-unknown-unknown -O1 -disable-llvm-optzns -emit-llvm -o - -std=c99 -fms-compatibility | FileCheck %s --check-prefix=CHECK4
+// CHECK4-NOT: define weak_odr void @_Exit(
// CHECK4-LABEL: define weak_odr i32 @ei()
// CHECK4-LABEL: define i32 @bar()
// CHECK4-NOT: unreferenced1
@@ -62,6 +63,9 @@
// CHECK4-LABEL: define linkonce_odr i32 @foo()
// CHECK4-LABEL: define available_externally void @gnu_ei_inline()
+__attribute__((noreturn)) void __cdecl _exit(int _Code);
+__inline void __cdecl _Exit(int status) { _exit(status); }
+
extern __inline int ei() { return 123; }
__inline int foo() {
More information about the cfe-commits
mailing list