Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 017bc0f

Browse files
author
Reed Kotler
committed
Fix regression with -O0 for mips .
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203469 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c869887 commit 017bc0f

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

lib/Target/Mips/MipsTargetMachine.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ class MipsPassConfig : public TargetPassConfig {
175175
virtual bool addInstSelector();
176176
virtual void addMachineSSAOptimization();
177177
virtual bool addPreEmitPass();
178+
179+
virtual bool addPreRegAlloc();
180+
178181
};
179182
} // namespace
180183

@@ -208,6 +211,15 @@ void MipsPassConfig::addMachineSSAOptimization() {
208211
TargetPassConfig::addMachineSSAOptimization();
209212
}
210213

214+
bool MipsPassConfig::addPreRegAlloc() {
215+
if (getOptLevel() == CodeGenOpt::None) {
216+
addPass(createMipsOptimizePICCallPass(getMipsTargetMachine()));
217+
return true;
218+
}
219+
else
220+
return false;
221+
}
222+
211223
void MipsTargetMachine::addAnalysisPasses(PassManagerBase &PM) {
212224
if (Subtarget.allowMixed16_32()) {
213225
DEBUG(errs() << "No ");

test/CodeGen/Mips/optimize-pic-o0.ll

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
; RUN: llc -mtriple=mipsel -O0 < %s | FileCheck %s
2+
3+
; Function Attrs: nounwind
4+
define i32 @main() {
5+
entry:
6+
%retval = alloca i32, align 4
7+
%i = alloca i32, align 4
8+
store i32 0, i32* %retval
9+
store i32 0, i32* %i, align 4
10+
br label %for.cond
11+
12+
for.cond: ; preds = %for.inc, %entry
13+
%0 = load i32* %i, align 4
14+
%cmp = icmp slt i32 %0, 10
15+
br i1 %cmp, label %for.body, label %for.end
16+
17+
for.body: ; preds = %for.cond
18+
call void bitcast (void (...)* @foo to void ()*)()
19+
; CHECK: jalr $25
20+
br label %for.inc
21+
22+
for.inc: ; preds = %for.body
23+
%1 = load i32* %i, align 4
24+
%inc = add nsw i32 %1, 1
25+
store i32 %inc, i32* %i, align 4
26+
br label %for.cond
27+
28+
for.end: ; preds = %for.cond
29+
%2 = load i32* %retval
30+
ret i32 %2
31+
}
32+
33+
declare void @foo(...)

0 commit comments

Comments
 (0)