@@ -254,30 +254,23 @@ void MCTargetExpr::anchor() {}
254254/* *** */
255255
256256bool MCExpr::evaluateAsAbsolute (int64_t &Res) const {
257- return evaluateAsAbsolute (Res, nullptr , nullptr , false );
258- }
259-
260- bool MCExpr::evaluateAsAbsolute (int64_t &Res, const MCAssembler &Asm,
261- const SectionAddrMap &Addrs) const {
262- // Setting InSet causes us to absolutize differences across sections and that
263- // is what the MachO writer uses Addrs for.
264- return evaluateAsAbsolute (Res, &Asm, &Addrs, true );
257+ return evaluateAsAbsolute (Res, nullptr , false );
265258}
266259
267260bool MCExpr::evaluateAsAbsolute (int64_t &Res, const MCAssembler &Asm) const {
268- return evaluateAsAbsolute (Res, &Asm, nullptr , false );
261+ return evaluateAsAbsolute (Res, &Asm, false );
269262}
270263
271264bool MCExpr::evaluateAsAbsolute (int64_t &Res, const MCAssembler *Asm) const {
272- return evaluateAsAbsolute (Res, Asm, nullptr , false );
265+ return evaluateAsAbsolute (Res, Asm, false );
273266}
274267
275268bool MCExpr::evaluateKnownAbsolute (int64_t &Res, const MCAssembler &Asm) const {
276- return evaluateAsAbsolute (Res, &Asm, nullptr , true );
269+ return evaluateAsAbsolute (Res, &Asm, true );
277270}
278271
279272bool MCExpr::evaluateAsAbsolute (int64_t &Res, const MCAssembler *Asm,
280- const SectionAddrMap *Addrs, bool InSet) const {
273+ bool InSet) const {
281274 MCValue Value;
282275
283276 // Fast path constants.
@@ -286,7 +279,7 @@ bool MCExpr::evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
286279 return true ;
287280 }
288281
289- bool IsRelocatable = evaluateAsRelocatableImpl (Value, Asm, Addrs, InSet);
282+ bool IsRelocatable = evaluateAsRelocatableImpl (Value, Asm, InSet);
290283 Res = Value.getConstant ();
291284 // Value with RefKind (e.g. %hi(0xdeadbeef) in MIPS) is not considered
292285 // absolute (the value is unknown at parse time), even if it might be resolved
@@ -296,7 +289,6 @@ bool MCExpr::evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
296289
297290// / Helper method for \see EvaluateSymbolAdd().
298291static void attemptToFoldSymbolOffsetDifference (const MCAssembler *Asm,
299- const SectionAddrMap *Addrs,
300292 bool InSet, const MCSymbol *&A,
301293 const MCSymbol *&B,
302294 int64_t &Addend) {
@@ -324,7 +316,7 @@ static void attemptToFoldSymbolOffsetDifference(const MCAssembler *Asm,
324316 const MCFragment *FB = SB.getFragment ();
325317 const MCSection &SecA = *FA->getParent ();
326318 const MCSection &SecB = *FB->getParent ();
327- if (( &SecA != &SecB) && !Addrs )
319+ if (&SecA != &SecB)
328320 return ;
329321
330322 // When layout is available, we can generally compute the difference using the
@@ -345,9 +337,6 @@ static void attemptToFoldSymbolOffsetDifference(const MCAssembler *Asm,
345337
346338 // Eagerly evaluate when layout is finalized.
347339 Addend += Asm->getSymbolOffset (SA) - Asm->getSymbolOffset (SB);
348- if (Addrs && (&SecA != &SecB))
349- Addend += (Addrs->lookup (&SecA) - Addrs->lookup (&SecB));
350-
351340 FinalizeFolding ();
352341 } else {
353342 // When layout is not finalized, our ability to resolve differences between
@@ -434,8 +423,7 @@ static void attemptToFoldSymbolOffsetDifference(const MCAssembler *Asm,
434423// NOTE: This function can be used before layout is done (see the object
435424// streamer for example) and having the Asm argument lets us avoid relaxations
436425// early.
437- bool MCExpr::evaluateSymbolicAdd (const MCAssembler *Asm,
438- const SectionAddrMap *Addrs, bool InSet,
426+ bool MCExpr::evaluateSymbolicAdd (const MCAssembler *Asm, bool InSet,
439427 const MCValue &LHS, const MCValue &RHS,
440428 MCValue &Res) {
441429 const MCSymbol *LHS_A = LHS.getAddSym ();
@@ -456,12 +444,10 @@ bool MCExpr::evaluateSymbolicAdd(const MCAssembler *Asm,
456444 // Result = (LHS_A - LHS_B + LHS_Cst) + (RHS_A - RHS_B + RHS_Cst).
457445 // might bring more opportunities.
458446 if (LHS_A && RHS_B) {
459- attemptToFoldSymbolOffsetDifference (Asm, Addrs, InSet, LHS_A, RHS_B,
460- Result_Cst);
447+ attemptToFoldSymbolOffsetDifference (Asm, InSet, LHS_A, RHS_B, Result_Cst);
461448 }
462449 if (RHS_A && LHS_B) {
463- attemptToFoldSymbolOffsetDifference (Asm, Addrs, InSet, RHS_A, LHS_B,
464- Result_Cst);
450+ attemptToFoldSymbolOffsetDifference (Asm, InSet, RHS_A, LHS_B, Result_Cst);
465451 }
466452 }
467453
@@ -481,10 +467,10 @@ bool MCExpr::evaluateSymbolicAdd(const MCAssembler *Asm,
481467}
482468
483469bool MCExpr::evaluateAsRelocatable (MCValue &Res, const MCAssembler *Asm) const {
484- return evaluateAsRelocatableImpl (Res, Asm, nullptr , false );
470+ return evaluateAsRelocatableImpl (Res, Asm, false );
485471}
486472bool MCExpr::evaluateAsValue (MCValue &Res, const MCAssembler &Asm) const {
487- return evaluateAsRelocatableImpl (Res, &Asm, nullptr , true );
473+ return evaluateAsRelocatableImpl (Res, &Asm, true );
488474}
489475static bool canExpand (const MCSymbol &Sym, bool InSet) {
490476 if (Sym.isWeakExternal ())
@@ -503,7 +489,6 @@ static bool canExpand(const MCSymbol &Sym, bool InSet) {
503489}
504490
505491bool MCExpr::evaluateAsRelocatableImpl (MCValue &Res, const MCAssembler *Asm,
506- const SectionAddrMap *Addrs,
507492 bool InSet) const {
508493 ++stats::MCExprEvaluate;
509494 switch (getKind ()) {
@@ -523,7 +508,7 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
523508 if (Sym.isVariable () && (Kind == MCSymbolRefExpr::VK_None || Layout) &&
524509 canExpand (Sym, InSet)) {
525510 bool IsMachO = SRE->hasSubsectionsViaSymbols ();
526- if (Sym.getVariableValue ()->evaluateAsRelocatableImpl (Res, Asm, Addrs,
511+ if (Sym.getVariableValue ()->evaluateAsRelocatableImpl (Res, Asm,
527512 InSet || IsMachO)) {
528513 if (Kind != MCSymbolRefExpr::VK_None) {
529514 if (Res.isAbsolute ()) {
@@ -566,7 +551,7 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
566551 const MCUnaryExpr *AUE = cast<MCUnaryExpr>(this );
567552 MCValue Value;
568553
569- if (!AUE->getSubExpr ()->evaluateAsRelocatableImpl (Value, Asm, Addrs, InSet))
554+ if (!AUE->getSubExpr ()->evaluateAsRelocatableImpl (Value, Asm, InSet))
570555 return false ;
571556 switch (AUE->getOpcode ()) {
572557 case MCUnaryExpr::LNot:
@@ -600,10 +585,8 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
600585 const MCBinaryExpr *ABE = cast<MCBinaryExpr>(this );
601586 MCValue LHSValue, RHSValue;
602587
603- if (!ABE->getLHS ()->evaluateAsRelocatableImpl (LHSValue, Asm, Addrs,
604- InSet) ||
605- !ABE->getRHS ()->evaluateAsRelocatableImpl (RHSValue, Asm, Addrs,
606- InSet)) {
588+ if (!ABE->getLHS ()->evaluateAsRelocatableImpl (LHSValue, Asm, InSet) ||
589+ !ABE->getRHS ()->evaluateAsRelocatableImpl (RHSValue, Asm, InSet)) {
607590 // Check if both are Target Expressions, see if we can compare them.
608591 if (const MCTargetExpr *L = dyn_cast<MCTargetExpr>(ABE->getLHS ())) {
609592 if (const MCTargetExpr *R = dyn_cast<MCTargetExpr>(ABE->getRHS ())) {
@@ -650,7 +633,7 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
650633 return false ;
651634 if (RHSValue.SymB && RHSValue.Specifier )
652635 return false ;
653- return evaluateSymbolicAdd (Asm, Addrs, InSet, LHSValue, RHSValue, Res);
636+ return evaluateSymbolicAdd (Asm, InSet, LHSValue, RHSValue, Res);
654637 }
655638 }
656639
0 commit comments