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

David Majnemer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 23 12:29:53 PDT 2018


majnemer added inline comments.


================
Comment at: lib/CodeGen/AsmPrinter/AsmPrinter.cpp:2669
+    const MachineConstantPoolEntry &CPE =
+        MF->getConstantPool()->getConstants()[CPID];
+    if (!CPE.isMachineConstantPoolEntry() && CPE.getType() &&
----------------
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?


https://reviews.llvm.org/D49644





More information about the llvm-commits mailing list