<div dir="ltr">Fangrui,<div><br></div><div>Not sure if you saw my update on <a href="https://bugs.llvm.org/show_bug.cgi?id=46469">https://bugs.llvm.org/show_bug.cgi?id=46469</a>: This change (presumably along with <span style="color:rgb(0,0,0);white-space:pre-wrap">961f31d8ad14c66829991522d73e14b5a96ff6d4)</span> fixed that bug. Can you see if this fix is expected? My understanding from reading through 961f31d8ad14c66829991522d73e14b5a96ff6d4 is that it (plus this follow on) should have been NFC. Also, there is a question on that bug for you about whether the fixes could be backported to 11.0.x</div><div><br></div><div>Teresa</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Dec 5, 2020 at 11:13 PM Fangrui Song via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</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"><br>
Author: Fangrui Song<br>
Date: 2020-12-05T23:13:28-08:00<br>
New Revision: 687b83ceabafe81970cd4639e7f0c8<a href="tel:(903)%20640-2081" value="+19036402081" target="_blank">9036402081</a><br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/687b83ceabafe81970cd4639e7f0c89036402081" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/687b83ceabafe81970cd4639e7f0c89036402081</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/687b83ceabafe81970cd4639e7f0c89036402081.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/687b83ceabafe81970cd4639e7f0c89036402081.diff</a><br>
<br>
LOG: [X86FastISel] Fix MO_GOTPCREL GlobalValue reference in static relocation model<br>
<br>
This fixes the bug referenced by 5582a7987662a92eda5d883b88fc4586e755acf5<br>
which was exposed by 961f31d8ad14c66829991522d73e14b5a96ff6d4.<br>
<br>
With this change, `movq src@GOTPCREL, %rcx` => `movq src@GOTPCREL(%rip), %rcx`<br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
    llvm/lib/Target/X86/X86FastISel.cpp<br>
    llvm/test/CodeGen/X86/fast-isel-mem.ll<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff  --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp<br>
index a8db3d416c2e..caf158102230 100644<br>
--- a/llvm/lib/Target/X86/X86FastISel.cpp<br>
+++ b/llvm/lib/Target/X86/X86FastISel.cpp<br>
@@ -784,7 +784,7 @@ bool X86FastISel::handleConstantAddresses(const Value *V, X86AddressMode &AM) {<br>
           RC  = &X86::GR32RegClass;<br>
         }<br>
<br>
-        if (Subtarget->isPICStyleRIPRel())<br>
+        if (Subtarget->isPICStyleRIPRel() || GVFlags == X86II::MO_GOTPCREL)<br>
           StubAM.Base.Reg = X86::RIP;<br>
<br>
         LoadReg = createResultReg(RC);<br>
<br>
diff  --git a/llvm/test/CodeGen/X86/fast-isel-mem.ll b/llvm/test/CodeGen/X86/fast-isel-mem.ll<br>
index 3f1d9cae9340..42f210199e64 100644<br>
--- a/llvm/test/CodeGen/X86/fast-isel-mem.ll<br>
+++ b/llvm/test/CodeGen/X86/fast-isel-mem.ll<br>
@@ -1,7 +1,8 @@<br>
 ; RUN: llc < %s -fast-isel -mtriple=i386-apple-darwin -mcpu=generic | FileCheck %s<br>
 ; RUN: llc < %s -fast-isel -mtriple=i386-apple-darwin -mcpu=atom | FileCheck -check-prefix=ATOM %s<br>
+; RUN: llc < %s -fast-isel -fast-isel-abort=3 -mtriple=x86_64 | FileCheck -check-prefix=ELF64 %s<br>
<br>
-@src = external global i32<br>
+@src = external dso_preemptable global i32<br>
<br>
 ; rdar://6653118<br>
 define i32 @loadgv() nounwind {<br>
@@ -26,6 +27,14 @@ entry:<br>
 ; ATOM:         movl    %eax, (%ecx)<br>
 ; ATOM:         ret<br>
<br>
+;; dso_preemptable src is loaded via GOT indirection.<br>
+; ELF64-LABEL: loadgv:<br>
+; ELF64:        movq    src@GOTPCREL(%rip), %rcx<br>
+; ELF64-NEXT:   movl    (%rcx), %eax<br>
+; ELF64-NEXT:   addl    (%rcx), %eax<br>
+; ELF64-NEXT:   movl    %eax, (%rcx)<br>
+; ELF64-NEXT:   retq<br>
+<br>
 }<br>
<br>
 %stuff = type { i32 (...)** }<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><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top:2px solid rgb(213,15,37)">Teresa Johnson |</td><td nowrap style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td nowrap style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top:2px solid rgb(238,178,17)"><br></td></tr></tbody></table></span></div></div></div>