aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/X86/X86FastISel.cpp
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2013-10-22 21:29:08 +0000
committerQuentin Colombet <qcolombet@apple.com>2013-10-22 21:29:08 +0000
commitf45787c645cdf9fb9e0f65b77d48630579a6d3e3 (patch)
tree0e0f711ebce7a2e49a5d58f3cb5cc409cae3e643 /lib/Target/X86/X86FastISel.cpp
parent8305cae0045f804b7cca7c69f83f20ad847817bd (diff)
downloadexternal_llvm-f45787c645cdf9fb9e0f65b77d48630579a6d3e3.zip
external_llvm-f45787c645cdf9fb9e0f65b77d48630579a6d3e3.tar.gz
external_llvm-f45787c645cdf9fb9e0f65b77d48630579a6d3e3.tar.bz2
[X86][FastISel] Add a comment to help understanding changes made in r192636.
<rdar://problem/15192473> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193199 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86FastISel.cpp')
-rw-r--r--lib/Target/X86/X86FastISel.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp
index 6bbc984..7984e76 100644
--- a/lib/Target/X86/X86FastISel.cpp
+++ b/lib/Target/X86/X86FastISel.cpp
@@ -633,6 +633,29 @@ bool X86FastISel::X86SelectCallAddress(const Value *V, X86AddressMode &AM) {
const User *U = NULL;
unsigned Opcode = Instruction::UserOp1;
const Instruction *I = dyn_cast<Instruction>(V);
+ // Record if the value is defined in the same basic block.
+ //
+ // This information is crucial to know whether or not folding an
+ // operand is valid.
+ // Indeed, FastISel generates or reuses a virtual register for all
+ // operands of all instructions it selects. Obviously, the definition and
+ // its uses must use the same virtual register otherwise the produced
+ // code is incorrect.
+ // Before instruction selection, FunctionLoweringInfo::set sets the virtual
+ // registers for values that are alive across basic blocks. This ensures
+ // that the values are consistently set between across basic block, even
+ // if different instruction selection mechanisms are used (e.g., a mix of
+ // SDISel and FastISel).
+ // For values local to a basic block, the instruction selection process
+ // generates these virtual registers with whatever method is appropriate
+ // for its needs. In particular, FastISel and SDISel do not share the way
+ // local virtual registers are set.
+ // Therefore, this is impossible (or at least unsafe) to share values
+ // between basic blocks unless they use the same instruction selection
+ // method, which is not guarantee for X86.
+ // Moreover, things like hasOneUse could not be used accurately, if we
+ // allow to reference values across basic blocks whereas they are not
+ // alive across basic blocks initially.
bool InMBB = true;
if (I) {
Opcode = I->getOpcode();