aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2004-05-20 07:43:40 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2004-05-20 07:43:40 +0000
commitceabd97423f8431f8215f180e21722fc3d221a35 (patch)
tree4174a8da9770f5f57690f793cbcc5a094a2d68d2 /lib
parenta900452d37ec2b5ae34b0aedfefe23675476a6c4 (diff)
Fix a bug in outputting branches to constant PCs. Since the PC is supplied as
a full 64-bit address, it must be adjusted to fit in the branch instruction's immediate field. (This is only used in the reoptimizer, for now.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13608 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/SparcV9/SparcV9CodeEmitter.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp
index 6606d8d646..4fc221325a 100644
--- a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp
+++ b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp
@@ -597,8 +597,9 @@ int64_t SparcV9CodeEmitter::getMachineOpValue(MachineInstr &MI,
unsigned* CurrPC = (unsigned*)(intptr_t)MCE.getCurrentPCValue();
BBRefs.push_back(std::make_pair(BB, std::make_pair(CurrPC, &MI)));
} else if (const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
- // Make constant PC-relative by subtracting the PC from it.
- rv = CI->getRawValue() - MCE.getCurrentPCValue();
+ // The real target of the branch is CI = PC + (rv * 4)
+ // So undo that: give the instruction (CI - PC) / 4
+ rv = (CI->getRawValue() - MCE.getCurrentPCValue()) / 4;
} else if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
// same as MO.isGlobalAddress()
DEBUG(std::cerr << "GlobalValue: ");