[PATCH] Defer codegen of dllexport/attribute(used) inline method definitions

Richard Smith richard at metafoo.co.uk
Thu Jun 5 18:24:09 PDT 2014

Comment at: lib/CodeGen/ModuleBuilder.cpp:92
@@ -91,3 @@
-      if (!D->isDependentContext() &&
-          (D->hasAttr<UsedAttr>() || D->hasAttr<ConstructorAttr>() ||
-           D->hasAttr<DLLExportAttr>())) {
An alternative fix would be to check `D->isUsed()` instead of checking for `UsedAttr` here. That'd avoid the locality degradation and memory allocation here.

Or just remove this check and unconditionally call `EmitTopLevelDecl`? That would better match what we do for out-of-line method definitions, and would avoid duplicating this between here and `ASTContext::DeclMustBeEmitted`.

Comment at: test/CodeGenCXX/attr-used.cpp:21
@@ +20,3 @@
+  // We must delay emission of bar() until foo() has had its body parsed,
+  // othersie foo() would not be emitted.
+  void __attribute__((used)) bar() { foo(); }
Reid Kleckner wrote:
> "otherwise"
Typo "othersie"


More information about the cfe-commits mailing list