Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

address constants forced to registers in small-model static-reloc x86-64 #1434

Closed
sunfishcode opened this issue Dec 19, 2006 · 1 comment
Closed
Labels
backend:X86 bugzilla Issues migrated from bugzilla code-quality

Comments

@sunfishcode
Copy link
Member

Bugzilla Link 1062
Resolution FIXED
Resolved on Feb 22, 2010 12:55
Version 1.9
OS Linux

Extended Description

Weak, extern and linkonce symbols are currently excluded from address
operands in x86-64 with the small memory model and static linking.

With this test case:

%x = external global int

implementation

int %foo(long %i) {
%a = getelementptr int* %x, long %i
%t = load int* %a
ret int %t
}

Currently llc -march=x86-64 -code-model=small -relocation-model=static
emits this:

    leaq x(%rip), %rcx
    movl (%rcx,%rax,4), %eax

I believe should emit this:

    movl x(,%rax,4), %eax

Unless I'm missing something, it should be safe to let llc do this,
with the following patch.

Index: X86ISelDAGToDAG.cpp

RCS file: /var/cvs/llvm/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp,v
retrieving revision 1.138
diff -u -r1.138 X86ISelDAGToDAG.cpp
--- X86ISelDAGToDAG.cpp
+++ X86ISelDAGToDAG.cpp
@@ -604,9 +604,7 @@
SDOperand N0 = N.getOperand(0);
if (GlobalAddressSDNode *G = dyn_cast(N0)) {
GlobalValue *GV = G->getGlobal();

  •    bool isAbs32 = !is64Bit ||
    
  •      (isStatic && !(GV->isExternal() || GV->hasWeakLinkage() ||
    
  •                     GV->hasLinkOnceLinkage()));
    
  •    bool isAbs32 = !is64Bit || isStatic;
       if (isAbs32 || isRoot) {
         AM.GV = G->getGlobal();
         AM.Disp += G->getOffset();
    
@llvmbot
Copy link
Collaborator

llvmbot commented Dec 19, 2006

Patch applied. Thanks!

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
clementval pushed a commit to clementval/llvm-project that referenced this issue Feb 16, 2022
* [flang][driver] Extend support for LLVM IR/BC files

Before this change, `clangDriver` (i.e. the compiles driver library)
would always use `clang` to compile LLVM IR or LLVM BC files (even when
`flang-new` was used to invoke the driver). With this change, Flang will
finally accept LLVM IR and LLVM BC alongside e.g. Fortran input files.
This means that from now on it is up to the user to decide whether to
use Flang or Clang to compile an LLVM file (`flang-new -c file.bc` and
`clang -c file.bc`, respectively).

To complement this, support for generating LLVM BC files is added. This
requires the `BitcodeWriterPass` pass to be run on the input LLVM IR
module and is implemented as a dedicated frontend aciton.

The new functionality as seen by the user:
1. LLVM BC file generation (`flang-new -c -emit-llvm file.90` or
   `flang-new -fc1 -emit-llvm-bc file.f90`)
2. Ability to consume LLVM IR and BC files and to lower them to object
   files (`flang-new -c file.bc` or `flang-new -c file.ll`)

The new behaviour is consistent with `clang` and `clang -cc1`.

* [flang][driver] Add support for `-save-temps`

This patch adds support for `-save-temps` in `flang-new`, Flang's
compiler driver. The semantics of this option are inherited from Clang.

The file extension for temporary Fortran preprocessed files is set to
`i`. This is identical to what Clang uses for C (or C++) preprocessed
files. I have tried researching what other compilers do here, but I
couldn't find any definitive answers. One GFortran thread [1] suggests
that indeed it is not clear what the right approach should be.

As `-save-temps` makes the compiler run every phase separately, in Flang
one currently has to use it with `-fno-integrated-as`. Otherwise, an
invocation to the integrated assembler driver is generated (i.e.
something equivalent to `clang -cc1as` from Clang), but this is not yet
implemented in Flang.

[1] https://gcc.gnu.org/bugzilla//show_bug.cgi?id=81615

* Add missing llvm-dis dependency
clementval added a commit to clementval/llvm-project that referenced this issue Feb 16, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 bugzilla Issues migrated from bugzilla code-quality
Projects
None yet
Development

No branches or pull requests

2 participants