Index: clang/lib/CodeGen/CGStmt.cpp =================================================================== --- clang/lib/CodeGen/CGStmt.cpp +++ clang/lib/CodeGen/CGStmt.cpp @@ -2454,7 +2454,7 @@ const ABIArgInfo &RetAI = CurFnInfo->getReturnInfo(); if (RetAI.isDirect() || RetAI.isExtend()) { // Make a fake lvalue for the return value slot. - LValue ReturnSlot = MakeAddrLValue(ReturnValue, FnRetTy); + LValue ReturnSlot = MakeAddrLValueWithoutTBAA(ReturnValue, FnRetTy); CGM.getTargetCodeGenInfo().addReturnRegisterOutputs( *this, ReturnSlot, Constraints, ResultRegTypes, ResultTruncRegTypes, ResultRegDests, AsmString, S.getNumOutputs()); Index: clang/lib/CodeGen/CodeGenFunction.h =================================================================== --- clang/lib/CodeGen/CodeGenFunction.h +++ clang/lib/CodeGen/CodeGenFunction.h @@ -2504,6 +2504,13 @@ BaseInfo, TBAAInfo); } + LValue + MakeAddrLValueWithoutTBAA(Address Addr, QualType T, + AlignmentSource Source = AlignmentSource::Type) { + return LValue::MakeAddr(Addr, T, getContext(), LValueBaseInfo(Source), + CGM.returnNullTBAA()); + } + LValue MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T); LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T); Index: clang/lib/CodeGen/CodeGenModule.h =================================================================== --- clang/lib/CodeGen/CodeGenModule.h +++ clang/lib/CodeGen/CodeGenModule.h @@ -746,6 +746,9 @@ /// an object of the given type. TBAAAccessInfo getTBAAAccessInfo(QualType AccessType); + /// returnNullTBAA - Return empty TBAA constructor + TBAAAccessInfo returnNullTBAA(); + /// getTBAAVTablePtrAccessInfo - Get the TBAA information that describes an /// access to a virtual table pointer. TBAAAccessInfo getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType); Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -935,6 +935,8 @@ return TBAA->getAccessInfo(AccessType); } +TBAAAccessInfo CodeGenModule::returnNullTBAA() { return TBAAAccessInfo(); } + TBAAAccessInfo CodeGenModule::getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType) { if (!TBAA) Index: clang/test/CodeGen/avoidTBAAonASMstore.cpp =================================================================== --- /dev/null +++ clang/test/CodeGen/avoidTBAAonASMstore.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -O2 -disable-llvm-passes -fasm-blocks %s -emit-llvm -o - | FileCheck %s +float _Complex foo(float _Complex z) { +// CHECK-LABEL: define{{.*}} i64 @_Z3fooCf + unsigned short ControlWord; + __asm { fnstcw word ptr[ControlWord] }; +// CHECK: store i64 %2, i64* %1, align 4 +// CHECK-NOT: !tbaa + return z; +}