This is the error message when I use the following command:
clang++ test.cpp -mypass -fno-use-cxa-atexit
to compile my test.cpp
source file directly with my transform pass.
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:
********************
However, when I use the following command to compile seperately:
clang++ -emit-llvm -S test.cpp -mypass -fno-use-cxa-atexit
This command generate test.ll
and then use:
llvm-as test.ll -o test.bc
to generate test.bc
and finally use:
lli test.bc
to run the program.
There are no errors and my program works well.
Then why the error came when I compile the test.cpp
directly?
Here is part of my source code in pass:
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);