[PATCH] D17938: CodeGen: Use PLT relocations for relative references to unnamed_addr functions.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 7 14:35:40 PST 2016
pcc added inline comments.
================
Comment at: lib/Target/X86/X86TargetObjectFile.cpp:78-91
@@ -77,16 @@
- const ConstantExpr *CE, Mangler &Mang, const TargetMachine &TM) const {
- // We are looking for the difference of two symbols, need a subtraction
- // operation.
- const SubOperator *Sub = dyn_cast<SubOperator>(CE);
- if (!Sub)
- return nullptr;
-
- // Symbols must first be numbers before we can subtract them, we need to see a
- // ptrtoint on both subtraction operands.
- const PtrToIntOperator *SubLHS =
- dyn_cast<PtrToIntOperator>(Sub->getOperand(0));
- const PtrToIntOperator *SubRHS =
- dyn_cast<PtrToIntOperator>(Sub->getOperand(1));
- if (!SubLHS || !SubRHS)
- return nullptr;
-
----------------
majnemer wrote:
> Removing this logic seems problematic, no?
>
> Won't this fire on `x * __ImageBase` ?
This part of the logic has been moved to `AsmPrinter::lowerConstant`, which will only call `lowerRelativeReference` if the expression is a substraction.
================
Comment at: lib/Target/X86/X86TargetObjectFile.h:44-45
@@ +43,4 @@
+ public:
+ X86ELFTargetObjectFile() {
+ PLTRelativeVariantKind = MCSymbolRefExpr::VK_PLT;
+ }
----------------
majnemer wrote:
> Should this be:
> X86ELFTargetObjectFile() : PLTRelativeVariantKind(MCSymbolRefExpr::VK_PLT) {}
>
> ?
No, because `PLTRelativeVariantKind` is a field of a base, so we can't initialize it that way.
http://reviews.llvm.org/D17938
More information about the llvm-commits
mailing list