[PATCH] Fix addrspace when emitting constructors of static local variables

Jingyue Wu jingyue at google.com
Tue Mar 24 11:56:25 PDT 2015


Speaking of which layer we should add the conversion, I actually worked on another patch (http://reviews.llvm.org/differential/diff/22588/) that has EmitStaticVarDecl pass the addrspacecasted global variable to AddInitializerToStaticVarDecl. They both fix the issue. The patch here is to me simpler, because the other patch requires several interface-level changes.


================
Comment at: lib/CodeGen/CGDeclCXX.cpp:143
@@ +142,3 @@
+  // The address space of D may be more generic than the address space of
+  // DeclPtr. In that case, we perform an addrspacecast.
+  unsigned DeclaredAddrSpace = getContext().getTargetAddressSpace(T);
----------------
eliben wrote:
> IMHO this could use a bit more clarification - when can this happen and what does "more generic" mean. Perhaps a small input code example in the comment + showing what VarDecl and DeclPtr end up being in that case?
Done. 

================
Comment at: lib/CodeGen/CGDeclCXX.cpp:145
@@ +144,3 @@
+  unsigned DeclaredAddrSpace = getContext().getTargetAddressSpace(T);
+  unsigned ActualAddrSpace = CGM.GetGlobalVarAddressSpace(&D, DeclaredAddrSpace);
+  if (ActualAddrSpace != DeclaredAddrSpace) {
----------------
eliben wrote:
> Why is DeclaredAddrSpace passed to GetGlobalVarAddressSpace here?
DeclaredAddrSpace is the type GetGlobalVarAddressSpace should return when D is not address space qualified. I agree it's a little confusing, so I now compute ActualAddrSpace in a different way. It's equivalent, but more understandable.

http://reviews.llvm.org/D8575

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list