Index: lib/Transforms/NaCl/ExpandByVal.cpp |
diff --git a/lib/Transforms/NaCl/ExpandByVal.cpp b/lib/Transforms/NaCl/ExpandByVal.cpp |
index cc2c73325eac25f33e9c85f7696556bb3d465854..7227f3e5018b60f1e02b69624830b2a82733f3fa 100644 |
--- a/lib/Transforms/NaCl/ExpandByVal.cpp |
+++ b/lib/Transforms/NaCl/ExpandByVal.cpp |
@@ -82,6 +82,14 @@ AttributeSet RemoveAttrs(LLVMContext &Context, AttributeSet Attrs) { |
Attr->getKindAsEnum() != Attribute::StructRet) { |
AB.addAttribute(*Attr); |
} |
+ // IR semantics require that ByVal implies NoAlias. However, IR |
+ // semantics do not require StructRet to imply NoAlias. For |
+ // example, a global variable address can be passed as a |
+ // StructRet argument, although Clang does not do so and Clang |
+ // explicitly adds NoAlias to StructRet arguments. |
+ if (Attr->getKindAsEnum() == Attribute::ByVal) { |
+ AB.addAttribute(Attribute::get(Context, Attribute::NoAlias)); |
+ } |
} |
AttrList.push_back(AttributeSet::get(Context, Index, AB)); |
} |