Skip to content

Commit f55c239

Browse files
committed
Addressing review comments
Change-Id: I029312362f9dd714b2e9bc206cc002883d761b8b
1 parent 72be4ca commit f55c239

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static cl::opt<bool>
5656
AllowWLSLoops("allow-arm-wlsloops", cl::Hidden, cl::init(true),
5757
cl::desc("Enable the generation of WLS loops"));
5858

59-
static cl::opt<unsigned> UseWidenGlobalStrings(
59+
static cl::opt<bool> UseWidenGlobalArrays(
6060
"widen-global-strings", cl::Hidden, cl::init(true),
6161
cl::desc("Enable the widening of global strings to alignment boundaries"));
6262

@@ -2815,6 +2815,11 @@ bool ARMTTIImpl::useWidenGlobalStrings() const { return UseWidenGlobalStrings; }
28152815

28162816
unsigned ARMTTIImpl::getNumBytesToPadGlobalArray(unsigned Size,
28172817
Type *ArrayType) const {
2818+
if (!UseWidenGlobalArrays){
2819+
LLVM_DEBUG(dbgs() << "Padding global arrays disabled\n");
2820+
return false;
2821+
}
2822+
28182823
// Don't modify none integer array types
28192824
if (!ArrayType || !ArrayType->isArrayTy() ||
28202825
!ArrayType->getArrayElementType()->isIntegerTy())

llvm/lib/Transforms/IPO/GlobalOpt.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,13 +2043,9 @@ static bool callInstIsMemcpy(CallInst *CI) {
20432043
}
20442044

20452045
static bool destArrayCanBeWidened(CallInst *CI) {
2046-
auto *GV = dyn_cast<GlobalVariable>(CI->getArgOperand(0));
20472046
auto *Alloca = dyn_cast<AllocaInst>(CI->getArgOperand(0));
20482047
auto *IsVolatile = dyn_cast<ConstantInt>(CI->getArgOperand(3));
20492048

2050-
if (!GV || !GV->hasInitializer())
2051-
return false;
2052-
20532049
if (!Alloca || !IsVolatile || IsVolatile->isOne())
20542050
return false;
20552051

@@ -2129,12 +2125,17 @@ static bool tryWidenGlobalArrayAndDests(Function *F, GlobalVariable *SourceVar,
21292125
widenGlobalVariable(SourceVar, F, NumBytesToPad, NumBytesToCopy);
21302126
if (!NewSourceGV)
21312127
return false;
2128+
21322129
// Update arguments of remaining uses that
21332130
// are memcpys.
21342131
for (auto *User : SourceVar->users()) {
21352132
auto *CI = dyn_cast<CallInst>(User);
2136-
if (!callInstIsMemcpy(CI))
2137-
continue;
2133+
if (!callInstIsMemcpy(CI))
2134+
continue;
2135+
2136+
if (CI->getArgOperand(1) != SourceVar)
2137+
continue;
2138+
21382139

21392140
widenDestArray(CI, NumBytesToPad, NumBytesToCopy, SourceDataArray);
21402141

llvm/test/Transforms/GlobalOpt/ARM/arm-widen-global-dest.ll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2-
; RUN: opt -mtriple=arm-none-eabi -passes=globalopt -S | FileCheck %s
2+
; RUN: opt <%s -mtriple=arm-none-eabi -passes=globalopt -S | FileCheck %s
33

4-
; CHECK: [4 x i8]
54
@.i8 = private unnamed_addr constant [3 x i8] [i8 1, i8 2, i8 3] , align 1
6-
; CHECK: [4 x i8]
75
@other = private unnamed_addr global [3 x i8] [i8 1, i8 2, i8 3] , align 1
86

97
define void @memcpy_multiple() {

0 commit comments

Comments
 (0)