AntonBikineev created this revision. AntonBikineev added reviewers: rsmith, aaron.ballman. AntonBikineev added a project: clang.
The patch addresses this bug <https://bugs.llvm.org/show_bug.cgi?id=37329>. According to the Standard (taken from the bug description): [class.ctor] paragraph 14: "During the construction of an object, if the value of the object or any of its subobjects is accessed through a glvalue that is not obtained, directly or indirectly, from the constructor’s this pointer, the value of the object or subobject thus obtained is unspecified." Repository: rC Clang https://reviews.llvm.org/D46441 Files: lib/CodeGen/CGCXX.cpp Index: lib/CodeGen/CGCXX.cpp =================================================================== --- lib/CodeGen/CGCXX.cpp +++ lib/CodeGen/CGCXX.cpp @@ -224,6 +224,11 @@ } else { const auto *CD = cast<CXXConstructorDecl>(MD); GD = GlobalDecl(CD, toCXXCtorType(Type)); + + // As long as `this` argument always comes first + // we hardcode the position of the `src` argument + if (CD->isCopyOrMoveConstructor()) + Fn->addParamAttr(1, llvm::Attribute::NoAlias); } setFunctionLinkage(GD, Fn);
Index: lib/CodeGen/CGCXX.cpp =================================================================== --- lib/CodeGen/CGCXX.cpp +++ lib/CodeGen/CGCXX.cpp @@ -224,6 +224,11 @@ } else { const auto *CD = cast<CXXConstructorDecl>(MD); GD = GlobalDecl(CD, toCXXCtorType(Type)); + + // As long as `this` argument always comes first + // we hardcode the position of the `src` argument + if (CD->isCopyOrMoveConstructor()) + Fn->addParamAttr(1, llvm::Attribute::NoAlias); } setFunctionLinkage(GD, Fn);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits