Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1330)

Unified Diff: lib/CodeGen/CGExprComplex.cpp

Issue 18502004: Propagate alignment for _Complex (Closed) Base URL: http://git.chromium.org/native_client/pnacl-clang.git@master
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/CodeGen/CGExprComplex.cpp
diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp
index 0a53d4f1277f3493e8e6a206f16a3b26c5d6788d..0067c38285a0496b6c6a23ee98b604fe5e0c05b3 100644
--- a/lib/CodeGen/CGExprComplex.cpp
+++ b/lib/CodeGen/CGExprComplex.cpp
@@ -18,6 +18,7 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
+#include "llvm/IR/GlobalValue.h" // @LOCALMOD not needed after merge
using namespace clang;
using namespace CodeGen;
@@ -291,17 +292,27 @@ public:
ComplexPairTy ComplexExprEmitter::EmitLoadOfComplex(llvm::Value *SrcPtr,
bool isVolatile) {
llvm::Value *Real=0, *Imag=0;
+ // @LOCALMOD-START I submitted a fix upstream for this issue, but the code
+ // was re-written to use LValue instead of Value, so this
+ // fix will be wrong after the merge.
+ // We should cherry-pick my fix, which is past 3.3.
+ unsigned Align = 0;
+
+ if (llvm::GlobalValue *GV = dyn_cast<llvm::GlobalValue>(SrcPtr))
+ Align = GV->getAlignment();
if (!IgnoreReal || isVolatile) {
llvm::Value *RealP = Builder.CreateStructGEP(SrcPtr, 0,
SrcPtr->getName() + ".realp");
- Real = Builder.CreateLoad(RealP, isVolatile, SrcPtr->getName() + ".real");
+ Real = Builder.CreateAlignedLoad(RealP, Align, isVolatile,
+ SrcPtr->getName() + ".real");
}
if (!IgnoreImag || isVolatile) {
llvm::Value *ImagP = Builder.CreateStructGEP(SrcPtr, 1,
SrcPtr->getName() + ".imagp");
- Imag = Builder.CreateLoad(ImagP, isVolatile, SrcPtr->getName() + ".imag");
+ Imag = Builder.CreateAlignedLoad(ImagP, Align, isVolatile,
+ SrcPtr->getName() + ".imag");
}
return ComplexPairTy(Real, Imag);
}
@@ -312,9 +323,14 @@ void ComplexExprEmitter::EmitStoreOfComplex(ComplexPairTy Val, llvm::Value *Ptr,
bool isVolatile) {
llvm::Value *RealPtr = Builder.CreateStructGEP(Ptr, 0, "real");
llvm::Value *ImagPtr = Builder.CreateStructGEP(Ptr, 1, "imag");
+ unsigned Align = 0;
+
+ if (llvm::GlobalValue *GV = dyn_cast<llvm::GlobalValue>(Ptr))
+ Align = GV->getAlignment();
- Builder.CreateStore(Val.first, RealPtr, isVolatile);
- Builder.CreateStore(Val.second, ImagPtr, isVolatile);
+ Builder.CreateAlignedStore(Val.first, RealPtr, Align, isVolatile);
+ Builder.CreateAlignedStore(Val.second, ImagPtr, Align, isVolatile);
+ // @LOCALMOD-END
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698