[compiler-rt] [flang] [libcxx] [libc] [lldb] [clang-tools-extra] [clang] [llvm] [PowerPC] Support mcmodel=large for AIX (PR #70652)

Chen Zheng via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 5 19:48:53 PST 2023


================
@@ -5723,16 +5723,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
     StringRef CM = A->getValue();
     bool Ok = false;
-    if (Triple.isOSAIX() && CM == "medium") {
+    if (Triple.isOSAIX() && CM == "medium")
       CM = "large";
-      Ok = true;
-    }
     if (Triple.isAArch64(64)) {
       Ok = CM == "tiny" || CM == "small" || CM == "large";
       if (CM == "large" && RelocationModel != llvm::Reloc::Static)
         D.Diag(diag::err_drv_argument_only_allowed_with)
             << A->getAsString(Args) << "-fno-pic";
-    } else if (Triple.isPPC64()) {
+    } else if (Triple.isPPC64() || Triple.isOSAIX()) {
----------------
chenzheng1030 wrote:

```
int b = 20;
int foo()
{
  return b;
}
```

- Small code model:
```
.foo:
# %bb.0:                                # %entry
	lwz 3, L..C0(2)                         # @b  ;; Use one instruction to load b's address in the TOC. So only 2^16 bytes TOC range can be accessed because of encoding limitation of `lwz` instruction.
	lwz 3, 0(3)
	blr
```

- large code model
```
.foo:
# %bb.0:                                # %entry
	addis 3, L..C0 at u(2)
	lwz 3, L..C0 at l(3)          ;; Use two instructions to load b's address. So that bigger TOC range can be accessed.
	lwz 3, 0(3)
	blr
```

https://github.com/llvm/llvm-project/pull/70652


More information about the cfe-commits mailing list