[PATCH] D46441: [clang][CodeGenCXX] Noalias attr for copy/move constructor arguments

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat May 12 22:21:26 PDT 2018


rsmith added inline comments.


================
Comment at: lib/CodeGen/CodeGenModule.cpp:2513
+      cast<CXXConstructorDecl>(D)->isCopyOrMoveConstructor())
+    F->addParamAttr(1, llvm::Attribute::NoAlias);
+
----------------
rsmith wrote:
> It's not strictly correct to assume that you know the correspondence between `llvm::Function` parameter indices and those of the `clang::FunctionDecl` like this. That's up to the ABI, and for constructors in particular, there may be a VTT parameter to deal with (and `__attribute__((pass_object_size))` can also interfere). You can probably get away with assuming that the `this` parameter has index 0 for now, but even that is likely to break at some point down the line.
The best way to deal with this is to create the attribute in `CodeGenModule::ConstructAttributeList`, where you have access to the `ClangToLLVMArgMapping`.


https://reviews.llvm.org/D46441





More information about the cfe-commits mailing list