title: fatal error: error in backend: Cannot select: 0x7793fa0: f64 = xor 0x74291b0, Constant:i8<-3>
body: <p>This is the error message when I use the following command:</p>
  
  <pre><code>clang++ test.cpp -mypass -fno-use-cxa-atexit
  </code></pre>
  
  <p>to compile my <code>test.cpp</code> source file directly with my transform pass.</p>
  
  <pre><code>Error message:
  fatal error: error in backend: Cannot select: 0x7793fa0: f64 = xor 0x74291b0,
        Constant:i8&lt;-3&gt;
    0x74291b0: f64,ch = load&lt;LD8[%1064](align=1)&gt; 0x732b440, 0x74317d0, undef:i64
      0x74317d0: i64 = add 0x7794390, 0x7428f10
        0x7794390: i64 = shl 0x7464360, Constant:i8&lt;3&gt;
          0x7464360: i64 = sign_extend 0x7430d50
            0x7430d50: i32,ch = CopyFromReg 0x732b440, Register:i32 %vreg212
              0x77949b0: i32 = Register %vreg212
          0x77bbd40: i8 = Constant&lt;3&gt;
        0x7428f10: i64 = X86ISD::Wrapper TargetGlobalAddress:i64&lt;[27 x double]* @_ZZ9test_mainiPPcE5valsA.291&gt; 0
          0x77904a0: i64 = TargetGlobalAddress&lt;[27 x double]* @_ZZ9test_mainiPPcE5valsA.291&gt; 0
      0x7431990: i64 = undef
    0x77bbdb0: i8 = Constant&lt;-3&gt;
  In function: .datadiv_decode15430557481081536446
  clang-3.9: error: clang frontend command failed with exit code 70 (use -v to see invocation)
  clang version 3.9.1 (tags/RELEASE_391/final)
  Target: x86_64-unknown-linux-gnu
  Thread model: posix
  InstalledDir: /home/oubotong/obf/bin
  clang-3.9: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
  clang-3.9: note: diagnostic msg: 
  ********************
  </code></pre>
  
  <p>However, when I use the following command to compile seperately:</p>
  
  <pre><code>clang++ -emit-llvm -S test.cpp -mypass -fno-use-cxa-atexit
  </code></pre>
  
  <p>This  command generate <code>test.ll</code> and then use:</p>
  
  <pre><code>llvm-as test.ll -o test.bc
  </code></pre>
  
  <p>to generate <code>test.bc</code> and finally use:</p>
  
  <pre><code>lli test.bc
  </code></pre>
  
  <p>to run the program.
  There are no errors and my program works well.
  Then why the error came when I compile the <code>test.cpp</code> directly?
  Here is part of my source code in pass:</p>
  
  <pre><code>LoadInst *Load=builder.CreateLoad(gvar);
  Load-&gt;setAlignment(8);
  Value* indexList[2] = {ConstantInt::get(variable-&gt;getType(), 0), variable};                                 
  Value *const_key=builder.getInt8(key);
  Value *GEP=builder.CreateGEP(gvar,ArrayRef&lt;Value*&gt;(indexList, 2),"arrayIdx");
  LoadInst *loadElement=builder.CreateLoad(GEP);
  loadElement-&gt;setAlignment(1);
  Value *Xor = builder.CreateXor(loadElement,const_key,"xor");
  StoreInst *Store = builder.CreateStore(Xor, GEP);
  Store-&gt;setAlignment(1);
  </code></pre>