diff options
author | Dan Gohman <gohman@apple.com> | 2010-10-14 23:06:10 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-10-14 23:06:10 +0000 |
commit | 3d5aff5d3036b0ff09d114857cd2276134b3d8c9 (patch) | |
tree | 63d582147e979c75e55602858d0bcae7fff6b422 /lib/CodeGen/CGExpr.cpp | |
parent | 5bc794ff3034bad2b231b0841ea6d0a711c4af59 (diff) |
Experimental TBAA support.
This enables metadata generation by default, however the TBAA pass
in the optimizer is still disabled for now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116536 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 186c5ff428..5b695cd52c 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -13,6 +13,7 @@ #include "CodeGenFunction.h" #include "CodeGenModule.h" +#include "CodeGenTBAA.h" #include "CGCall.h" #include "CGCXXABI.h" #include "CGRecordLayout.h" @@ -580,12 +581,15 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) { } llvm::Value *CodeGenFunction::EmitLoadOfScalar(llvm::Value *Addr, bool Volatile, - unsigned Alignment, QualType Ty) { + unsigned Alignment, QualType Ty, + llvm::MDNode *TBAAInfo) { llvm::LoadInst *Load = Builder.CreateLoad(Addr, "tmp"); if (Volatile) Load->setVolatile(true); if (Alignment) Load->setAlignment(Alignment); + if (TBAAInfo) + CGM.DecorateInstruction(Load, TBAAInfo); // Bool can have different representation in memory than in registers. llvm::Value *V = Load; @@ -604,7 +608,8 @@ static bool isBooleanUnderlyingType(QualType Ty) { void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, llvm::Value *Addr, bool Volatile, unsigned Alignment, - QualType Ty) { + QualType Ty, + llvm::MDNode *TBAAInfo) { if (Ty->isBooleanType() || isBooleanUnderlyingType(Ty)) { // Bool can have different representation in memory than in registers. @@ -615,6 +620,8 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, llvm::Value *Addr, llvm::StoreInst *Store = Builder.CreateStore(Value, Addr, Volatile); if (Alignment) Store->setAlignment(Alignment); + if (TBAAInfo) + CGM.DecorateInstruction(Store, TBAAInfo); } /// EmitLoadOfLValue - Given an expression that represents a value lvalue, this @@ -637,7 +644,8 @@ RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) { // Everything needs a load. return RValue::get(EmitLoadOfScalar(Ptr, LV.isVolatileQualified(), - LV.getAlignment(), ExprType)); + LV.getAlignment(), ExprType, + LV.getTBAAInfo())); } @@ -846,7 +854,8 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, assert(Src.isScalar() && "Can't emit an agg store with this method"); EmitStoreOfScalar(Src.getScalarVal(), Dst.getAddress(), - Dst.isVolatileQualified(), Dst.getAlignment(), Ty); + Dst.isVolatileQualified(), Dst.getAlignment(), Ty, + Dst.getTBAAInfo()); } void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, |