[PATCH] D48417: Fix global variable addressing code generation issue in PIC medium code model

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 22 17:09:58 PDT 2018


rnk added a comment.

In https://reviews.llvm.org/D48417#1141304, @craig.topper wrote:

> @rnk, I see that this patch touches isOffsetSuitableForCodeModel , but https://reviews.llvm.org/D47211 does not.


I think this change implements some extra folding that would only be appropriate once we have heuristics in place for classifying "near" and "far" globals. I was thinking we'd implement the logic for classifying globals in clang, since we'll probably want both explicit attributes and size cutoffs, and that we'd mark "near" globals, and unadorned globals would always be treated as far away, requiring GOTPCREL or GOTOFF64 relocations, depending on whether they are known to be dso_local or not.



================
Comment at: test/CodeGen/X86/x86-64-codemodel-medium-internal.ll:21-22
+; CHECK-MEDIUM:   movabsq $global_arr+28,
+; CHECK-MEDIUM-PIC-LABEL:  foo:
+; CHECK-MEDIUM-PIC:  addl global_arr+28(%rip),
+  %0 = load i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* bitcast (<{ i32, i32, [98 x i32] }>* @global_arr to [100 x i32]*), i64 0, i64 7), align 4
----------------
This doesn't seem correct. `global_arr` might be too far away, right?


Repository:
  rL LLVM

https://reviews.llvm.org/D48417





More information about the llvm-commits mailing list