@@ -997,26 +997,29 @@ class BinaryWrapper {
997
997
ImagesInits.push_back (ConstantStruct::get (
998
998
getDeviceImageTy (), Fbin.first , Fbin.second , EntriesB, EntriesE));
999
999
1000
- // Create an object that holds <address, size> pair for the device image
1001
- // and put it into a .tgtimg section. This section can be used for finding
1002
- // and extracting all device images from the fat binary after linking.
1003
- Type *IntPtrTy = M.getDataLayout ().getIntPtrType (C);
1004
- auto *ImgInfoArr = ConstantArray::get (
1005
- ArrayType::get (IntPtrTy, 2 ),
1006
- {ConstantExpr::getPointerCast (Fbin.first , IntPtrTy),
1007
- ConstantInt::get (IntPtrTy, Bin->getBufferSize ())});
1008
- auto *ImgInfoVar = new GlobalVariable (
1009
- M, ImgInfoArr->getType (), /* isConstant*/ true ,
1010
- GlobalVariable::InternalLinkage, ImgInfoArr,
1011
- Twine (OffloadKindTag) + Twine (ImgId) + Twine (" .info" ));
1012
- ImgInfoVar->setAlignment (
1013
- MaybeAlign (M.getDataLayout ().getTypeStoreSize (IntPtrTy) * 2u ));
1014
- ImgInfoVar->setUnnamedAddr (GlobalValue::UnnamedAddr::Local);
1015
- ImgInfoVar->setSection (" .tgtimg" );
1016
-
1017
- // Add image info to the used list to force it to be emitted to the
1018
- // object.
1019
- appendToUsed (M, ImgInfoVar);
1000
+ if (EmitRegFuncs) {
1001
+ // Create an object that holds <address, size> pair for the device image
1002
+ // and put it into a .tgtimg section. This section can be used for
1003
+ // finding and extracting all device images from the fat binary after
1004
+ // linking.
1005
+ Type *IntPtrTy = M.getDataLayout ().getIntPtrType (C);
1006
+ auto *ImgInfoArr = ConstantArray::get (
1007
+ ArrayType::get (IntPtrTy, 2 ),
1008
+ {ConstantExpr::getPointerCast (Fbin.first , IntPtrTy),
1009
+ ConstantInt::get (IntPtrTy, Bin->getBufferSize ())});
1010
+ auto *ImgInfoVar = new GlobalVariable (
1011
+ M, ImgInfoArr->getType (), /* isConstant*/ true ,
1012
+ GlobalVariable::InternalLinkage, ImgInfoArr,
1013
+ Twine (OffloadKindTag) + Twine (ImgId) + Twine (" .info" ));
1014
+ ImgInfoVar->setAlignment (
1015
+ MaybeAlign (M.getDataLayout ().getTypeStoreSize (IntPtrTy) * 2u ));
1016
+ ImgInfoVar->setUnnamedAddr (GlobalValue::UnnamedAddr::Local);
1017
+ ImgInfoVar->setSection (" .tgtimg" );
1018
+
1019
+ // Add image info to the used list to force it to be emitted to the
1020
+ // object.
1021
+ appendToUsed (M, ImgInfoVar);
1022
+ }
1020
1023
1021
1024
ImgId++;
1022
1025
}
0 commit comments