[PATCH] D54016: [X86] don't allow X86_64 PIC mode addresses to be used as immediates

John Reagan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 2 08:18:44 PDT 2018


JohnReagan added a comment.

While that seems like a place to change, I would have thought that the code just a little farther down would have caught this....

  const GlobalValue *GV = GA->getGlobal();
  // If we require an extra load to get this address, as in PIC mode, we
  // can't accept it.
  if (isGlobalStubReference(Subtarget.classifyGlobalReference(GV)))
    return;

but I was remembering my older out-of-tree backend where I have made changes.  An older classifyGlobalReference was for both functions and data.  Today, we have both classifyGlobalReference and classifyGlobalFunctionReference.  Today's classifyGlobalReference then ends up in TargetMachine.cpp/shouldAssumeDSOLocal which then sends you off into classifyLocalReference.  With no GOTPCREL, isGlobalStubReference() returns false.

I wonder if it needs to check GV to see if it is function with a dyn_cast_or_null<function> and call classifyGlobalFunctionReference instead?


Repository:
  rL LLVM

https://reviews.llvm.org/D54016





More information about the llvm-commits mailing list