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

Unified Diff: lib/Transforms/NaCl/FlattenGlobals.cpp

Issue 15359006: PNaCl: Fix FlattenGlobals to correctly handle implicitly-aligned variables (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Created 7 years, 7 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 | test/Transforms/NaCl/flatten-globals.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/Transforms/NaCl/FlattenGlobals.cpp
diff --git a/lib/Transforms/NaCl/FlattenGlobals.cpp b/lib/Transforms/NaCl/FlattenGlobals.cpp
index 86a46b5d30ca6947b41996b01664a131da5fd9e3..77ce2b36b453e837029dc08fc61d2c4135615278 100644
--- a/lib/Transforms/NaCl/FlattenGlobals.cpp
+++ b/lib/Transforms/NaCl/FlattenGlobals.cpp
@@ -255,8 +255,8 @@ bool FlattenGlobals::runOnModule(Module &M) {
continue;
Modified = true;
- uint64_t Size = DL.getTypeAllocSize(
- Global->getType()->getPointerElementType());
+ Type *GlobalType = Global->getType()->getPointerElementType();
+ uint64_t Size = DL.getTypeAllocSize(GlobalType);
Constant *NewInit;
Type *NewType;
if (Global->hasInitializer()) {
@@ -281,6 +281,8 @@ bool FlattenGlobals::runOnModule(Module &M) {
NewInit, "", Global,
Global->getThreadLocalMode());
NewGlobal->copyAttributesFrom(Global);
+ if (NewGlobal->getAlignment() == 0)
+ NewGlobal->setAlignment(DL.getPrefTypeAlignment(GlobalType));
NewGlobal->setExternallyInitialized(Global->isExternallyInitialized());
NewGlobal->takeName(Global);
Global->replaceAllUsesWith(
« no previous file with comments | « no previous file | test/Transforms/NaCl/flatten-globals.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698