<div dir="ltr">What would addrspace 0 be added to?</div><div dir="ltr"></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 9, 2019 at 1:54 PM Eric Christopher <<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Not just add addrspace 0 to all of them?<br>
<br>
-eric<br>
<br>
On Tue, Aug 27, 2019 at 4:06 PM Amy Huang via Phabricator via<br>
llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
><br>
> akhuang created this revision.<br>
> akhuang added a reviewer: rnk.<br>
> Herald added subscribers: llvm-commits, hiraditya.<br>
> Herald added a project: LLVM.<br>
><br>
> Follow up to <a href="https://reviews.llvm.org/D64931" rel="noreferrer" target="_blank">https://reviews.llvm.org/D64931</a> to allow existing IR with the old datalayout to compile.<br>
><br>
><br>
> Repository:<br>
>   rG LLVM Github Monorepo<br>
><br>
> <a href="https://reviews.llvm.org/D66843" rel="noreferrer" target="_blank">https://reviews.llvm.org/D66843</a><br>
><br>
> Files:<br>
>   llvm/include/llvm/Target/TargetMachine.h<br>
>   llvm/lib/Target/X86/X86TargetMachine.cpp<br>
>   llvm/lib/Target/X86/X86TargetMachine.h<br>
><br>
><br>
> Index: llvm/lib/Target/X86/X86TargetMachine.h<br>
> ===================================================================<br>
> --- llvm/lib/Target/X86/X86TargetMachine.h<br>
> +++ llvm/lib/Target/X86/X86TargetMachine.h<br>
> @@ -30,6 +30,7 @@<br>
>  class X86TargetMachine final : public LLVMTargetMachine {<br>
>    std::unique_ptr<TargetLoweringObjectFile> TLOF;<br>
>    mutable StringMap<std::unique_ptr<X86Subtarget>> SubtargetMap;<br>
> +  const DataLayout DLNoAddrSpaces;<br>
><br>
>  public:<br>
>    X86TargetMachine(const Target &T, const Triple &TT, StringRef CPU,<br>
> @@ -52,6 +53,8 @@<br>
>    TargetLoweringObjectFile *getObjFileLowering() const override {<br>
>      return TLOF.get();<br>
>    }<br>
> +<br>
> +  bool isCompatibleDataLayout(const DataLayout &Candidate) const override;<br>
>  };<br>
><br>
>  } // end namespace llvm<br>
> Index: llvm/lib/Target/X86/X86TargetMachine.cpp<br>
> ===================================================================<br>
> --- llvm/lib/Target/X86/X86TargetMachine.cpp<br>
> +++ llvm/lib/Target/X86/X86TargetMachine.cpp<br>
> @@ -106,7 +106,8 @@<br>
>    llvm_unreachable("unknown subtarget type");<br>
>  }<br>
><br>
> -static std::string computeDataLayout(const Triple &TT) {<br>
> +static std::string computeDataLayout(const Triple &TT,<br>
> +                                     bool AddressSpaces = true) {<br>
>    // X86 is little endian<br>
>    std::string Ret = "e";<br>
><br>
> @@ -118,7 +119,8 @@<br>
>      Ret += "-p:32:32";<br>
><br>
>    // Address spaces for 32 bit signed, 32 bit unsigned, and 64 bit pointers.<br>
> -  Ret += "-p270:32:32-p271:32:32-p272:64:64";<br>
> +  if (AddressSpaces)<br>
> +    Ret += "-p270:32:32-p271:32:32-p272:64:64";<br>
><br>
>    // Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.<br>
>    if (TT.isArch64Bit() || TT.isOSWindows() || TT.isOSNaCl())<br>
> @@ -221,7 +223,8 @@<br>
>            getEffectiveRelocModel(TT, JIT, RM),<br>
>            getEffectiveX86CodeModel(CM, JIT, TT.getArch() == Triple::x86_64),<br>
>            OL),<br>
> -      TLOF(createTLOF(getTargetTriple())) {<br>
> +      TLOF(createTLOF(getTargetTriple())),<br>
> +      DLNoAddrSpaces(computeDataLayout(TT, /*AddressSpaces=*/false)) {<br>
>    // Windows stack unwinder gets confused when execution flow "falls through"<br>
>    // after a call to 'noreturn' function.<br>
>    // To prevent that, we emit a trap for 'unreachable' IR instructions.<br>
> @@ -323,6 +326,13 @@<br>
>    return I.get();<br>
>  }<br>
><br>
> +bool X86TargetMachine::isCompatibleDataLayout(<br>
> +    const DataLayout &Candidate) const {<br>
> +  // Maintain compatibility with datalayouts that don't have address space<br>
> +  // pointer sizes.<br>
> +  return DL == Candidate || DLNoAddrSpaces == Candidate;<br>
> +}<br>
> +<br>
>  //===----------------------------------------------------------------------===//<br>
>  // Command line options for x86<br>
>  //===----------------------------------------------------------------------===//<br>
> Index: llvm/include/llvm/Target/TargetMachine.h<br>
> ===================================================================<br>
> --- llvm/include/llvm/Target/TargetMachine.h<br>
> +++ llvm/include/llvm/Target/TargetMachine.h<br>
> @@ -157,7 +157,7 @@<br>
>    /// The LLVM Module owns a DataLayout that is used for the target independent<br>
>    /// optimizations and code generation. This hook provides a target specific<br>
>    /// check on the validity of this DataLayout.<br>
> -  bool isCompatibleDataLayout(const DataLayout &Candidate) const {<br>
> +  virtual bool isCompatibleDataLayout(const DataLayout &Candidate) const {<br>
>      return DL == Candidate;<br>
>    }<br>
><br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>