[PATCH] D49644: [COFF] Hoist constant pool handling from X86AsmPrinter into AsmPrinter

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 23 12:34:00 PDT 2018


mstorsjo added inline comments.


================
Comment at: lib/CodeGen/AsmPrinter/AsmPrinter.cpp:2669
+    const MachineConstantPoolEntry &CPE =
+        MF->getConstantPool()->getConstants()[CPID];
+    if (!CPE.isMachineConstantPoolEntry() && CPE.getType() &&
----------------
majnemer wrote:
> mstorsjo wrote:
> > FWIW, in order to make test/CodeGen/ARM/setjmp_longjmp.ll pass reliably without out of bounds accesses, I have to do this extra modification:
> > 
> > ```
> > @@ -2664,11 +2664,11 @@ MCSymbol *AsmPrinter::GetBlockAddressSymbol(const BasicBlock *BB) const {
> >  
> >  /// GetCPISymbol - Return the symbol for the specified constant pool entry.
> >  MCSymbol *AsmPrinter::GetCPISymbol(unsigned CPID) const {
> > -  if (getSubtargetInfo().getTargetTriple().isOSWindows()) {
> > -    const MachineConstantPoolEntry &CPE =
> > -        MF->getConstantPool()->getConstants()[CPID];
> > +  const std::vector<MachineConstantPoolEntry> &CP =
> > +      MF->getConstantPool()->getConstants();
> > +  if (getSubtargetInfo().getTargetTriple().isOSWindows() && CPID < CP.size()) {
> > +    const MachineConstantPoolEntry &CPE = CP[CPID];
> >     if (!CPE.isMachineConstantPoolEntry() && CPE.getType() &&
> >         CPE.getType()->isSized()) {
> >        const DataLayout &DL = MF->getDataLayout();
> >        SectionKind Kind = CPE.getSectionKind(&DL);
> > ```
> > 
> > I'll update the diff accordingly.
> That's a little weird. Sounds like somebody is predicting the ID of something in the constant pool. Can you find out which path is doing this?
I can try, but if someone else who is more familiar wants to have a look I'd appreciate it - since CPID doesn't seem to come from somewhere directly further up in the call stack, I'd have to sit down and try trace it through the machinery to see where it comes from.


https://reviews.llvm.org/D49644





More information about the llvm-commits mailing list