[PATCH] D34367: CodeGen: Fix address space of indirect function argument

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 21 08:03:45 PST 2018


rjmccall added inline comments.


================
Comment at: lib/CodeGen/CGCall.cpp:3505
+    if (AS != LangAS::Default && AS != LangAS::opencl_private &&
+        AS != CGM.getASTAllocaAddressSpace())
+      Flag = CallArg::ByValArgNeedsCopy;
----------------
This is an odd condition.  What are you really trying to express here?  Something about the IR address space that the AST address space maps to?

The condition `AS != LangAS::Default` kills the optimization for all practical purposes, by the way, so something does need to change here.

I will note that if CallArg could take an LValue, neither this nor the alignment check would be required here; they'd just be done by the call-emission code.


================
Comment at: lib/CodeGen/CGCall.cpp:3511
+                   static_cast<unsigned>(CallArg::NonByValArgNeedsCopy) |
+                   static_cast<unsigned>(Flag)));
     } else {
----------------
Please just add an `operator|` for CallArg::Flag.


================
Comment at: lib/CodeGen/CGCall.h:216
   struct CallArg {
+    enum Flag {
+      Default = 0x0,
----------------
I thing `Flags` would be a better name.


https://reviews.llvm.org/D34367





More information about the cfe-commits mailing list