致命错误:后端错误:无法选择:0x7793fa0:f64 = xor 0x74291b0,常数:i8< -3>

时间:2018-04-12 04:04:04

标签: llvm

使用以下命令时,这是错误消息:

clang++ test.cpp -mypass -fno-use-cxa-atexit

使用我的转换传递直接编译我的test.cpp源文件。

Error message:
fatal error: error in backend: Cannot select: 0x7793fa0: f64 = xor 0x74291b0,
      Constant:i8<-3>
  0x74291b0: f64,ch = load<LD8[%1064](align=1)> 0x732b440, 0x74317d0, undef:i64
    0x74317d0: i64 = add 0x7794390, 0x7428f10
      0x7794390: i64 = shl 0x7464360, Constant:i8<3>
        0x7464360: i64 = sign_extend 0x7430d50
          0x7430d50: i32,ch = CopyFromReg 0x732b440, Register:i32 %vreg212
            0x77949b0: i32 = Register %vreg212
        0x77bbd40: i8 = Constant<3>
      0x7428f10: i64 = X86ISD::Wrapper TargetGlobalAddress:i64<[27 x double]* @_ZZ9test_mainiPPcE5valsA.291> 0
        0x77904a0: i64 = TargetGlobalAddress<[27 x double]* @_ZZ9test_mainiPPcE5valsA.291> 0
    0x7431990: i64 = undef
  0x77bbdb0: i8 = Constant<-3>
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: 
********************

但是,当我使用以下命令单独编译时:

clang++ -emit-llvm -S test.cpp -mypass -fno-use-cxa-atexit

此命令生成test.ll,然后使用:

llvm-as test.ll -o test.bc

生成test.bc并最终使用:

lli test.bc

运行程序。 没有错误,我的程序运行良好。 那么为什么我直接编译test.cpp时会出现错误? 以下是传递源代码的一部分:

LoadInst *Load=builder.CreateLoad(gvar);
Load->setAlignment(8);
Value* indexList[2] = {ConstantInt::get(variable->getType(), 0), variable};                                 
Value *const_key=builder.getInt8(key);
Value *GEP=builder.CreateGEP(gvar,ArrayRef<Value*>(indexList, 2),"arrayIdx");
LoadInst *loadElement=builder.CreateLoad(GEP);
loadElement->setAlignment(1);
Value *Xor = builder.CreateXor(loadElement,const_key,"xor");
StoreInst *Store = builder.CreateStore(Xor, GEP);
Store->setAlignment(1);

1 个答案:

答案 0 :(得分:0)

答案很晚,但是实际上,当您拥有.ll文件时,llc命令可以为您提供一些有意义的提示,说明为什么事情无法编译。

Cannot select错误更加隐秘。