r292522 - Don't inline dllimport functions referencing non-imported methods

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 20 12:56:09 PST 2017


The first Chrome DLL build with this change is crashing during compilation:
https://build.chromium.org/p/chromium.fyi/builders/ClangToTWin64%28dll%29/builds/8380/

The previous build fails with a link error, so the revision range for the
new crash is 292501 - 292526.

Only the DLL builders are affected, so I think it's very likely that this
is the culprit. I speculatively reverted it in r292643.

On Thu, Jan 19, 2017 at 1:33 PM, Hans Wennborg via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: hans
> Date: Thu Jan 19 15:33:13 2017
> New Revision: 292522
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292522&view=rev
> Log:
> Don't inline dllimport functions referencing non-imported methods
>
> This is another follow-up to r246338. I had assumed methods were already
> handled by the AST visitor, but turns out they weren't.
>
> Modified:
>     cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>     cfe/trunk/test/CodeGenCXX/dllimport.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CodeGenModule.cpp?rev=292522&r1=292521&r2=292522&view=diff
> ============================================================
> ==================
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Jan 19 15:33:13 2017
> @@ -1751,6 +1751,11 @@ namespace {
>        SafeToInline = E->getConstructor()->hasAttr<DLLImportAttr>();
>        return SafeToInline;
>      }
> +    bool VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
> +      CXXMethodDecl *M = E->getMethodDecl();
> +      SafeToInline = M->hasAttr<DLLImportAttr>();
> +      return SafeToInline;
> +    }
>      bool VisitCXXDeleteExpr(CXXDeleteExpr *E) {
>        SafeToInline = E->getOperatorDelete()->hasAttr<DLLImportAttr>();
>        return SafeToInline;
>
> Modified: cfe/trunk/test/CodeGenCXX/dllimport.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CodeGenCXX/dllimport.cpp?rev=292522&r1=292521&r2=292522&view=diff
> ============================================================
> ==================
> --- cfe/trunk/test/CodeGenCXX/dllimport.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/dllimport.cpp Thu Jan 19 15:33:13 2017
> @@ -26,6 +26,7 @@ struct ExplicitSpec_NotImported {};
>  #define USEVARTYPE(type, var) type UNIQ(use)() { return var; }
>  #define USEVAR(var) USEVARTYPE(int, var)
>  #define USE(func) void UNIQ(use)() { func(); }
> +#define USE1(func) void UNIQ(use)() { func(nullptr); }
>  #define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return
> &class::func; }
>  #define USESTATICMEMFUNC(class, func) void (*UNIQ(use)())() { return
> &class::func; }
>  #define USECLASS(class) void UNIQ(USE)() { class x; }
> @@ -316,10 +317,13 @@ namespace ns { __declspec(dllimport) voi
>  USE(ns::externalFunc)
>
>  // A dllimport function referencing non-imported vars or functions must
> not be available_externally.
> +
>  __declspec(dllimport) int ImportedVar;
>  int NonImportedVar;
>  __declspec(dllimport) int ImportedFunc();
>  int NonImportedFunc();
> +struct ClassWithNonImportedMethod { int f(); };
> +
>  __declspec(dllimport) inline int ReferencingImportedVar() { return
> ImportedVar; }
>  // MO1-DAG: define available_externally dllimport i32
> @"\01?ReferencingImportedVar@@YAHXZ"
>  __declspec(dllimport) inline int ReferencingNonImportedVar() { return
> NonImportedVar; }
> @@ -328,10 +332,13 @@ __declspec(dllimport) inline int Referen
>  // MO1-DAG: define available_externally dllimport i32
> @"\01?ReferencingImportedFunc@@YAHXZ"
>  __declspec(dllimport) inline int ReferencingNonImportedFunc() { return
> NonImportedFunc(); }
>  // MO1-DAG: declare dllimport i32 @"\01?ReferencingNonImportedFunc@@
> YAHXZ"()
> +__declspec(dllimport) inline int ReferencingNonImportedMethod(ClassWithNonImportedMethod
> *x) { return x->f(); }
> +// MO1-DAG: declare dllimport i32 @"\01?ReferencingNonImportedMethod
>  USE(ReferencingImportedVar)
>  USE(ReferencingNonImportedVar)
>  USE(ReferencingImportedFunc)
>  USE(ReferencingNonImportedFunc)
> +USE1(ReferencingNonImportedMethod)
>  // References to operator new and delete count too, despite not being
> DeclRefExprs.
>  __declspec(dllimport) inline int *ReferencingNonImportedNew() { return
> new int[2]; }
>  // MO1-DAG: declare dllimport i32* @"\01?ReferencingNonImportedNew@@
> YAPAHXZ"
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170120/91da1df0/attachment-0001.html>


More information about the cfe-commits mailing list