[PATCH] D137107: Allow MS extension: support of constexpr with __declspec(dllimport).

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 3 14:36:12 PDT 2022


mstorsjo added a comment.

In D137107#3905443 <https://reviews.llvm.org/D137107#3905443>, @zahiraam wrote:

> and the same assembly (load __imp_?val) (is that why you made the comment above?). And the test case runs.

Yes, pretty much - the actual value of the address of `&val` isn't known at compile time and it cannot be produced in a way to initialize e.g. static memory, which I would believe that one can expect of constexpr. The runtime linker that loads DLLs can't fix it so that the address is available as a statically initialized data, but to use it it does require runtime code to fetch the address.

> Without  constexpr the symbol generated is
>
> 0E 00000000 UNDEF  notype       External     | __imp_?val@@3HA (__declspec(dllimport) int val)
>
> and the assembly generates a ‘load __imp_? Val’. Same than MSVC, but the test case fails to run.  @rnk Shouldn't this run?

Can you give the full exact repro for this case, without constexpr, which you say fails to run - I tried to follow the instructions but for me it seems to work just fine, without constexpr.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137107/new/

https://reviews.llvm.org/D137107



More information about the cfe-commits mailing list