[llvm-commits] [llvm] r120697 - /llvm/trunk/lib/MC/MCExpr.cpp
Rafael Espindola
rafael.espindola at gmail.com
Wed Dec 1 23:53:12 PST 2010
Author: rafael
Date: Thu Dec 2 01:53:12 2010
New Revision: 120697
URL: http://llvm.org/viewvc/llvm-project?rev=120697&view=rev
Log:
Add a fast path to EvaluateSymbolicAdd. This avoids computing symbol addresses
which then avoids running EnsureValid.
This cuts the assembly time of the testcase in PR8711 from 2:50 minutes to 1
minute.
Modified:
llvm/trunk/lib/MC/MCExpr.cpp
Modified: llvm/trunk/lib/MC/MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=120697&r1=120696&r2=120697&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Thu Dec 2 01:53:12 2010
@@ -294,12 +294,20 @@
if (Layout && A && B) {
const MCSymbol &SA = A->getSymbol();
const MCSymbol &SB = B->getSymbol();
- const MCObjectFormat &F =
- Layout->getAssembler().getBackend().getObjectFormat();
+ const MCAssembler &Asm = Layout->getAssembler();
+ const MCObjectFormat &F = Asm.getBackend().getObjectFormat();
if (SA.isDefined() && SB.isDefined() && F.isAbsolute(InSet, SA, SB)) {
- const MCAssembler &Asm = Layout->getAssembler();
MCSymbolData &AD = Asm.getSymbolData(A->getSymbol());
MCSymbolData &BD = Asm.getSymbolData(B->getSymbol());
+
+ if (AD.getFragment() == BD.getFragment()) {
+ Res = MCValue::get(+ AD.getOffset()
+ - BD.getOffset()
+ + LHS.getConstant()
+ + RHS_Cst);
+ return true;
+ }
+
Res = MCValue::get(+ Layout->getSymbolAddress(&AD)
- Layout->getSymbolAddress(&BD)
+ LHS.getConstant()
More information about the llvm-commits
mailing list