@@ -2662,7 +2662,7 @@ void ModuleAddressSanitizer::instrumentGlobals(IRBuilder<> &IRB,
2662
2662
G->eraseFromParent ();
2663
2663
NewGlobals[i] = NewGlobal;
2664
2664
2665
- Constant *ODRIndicator = ConstantPointerNull::get (PtrTy );
2665
+ Constant *ODRIndicator = Constant::getNullValue (IntptrTy );
2666
2666
GlobalValue *InstrumentedGlobal = NewGlobal;
2667
2667
2668
2668
bool CanUsePrivateAliases =
@@ -2677,8 +2677,7 @@ void ModuleAddressSanitizer::instrumentGlobals(IRBuilder<> &IRB,
2677
2677
2678
2678
// ODR should not happen for local linkage.
2679
2679
if (NewGlobal->hasLocalLinkage ()) {
2680
- ODRIndicator =
2681
- ConstantExpr::getIntToPtr (ConstantInt::get (IntptrTy, -1 ), PtrTy);
2680
+ ODRIndicator = ConstantInt::get (IntptrTy, -1 );
2682
2681
} else if (UseOdrIndicator) {
2683
2682
// With local aliases, we need to provide another externally visible
2684
2683
// symbol __odr_asan_XXX to detect ODR violation.
@@ -2692,7 +2691,7 @@ void ModuleAddressSanitizer::instrumentGlobals(IRBuilder<> &IRB,
2692
2691
ODRIndicatorSym->setVisibility (NewGlobal->getVisibility ());
2693
2692
ODRIndicatorSym->setDLLStorageClass (NewGlobal->getDLLStorageClass ());
2694
2693
ODRIndicatorSym->setAlignment (Align (1 ));
2695
- ODRIndicator = ODRIndicatorSym;
2694
+ ODRIndicator = ConstantExpr::getPtrToInt ( ODRIndicatorSym, IntptrTy) ;
2696
2695
}
2697
2696
2698
2697
Constant *Initializer = ConstantStruct::get (
@@ -2703,8 +2702,7 @@ void ModuleAddressSanitizer::instrumentGlobals(IRBuilder<> &IRB,
2703
2702
ConstantExpr::getPointerCast (Name, IntptrTy),
2704
2703
ConstantExpr::getPointerCast (getOrCreateModuleName (), IntptrTy),
2705
2704
ConstantInt::get (IntptrTy, MD.IsDynInit ),
2706
- Constant::getNullValue (IntptrTy),
2707
- ConstantExpr::getPointerCast (ODRIndicator, IntptrTy));
2705
+ Constant::getNullValue (IntptrTy), ODRIndicator);
2708
2706
2709
2707
LLVM_DEBUG (dbgs () << " NEW GLOBAL: " << *NewGlobal << " \n " );
2710
2708
0 commit comments