]> granicus.if.org Git - llvm/commitdiff
GlobalISel: fix GOT accesses on AArch64.
authorTim Northover <tnorthover@apple.com>
Tue, 13 Dec 2016 18:25:38 +0000 (18:25 +0000)
committerTim Northover <tnorthover@apple.com>
Tue, 13 Dec 2016 18:25:38 +0000 (18:25 +0000)
We were using the correct pseudo-instruction, but because the operand's flags
weren't set correctly we still ended up emitting incorrect relocations during
MC lowering.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289566 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AArch64/AArch64InstructionSelector.cpp
test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir

index a5303fcdbb6104a1c380fc3664f9bde476af8abb..4274b4080ccdd4d03316a0a632fd3801dab12a2b 100644 (file)
@@ -662,9 +662,10 @@ bool AArch64InstructionSelector::select(MachineInstr &I) const {
       return false;
     }
     unsigned char OpFlags = STI.ClassifyGlobalReference(GV, TM);
-    if (OpFlags & AArch64II::MO_GOT)
+    if (OpFlags & AArch64II::MO_GOT) {
       I.setDesc(TII.get(AArch64::LOADgot));
-    else {
+      I.getOperand(1).setTargetFlags(OpFlags);
+    } else {
       I.setDesc(TII.get(AArch64::MOVaddr));
       I.getOperand(1).setTargetFlags(OpFlags | AArch64II::MO_PAGE);
       MachineInstrBuilder MIB(MF, I);
index e362521ca5bbd0f72408d4df752d6e0e01ccadff..22210e49bd77f3d82d9358c2d989c43876df32b2 100644 (file)
@@ -2408,7 +2408,7 @@ registers:
 # CHECK:  body:
 # IOS: %0 = MOVaddr target-flags(aarch64-page) @var_local, target-flags(aarch64-pageoff, aarch64-nc) @var_local
 # LINUX-DEFAULT: %0 = MOVaddr target-flags(aarch64-page) @var_local, target-flags(aarch64-pageoff, aarch64-nc) @var_local
-# LINUX-PIC: %0 = LOADgot @var_local
+# LINUX-PIC: %0 = LOADgot target-flags(aarch64-got) @var_local
 body:             |
   bb.0:
     %0(p0) = G_GLOBAL_VALUE @var_local
@@ -2423,9 +2423,9 @@ registers:
   - { id: 0, class: gpr }
 
 # CHECK:  body:
-# IOS: %0 = LOADgot @var_got
+# IOS: %0 = LOADgot target-flags(aarch64-got) @var_got
 # LINUX-DEFAULT: %0 = MOVaddr target-flags(aarch64-page) @var_got, target-flags(aarch64-pageoff, aarch64-nc) @var_got
-# LINUX-PIC: %0 = LOADgot @var_got
+# LINUX-PIC: %0 = LOADgot target-flags(aarch64-got) @var_got
 body:             |
   bb.0:
     %0(p0) = G_GLOBAL_VALUE @var_got